Search in sources :

Example 6 with AnchorPoint

use of org.opengis.style.AnchorPoint 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 7 with AnchorPoint

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

the class Styles method graphicStrokeLine.

public static MutableStyle graphicStrokeLine() throws URISyntaxException {
    // 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 offset = LITERAL_ONE_FLOAT;
    // the stroke fill
    // a pattern that will be repeated like a mosaic
    final Expression size = FF.literal(12);
    final Expression opacity = LITERAL_ONE_FLOAT;
    final Expression rotation = LITERAL_ONE_FLOAT;
    final AnchorPoint anchor = DEFAULT_ANCHOR_POINT;
    final Displacement disp = DEFAULT_DISPLACEMENT;
    final List<GraphicalSymbol> symbols = new ArrayList<GraphicalSymbol>();
    final GraphicalSymbol external = SF.externalGraphic(SF.onlineResource(Styles.class.getResource("/data/fish.png").toURI()), "image/png", null);
    symbols.add(external);
    final Graphic graphic = SF.graphic(symbols, opacity, size, rotation, anchor, disp);
    final Expression initialGap = LITERAL_ZERO_FLOAT;
    final Expression strokeGap = FF.literal(10);
    final GraphicStroke graphicStroke = SF.graphicStroke(graphic, strokeGap, initialGap);
    // the visual element
    final Expression color = SF.literal(Color.BLUE);
    final Expression width = FF.literal(4);
    final Expression linecap = STROKE_CAP_ROUND;
    final Expression linejoin = STROKE_JOIN_BEVEL;
    final float[] dashes = new float[] { 8, 4, 2, 2, 2, 2, 2, 4 };
    final Expression dashOffset = LITERAL_ZERO_FLOAT;
    final Stroke stroke = SF.stroke(graphicStroke, color, opacity, width, linejoin, linecap, dashes, dashOffset);
    final LineSymbolizer symbolizer = SF.lineSymbolizer(name, geometry, desc, unit, stroke, offset);
    final MutableStyle style = SF.style(symbolizer);
    return style;
}
Also used : Stroke(org.opengis.style.Stroke) GraphicStroke(org.opengis.style.GraphicStroke) Description(org.opengis.style.Description) Graphic(org.opengis.style.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) GraphicStroke(org.opengis.style.GraphicStroke) ArrayList(java.util.ArrayList) Unit(javax.measure.Unit) Displacement(org.opengis.style.Displacement) AnchorPoint(org.opengis.style.AnchorPoint) MutableStyle(org.geotoolkit.style.MutableStyle) Expression(org.opengis.filter.Expression) LineSymbolizer(org.opengis.style.LineSymbolizer)

Example 8 with AnchorPoint

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

the class Styles method ttfPoint.

public static MutableStyle ttfPoint() throws URISyntaxException {
    // 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;
    // the visual element
    final Expression size = FF.literal(32);
    final Expression opacity = LITERAL_ONE_FLOAT;
    final Expression rotation = LITERAL_ONE_FLOAT;
    final AnchorPoint anchor = DEFAULT_ANCHOR_POINT;
    final Displacement disp = DEFAULT_DISPLACEMENT;
    final List<GraphicalSymbol> symbols = new ArrayList<GraphicalSymbol>();
    final Stroke stroke = SF.stroke(Color.BLACK, 1);
    final Fill fill = SF.fill(Color.RED);
    final ExternalMark external = SF.externalMark(SF.onlineResource(IconBuilder.FONTAWESOME.toURI()), "ttf", FontAwesomeIcons.ICON_DICE.codePointAt(0));
    final Mark mark = SF.mark(external, fill, stroke);
    symbols.add(mark);
    final Graphic graphic = SF.graphic(symbols, opacity, size, rotation, anchor, disp);
    final PointSymbolizer symbolizer = SF.pointSymbolizer(name, geometry, desc, unit, graphic);
    final MutableStyle style = SF.style(symbolizer);
    return style;
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) 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) Graphic(org.opengis.style.Graphic) 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) ExternalMark(org.opengis.style.ExternalMark) MutableStyle(org.geotoolkit.style.MutableStyle) Expression(org.opengis.filter.Expression)

Example 9 with AnchorPoint

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

the class Styles method markPoint.

public static MutableStyle markPoint() {
    // 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;
    // the visual element
    final Expression size = FF.literal(12);
    final Expression opacity = LITERAL_ONE_FLOAT;
    final Expression rotation = LITERAL_ONE_FLOAT;
    final AnchorPoint anchor = DEFAULT_ANCHOR_POINT;
    final Displacement disp = DEFAULT_DISPLACEMENT;
    final List<GraphicalSymbol> symbols = new ArrayList<GraphicalSymbol>();
    final Stroke stroke = SF.stroke(Color.BLACK, 2);
    final Fill fill = SF.fill(Color.RED);
    final Mark mark = SF.mark(MARK_CIRCLE, fill, stroke);
    symbols.add(mark);
    final Graphic graphic = SF.graphic(symbols, opacity, size, rotation, anchor, disp);
    final PointSymbolizer symbolizer = SF.pointSymbolizer(name, geometry, desc, unit, graphic);
    final MutableStyle style = SF.style(symbolizer);
    return style;
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) 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) Graphic(org.opengis.style.Graphic) 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)

Example 10 with AnchorPoint

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

the class DefaultStyleVisitor method visit.

@Override
public Object visit(final Graphic graphic, Object data) {
    final AnchorPoint ac = graphic.getAnchorPoint();
    if (ac != null) {
        data = ac.accept(this, data);
    }
    final Displacement disp = graphic.getDisplacement();
    if (disp != null) {
        data = disp.accept(this, data);
    }
    final Expression opa = graphic.getOpacity();
    if (opa != null) {
        visit(opa, data);
    }
    final Expression rot = graphic.getRotation();
    if (rot != null) {
        visit(rot, data);
    }
    final Expression size = graphic.getSize();
    if (size != null) {
        visit(size, data);
    }
    final List<GraphicalSymbol> symbols = graphic.graphicalSymbols();
    if (symbols != null) {
        for (GraphicalSymbol gs : symbols) {
            if (gs instanceof Mark) {
                data = ((Mark) gs).accept(this, data);
            } else if (gs instanceof ExternalGraphic) {
                data = ((ExternalGraphic) gs).accept(this, data);
            }
        }
    }
    return data;
}
Also used : AnchorPoint(org.opengis.style.AnchorPoint) Expression(org.opengis.filter.Expression) GraphicalSymbol(org.opengis.style.GraphicalSymbol) Mark(org.opengis.style.Mark) ExternalMark(org.opengis.style.ExternalMark) ExternalGraphic(org.opengis.style.ExternalGraphic) Displacement(org.opengis.style.Displacement)

Aggregations

Expression (org.opengis.filter.Expression)18 AnchorPoint (org.opengis.style.AnchorPoint)18 Displacement (org.opengis.style.Displacement)18 GraphicalSymbol (org.opengis.style.GraphicalSymbol)14 ArrayList (java.util.ArrayList)12 Unit (javax.measure.Unit)10 Description (org.opengis.style.Description)10 Mark (org.opengis.style.Mark)9 Graphic (org.opengis.style.Graphic)8 MutableStyle (org.geotoolkit.style.MutableStyle)7 ExternalMark (org.opengis.style.ExternalMark)7 Stroke (org.opengis.style.Stroke)7 Fill (org.opengis.style.Fill)6 GraphicStroke (org.opengis.style.GraphicStroke)6 GraphicFill (org.opengis.style.GraphicFill)5 PointSymbolizer (org.opengis.style.PointSymbolizer)5 LineSymbolizer (org.opengis.style.LineSymbolizer)3 SimpleInternationalString (org.apache.sis.util.SimpleInternationalString)2 ExternalGraphic (org.opengis.style.ExternalGraphic)2 PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)2