Search in sources :

Example 6 with Halo

use of org.opengis.style.Halo in project geotoolkit by Geomatys.

the class SE100toGTTransformer method visit.

/**
 * Transform a SLD v1.0 text symbolizer in GT text symbolizer.
 */
public TextSymbolizer visit(final org.geotoolkit.sld.xml.v100.TextSymbolizer tst) {
    if (tst == null)
        return null;
    final Expression label = visitExpression(tst.getLabel());
    final Font font = (tst.getFont() == null) ? styleFactory.font() : visit(tst.getFont());
    final LabelPlacement placement = (tst.getLabelPlacement() == null) ? styleFactory.pointPlacement() : visit(tst.getLabelPlacement());
    final Halo halo = visit(tst.getHalo());
    final Fill fill = visit(tst.getFill());
    final Unit uom = Units.POINT;
    final String geom = visitGeom(tst.getGeometry());
    final String name = null;
    final Description desc = StyleConstants.DEFAULT_DESCRIPTION;
    if (label == null)
        return null;
    return styleFactory.textSymbolizer(name, geom, desc, uom, label, font, placement, halo, fill);
}
Also used : Fill(org.opengis.style.Fill) GraphicFill(org.opengis.style.GraphicFill) Description(org.opengis.style.Description) LabelPlacement(org.opengis.style.LabelPlacement) Expression(org.opengis.filter.Expression) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) InternationalString(org.opengis.util.InternationalString) Unit(javax.measure.Unit) Font(org.opengis.style.Font) Halo(org.opengis.style.Halo)

Example 7 with Halo

use of org.opengis.style.Halo in project geotoolkit by Geomatys.

the class MapfileToSLDProcess method createTextSymbolizer.

private List<Symbolizer> createTextSymbolizer(final Expression label, final Feature lblStyle) {
    Expression expLabelColor = (Expression) lblStyle.getPropertyValue(LABEL_COLOR.toString());
    Expression expLabelSize = (Expression) lblStyle.getPropertyValue(LABEL_SIZE.toString());
    Expression expHaloColor = (Expression) lblStyle.getPropertyValue(LABEL_OUTLINECOLOR.toString());
    Integer valHaloWidth = (Integer) lblStyle.getPropertyValue(LABEL_OUTLINEWIDTH.toString());
    String valAngle = (String) lblStyle.getPropertyValue(LABEL_ANGLE.toString());
    if (expLabelColor == null) {
        expLabelColor = SF.literal(Color.BLACK);
    }
    if (expLabelSize == null) {
        expLabelSize = DEFAULT_FONT_SIZE;
    }
    if (expHaloColor == null) {
        expHaloColor = SF.literal(Color.WHITE);
    }
    if (valHaloWidth == null) {
        valHaloWidth = 0;
    }
    Expression expHaloWidth = FF.literal(valHaloWidth);
    final List<Symbolizer> symbolizers = new ArrayList<Symbolizer>();
    LabelPlacement placement = SF.pointPlacement();
    if (valAngle != null) {
        if ("FOLLOW".equalsIgnoreCase(valAngle) || "AUTO".equalsIgnoreCase(valAngle)) {
            final Expression offset = FF.divide(expLabelSize, FF.literal(-2));
            final Expression initial = FF.literal(20);
            Expression gap = LITERAL_ZERO_FLOAT;
            boolean repeated = false;
            final boolean aligned = false;
            final boolean generalize = false;
            Integer minDistance = (Integer) lblStyle.getPropertyValue(LABEL_MINDISTANCE.toString());
            if (minDistance != null) {
                repeated = true;
                gap = FF.literal(minDistance);
            }
            placement = SF.linePlacement(offset, initial, gap, repeated, aligned, generalize);
        } else {
            Expression rotation = LITERAL_ZERO_FLOAT;
            // try if it's a number
            try {
                double d = Double.valueOf(valAngle);
                rotation = FF.literal(d);
            } catch (Exception ex) {
            }
            placement = SF.pointPlacement(DEFAULT_ANCHOR_POINT, DEFAULT_DISPLACEMENT, rotation);
        }
    }
    // general informations
    final String name = "";
    final Description desc = DEFAULT_DESCRIPTION;
    // use the default geometry of the feature
    final String geometry = null;
    final Unit unit = Units.POINT;
    final Font font = SF.font(FF.literal("Arial"), FONT_STYLE_NORMAL, FONT_WEIGHT_NORMAL, expLabelSize);
    final Halo halo = SF.halo(SF.fill(expHaloColor), expHaloWidth);
    final Fill fill = SF.fill(expLabelColor);
    final TextSymbolizer symbol = SF.textSymbolizer(name, geometry, desc, unit, label, font, placement, halo, fill);
    symbolizers.add(symbol);
    return symbolizers;
}
Also used : Fill(org.opengis.style.Fill) Description(org.opengis.style.Description) ArrayList(java.util.ArrayList) Unit(javax.measure.Unit) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) Symbolizer(org.opengis.style.Symbolizer) JAXBException(javax.xml.bind.JAXBException) ProcessException(org.geotoolkit.process.ProcessException) IOException(java.io.IOException) Font(org.opengis.style.Font) LabelPlacement(org.opengis.style.LabelPlacement) Expression(org.opengis.filter.Expression) TextSymbolizer(org.opengis.style.TextSymbolizer) Halo(org.opengis.style.Halo)

Example 8 with Halo

use of org.opengis.style.Halo in project geotoolkit by Geomatys.

the class Styles method linedText.

public static MutableStyle linedText() {
    // general informations
    final String name = "mySymbol";
    final Description desc = DEFAULT_DESCRIPTION;
    // use the default geometry of the feature
    final String geometry = null;
    final Unit unit = Units.POINT;
    final Expression label = FF.property("CNTRY_NAME");
    final Font font = SF.font(FF.literal("Arial"), FONT_STYLE_ITALIC, FONT_WEIGHT_BOLD, FF.literal(14));
    final LabelPlacement placement = SF.linePlacement(FF.literal(0));
    final Halo halo = SF.halo(Color.WHITE, 1);
    final Fill fill = SF.fill(Color.BLUE);
    final TextSymbolizer symbol = SF.textSymbolizer(name, geometry, desc, unit, label, font, placement, halo, fill);
    final MutableStyle style = SF.style(DEFAULT_POLYGON_SYMBOLIZER, symbol);
    return style;
}
Also used : Fill(org.opengis.style.Fill) GraphicFill(org.opengis.style.GraphicFill) Description(org.opengis.style.Description) LabelPlacement(org.opengis.style.LabelPlacement) MutableStyle(org.geotoolkit.style.MutableStyle) Expression(org.opengis.filter.Expression) TextSymbolizer(org.opengis.style.TextSymbolizer) Unit(javax.measure.Unit) Font(org.opengis.style.Font) Halo(org.opengis.style.Halo)

Example 9 with Halo

use of org.opengis.style.Halo in project geotoolkit by Geomatys.

the class DefaultStyleVisitor method visit.

@Override
public Object visit(final TextSymbolizer textSymbolizer, Object data) {
    final Fill fill = textSymbolizer.getFill();
    if (fill != null) {
        data = fill.accept(this, data);
    }
    final Font font = textSymbolizer.getFont();
    if (font != null) {
        data = font.accept(this, data);
    }
    final Halo halo = textSymbolizer.getHalo();
    if (halo != null) {
        data = halo.accept(this, data);
    }
    final Expression label = textSymbolizer.getLabel();
    if (label != null) {
        visit(label, data);
    }
    final LabelPlacement place = textSymbolizer.getLabelPlacement();
    if (place != null) {
        data = place.accept(this, data);
    }
    return data;
}
Also used : GraphicFill(org.opengis.style.GraphicFill) Fill(org.opengis.style.Fill) LabelPlacement(org.opengis.style.LabelPlacement) Expression(org.opengis.filter.Expression) Font(org.opengis.style.Font) Halo(org.opengis.style.Halo)

Example 10 with Halo

use of org.opengis.style.Halo in project geotoolkit by Geomatys.

the class ListingPropertyVisitor method visit.

@Override
public Object visit(final TextSymbolizer textSymbolizer, Object data) {
    visitGeomName(textSymbolizer, data);
    final Fill fill = textSymbolizer.getFill();
    if (fill != null) {
        data = fill.accept(this, data);
    }
    final Font font = textSymbolizer.getFont();
    if (font != null) {
        data = font.accept(this, data);
    }
    final Halo halo = textSymbolizer.getHalo();
    if (halo != null) {
        data = halo.accept(this, data);
    }
    final Expression label = textSymbolizer.getLabel();
    if (label != null) {
        visit(label, (Collection<String>) data);
    }
    final LabelPlacement place = textSymbolizer.getLabelPlacement();
    if (place != null) {
        data = place.accept(this, data);
    }
    return data;
}
Also used : GraphicFill(org.opengis.style.GraphicFill) Fill(org.opengis.style.Fill) LabelPlacement(org.opengis.style.LabelPlacement) Expression(org.opengis.filter.Expression) Font(org.opengis.style.Font) Halo(org.opengis.style.Halo)

Aggregations

Expression (org.opengis.filter.Expression)11 Fill (org.opengis.style.Fill)11 Font (org.opengis.style.Font)11 Halo (org.opengis.style.Halo)11 LabelPlacement (org.opengis.style.LabelPlacement)9 Unit (javax.measure.Unit)8 Description (org.opengis.style.Description)8 GraphicFill (org.opengis.style.GraphicFill)7 TextSymbolizer (org.opengis.style.TextSymbolizer)4 SimpleInternationalString (org.apache.sis.util.SimpleInternationalString)3 MutableStyle (org.geotoolkit.style.MutableStyle)3 PointPlacement (org.opengis.style.PointPlacement)2 Dimension (java.awt.Dimension)1 BufferedImage (java.awt.image.BufferedImage)1 Raster (java.awt.image.Raster)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 JAXBException (javax.xml.bind.JAXBException)1 FeatureTypeBuilder (org.apache.sis.feature.builder.FeatureTypeBuilder)1 GeneralEnvelope (org.apache.sis.geometry.GeneralEnvelope)1