Search in sources :

Example 16 with PolygonSymbolizer

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

the class MapfileToSLDProcess method createPolygonSymbolizer.

private List<Symbolizer> createPolygonSymbolizer(final Feature style) {
    Expression expColor = (Expression) style.getPropertyValue(STYLE_COLOR.toString());
    Expression expOpacity = (Expression) style.getPropertyValue(STYLE_OPACITY.toString());
    if (expOpacity == null) {
        expOpacity = DEFAULT_FILL_OPACITY;
    } else {
        // mapfile opacity is expressed in %, SE is in 0-1
        if (expOpacity instanceof Literal) {
            double d = ((Number) expOpacity.apply(null)).doubleValue();
            d /= 100d;
            expOpacity = FF.literal(d);
        } else {
            expOpacity = FF.divide(expOpacity, FF.literal(100));
        }
    }
    if (expColor == null) {
        expColor = DEFAULT_FILL_COLOR;
    }
    Fill fill = null;
    Stroke stroke = null;
    fill = SF.fill(expColor, expOpacity);
    final List<Symbolizer> symbolizers = new ArrayList<Symbolizer>();
    // 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 Displacement disp = DEFAULT_DISPLACEMENT;
    final Expression offset = LITERAL_ZERO_FLOAT;
    // stroke element
    // final Expression color = SF.literal(Color.BLUE);
    // final Expression width = FF.literal(4);
    // final Expression opacity = LITERAL_ONE_FLOAT;
    // final Stroke stroke = SF.stroke(color,width,opacity);
    final PolygonSymbolizer symbolizer = SF.polygonSymbolizer(name, geometry, desc, unit, stroke, fill, disp, offset);
    symbolizers.add(symbolizer);
    return symbolizers;
}
Also used : Fill(org.opengis.style.Fill) Stroke(org.opengis.style.Stroke) Description(org.opengis.style.Description) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) 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) Displacement(org.opengis.style.Displacement) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal)

Example 17 with PolygonSymbolizer

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

the class Styles method graphicFillPolygon.

public static MutableStyle graphicFillPolygon() {
    // 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 Displacement disp = DEFAULT_DISPLACEMENT;
    final Expression offset = LITERAL_ZERO_FLOAT;
    // stroke element
    final Expression color = SF.literal(Color.BLUE);
    final Expression width = FF.literal(2);
    final Expression opacity = LITERAL_ONE_FLOAT;
    final Stroke stroke = SF.stroke(color, width, opacity);
    // fill element
    // a pattern that will be repeated like a mosaic
    final Expression size = FF.literal(12);
    final Expression rotation = LITERAL_ONE_FLOAT;
    final AnchorPoint anchor = DEFAULT_ANCHOR_POINT;
    final List<GraphicalSymbol> symbols = new ArrayList<GraphicalSymbol>();
    final Stroke fillStroke = SF.stroke(Color.BLACK, 2);
    final Fill pattern = SF.fill(Color.BLUE);
    final Mark mark = SF.mark(MARK_CROSS, pattern, fillStroke);
    symbols.add(mark);
    final GraphicFill graphicfill = SF.graphicFill(symbols, opacity, size, rotation, anchor, disp);
    final Fill fill = SF.fill(graphicfill, color, opacity);
    final PolygonSymbolizer symbolizer = SF.polygonSymbolizer(name, geometry, desc, unit, stroke, fill, disp, offset);
    final MutableStyle style = SF.style(symbolizer);
    return style;
}
Also used : Stroke(org.opengis.style.Stroke) GraphicStroke(org.opengis.style.GraphicStroke) Fill(org.opengis.style.Fill) GraphicFill(org.opengis.style.GraphicFill) Description(org.opengis.style.Description) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) ExternalMark(org.opengis.style.ExternalMark) Mark(org.opengis.style.Mark) Unit(javax.measure.Unit) Displacement(org.opengis.style.Displacement) AnchorPoint(org.opengis.style.AnchorPoint) MutableStyle(org.geotoolkit.style.MutableStyle) Expression(org.opengis.filter.Expression) GraphicFill(org.opengis.style.GraphicFill)

Example 18 with PolygonSymbolizer

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

the class Styles method shadowPolygon.

public static MutableStyle shadowPolygon() {
    // first symbol classic
    final PolygonSymbolizer symbol1 = SF.polygonSymbolizer(null, SF.fill(Color.ORANGE), null);
    // second symbol for the shadow
    final PolygonSymbolizer symbol2 = SF.polygonSymbolizer("mySymbol", (String) null, DEFAULT_DESCRIPTION, Units.POINT, null, SF.fill(Color.DARK_GRAY), SF.displacement(3, -4), LITERAL_ZERO_FLOAT);
    final MutableStyle style = SF.style(symbol2, symbol1);
    return style;
}
Also used : MutableStyle(org.geotoolkit.style.MutableStyle) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer)

Example 19 with PolygonSymbolizer

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

the class Styles method colorPolygon.

public static MutableStyle colorPolygon() {
    // 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 Displacement disp = DEFAULT_DISPLACEMENT;
    final Expression offset = LITERAL_ZERO_FLOAT;
    // stroke element
    final Expression color = SF.literal(Color.BLUE);
    final Expression width = FF.literal(4);
    final Expression opacity = LITERAL_ONE_FLOAT;
    final Stroke stroke = SF.stroke(color, width, opacity);
    // fill element
    final Fill fill = SF.fill(Color.ORANGE);
    final PolygonSymbolizer symbolizer = SF.polygonSymbolizer(name, geometry, desc, unit, stroke, fill, disp, offset);
    final MutableStyle style = SF.style(symbolizer);
    return style;
}
Also used : Stroke(org.opengis.style.Stroke) GraphicStroke(org.opengis.style.GraphicStroke) Fill(org.opengis.style.Fill) GraphicFill(org.opengis.style.GraphicFill) Description(org.opengis.style.Description) MutableStyle(org.geotoolkit.style.MutableStyle) Expression(org.opengis.filter.Expression) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) Unit(javax.measure.Unit) Displacement(org.opengis.style.Displacement)

Example 20 with PolygonSymbolizer

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

the class Styles method offsetPolygon.

public static MutableStyle offsetPolygon() {
    // we produce a gradient border effect by combining several
    // symbolizer progressivly smaller
    final PolygonSymbolizer symbol1 = SF.polygonSymbolizer("mySymbol", (String) null, DEFAULT_DESCRIPTION, Units.POINT, null, SF.fill(new Color(255, 0, 0)), DEFAULT_DISPLACEMENT, FF.literal(0));
    final PolygonSymbolizer symbol2 = SF.polygonSymbolizer("mySymbol", (String) null, DEFAULT_DESCRIPTION, Units.POINT, null, SF.fill(new Color(255, 70, 70)), DEFAULT_DISPLACEMENT, FF.literal(-10));
    final PolygonSymbolizer symbol3 = SF.polygonSymbolizer("mySymbol", (String) null, DEFAULT_DESCRIPTION, Units.POINT, null, SF.fill(new Color(255, 140, 140)), DEFAULT_DISPLACEMENT, FF.literal(-20));
    final PolygonSymbolizer symbol4 = SF.polygonSymbolizer("mySymbol", (String) null, DEFAULT_DESCRIPTION, Units.POINT, null, SF.fill(new Color(255, 210, 210)), DEFAULT_DISPLACEMENT, FF.literal(-30));
    final MutableStyle style = SF.style(symbol1, symbol2, symbol3, symbol4);
    return style;
}
Also used : MutableStyle(org.geotoolkit.style.MutableStyle) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer)

Aggregations

PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)20 LineSymbolizer (org.opengis.style.LineSymbolizer)9 MutableStyle (org.geotoolkit.style.MutableStyle)8 Fill (org.opengis.style.Fill)8 PointSymbolizer (org.opengis.style.PointSymbolizer)7 Stroke (org.opengis.style.Stroke)7 Expression (org.opengis.filter.Expression)6 RasterSymbolizer (org.opengis.style.RasterSymbolizer)5 TextSymbolizer (org.opengis.style.TextSymbolizer)5 ArrayList (java.util.ArrayList)4 MapLayer (org.apache.sis.portrayal.MapLayer)4 MapLayers (org.apache.sis.portrayal.MapLayers)4 Test (org.junit.Test)4 Symbolizer (org.opengis.style.Symbolizer)4 Unit (javax.measure.Unit)3 FeatureTypeBuilder (org.apache.sis.feature.builder.FeatureTypeBuilder)3 CanvasDef (org.geotoolkit.display2d.service.CanvasDef)3 SceneDef (org.geotoolkit.display2d.service.SceneDef)3 Feature (org.opengis.feature.Feature)3 FeatureType (org.opengis.feature.FeatureType)3