Java Code Examples for org.geotools.styling.TextSymbolizer#getFont()

The following examples show how to use org.geotools.styling.TextSymbolizer#getFont() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextSymbolizerDetails.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/** @param textSymbolizer */
private void populateFont(TextSymbolizer textSymbolizer) {
    Font font = textSymbolizer.getFont();

    GroupConfigInterface group = getGroup(GroupIdEnum.FONT);
    group.enable(font != null);

    if (font != null) {
        fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_FAMILY, font);

        fieldConfigVisitor.populateField(FieldIdEnum.FONT_WEIGHT, font.getWeight());
        fieldConfigVisitor.populateField(FieldIdEnum.FONT_STYLE, font.getStyle());
        fieldConfigVisitor.populateField(FieldIdEnum.FONT_SIZE, font.getSize());
    }
    fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_PREVIEW, font);
}
 
Example 2
Source File: BatchUpdateFontUtils.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Contains font details.
 *
 * @param sldData the sld data
 * @return the scale sld data, returns null if invalid SLD string supplied.
 */
public static List<BatchUpdateFontData> containsFonts(SLDDataInterface sldData) {

    List<BatchUpdateFontData> dataList = null;

    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);

    if (sld != null) {
        List<StyledLayer> styledLayerList = sld.layers();

        for (StyledLayer styledLayer : styledLayerList) {
            if (styledLayer instanceof NamedLayerImpl) {
                NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;

                for (Style style : namedLayerImpl.styles()) {
                    for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                        for (Rule rule : fts.rules()) {
                            for (Symbolizer symbolizer : rule.symbolizers()) {
                                if (symbolizer instanceof TextSymbolizer) {
                                    TextSymbolizer textSymbol = (TextSymbolizer) symbolizer;
                                    Font font = textSymbol.getFont();
                                    if (font != null) {
                                        if (dataList == null) {
                                            dataList = new ArrayList<>();
                                        }
                                        BatchUpdateFontData fontSLDData =
                                                new BatchUpdateFontData(sld, sldData);

                                        fontSLDData.setNamedLayer(namedLayerImpl.getName());
                                        fontSLDData.setFeatureTypeStyle(fts.getName());
                                        fontSLDData.setStyle(style.getName());
                                        fontSLDData.setRule(rule);
                                        fontSLDData.setSymbolizer(textSymbol);
                                        fontSLDData.setFont(font);
                                        dataList.add(fontSLDData);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return dataList;
}