Search in sources :

Example 1 with AnchorPoint

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

the class ListingPropertyVisitor method visit.

@Override
public Object visit(final PointPlacement pointPlacement, Object data) {
    final AnchorPoint ap = pointPlacement.getAnchorPoint();
    if (ap != null) {
        data = ap.accept(this, data);
    }
    final Displacement disp = pointPlacement.getDisplacement();
    if (disp != null) {
        data = disp.accept(this, data);
    }
    final Expression rot = pointPlacement.getRotation();
    if (rot != null) {
        visit(rot, (Collection<String>) data);
    }
    return data;
}
Also used : AnchorPoint(org.opengis.style.AnchorPoint) Expression(org.opengis.filter.Expression) Displacement(org.opengis.style.Displacement)

Example 2 with AnchorPoint

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

the class Styles method graphicFillLine.

public static MutableStyle graphicFillLine() 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 Stroke fillStroke = SF.stroke(Color.BLACK, 2);
    final Fill fill = SF.fill(Color.RED);
    final Mark mark = SF.mark(MARK_CIRCLE, fill, fillStroke);
    symbols.add(mark);
    final GraphicFill graphicfill = SF.graphicFill(symbols, opacity, size, rotation, anchor, disp);
    // 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(graphicfill, 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) Fill(org.opengis.style.Fill) GraphicFill(org.opengis.style.GraphicFill) Description(org.opengis.style.Description) 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) LineSymbolizer(org.opengis.style.LineSymbolizer)

Example 3 with AnchorPoint

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

the class Styles method imagePoint.

public static MutableStyle imagePoint() 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(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 PointSymbolizer symbolizer = SF.pointSymbolizer(name, geometry, desc, unit, graphic);
    final MutableStyle style = SF.style(symbolizer);
    return style;
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) Description(org.opengis.style.Description) Graphic(org.opengis.style.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) 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)

Example 4 with AnchorPoint

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

the class Styles method ttfPoint2.

public static MutableStyle ttfPoint2() 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(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, 1);
    final Fill fill = SF.fill(Color.RED);
    final Expression external = FF.literal("ttf:Dialog?char=0x2A");
    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) MutableStyle(org.geotoolkit.style.MutableStyle) Expression(org.opengis.filter.Expression)

Example 5 with AnchorPoint

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

the class MapfileToSLDProcess method createPointSymbolizer.

private List<Symbolizer> createPointSymbolizer(final Feature style) {
    final String symbolName = (String) style.getPropertyValue(STYLE_SYMBOL.toString());
    Expression expSize = (Expression) style.getPropertyValue(STYLE_SIZE.toString());
    Expression expOpacity = (Expression) style.getPropertyValue(STYLE_OPACITY.toString());
    Expression expFillColor = (Expression) style.getPropertyValue(STYLE_COLOR.toString());
    Expression expStrokeColor = (Expression) style.getPropertyValue(STYLE_OUTLINECOLOR.toString());
    Expression expStrokeWidth = (Expression) style.getPropertyValue(STYLE_WIDTH.toString());
    if (expFillColor == null) {
        expFillColor = DEFAULT_FILL_COLOR;
    }
    if (expStrokeColor == null) {
        expStrokeColor = DEFAULT_STROKE_COLOR;
    }
    if (expStrokeWidth == null) {
        expStrokeWidth = FF.literal(0);
    }
    if (expOpacity == null) {
        expOpacity = DEFAULT_GRAPHIC_OPACITY;
    }
    if (expSize == null) {
        expSize = DEFAULT_GRAPHIC_SIZE;
    }
    final List<Symbolizer> symbolizers = new ArrayList<Symbolizer>();
    final Feature symbol = getSymbol(symbolName);
    if (symbol == null) {
        // no symbol found for this name
        return symbolizers;
    }
    final Stroke stroke = SF.stroke(expStrokeColor, expStrokeWidth);
    final Fill fill = SF.fill(expFillColor);
    final String symbolTypeName = (String) symbol.getPropertyValue(SYMBOL_TYPE.toString());
    final Mark mark;
    if ("ellipse".equals(symbolTypeName)) {
        mark = SF.mark(MARK_CIRCLE, fill, stroke);
    } else if ("hatch".equals(symbolTypeName)) {
        // TODO
        mark = SF.mark(MARK_SQUARE, fill, stroke);
    } else if ("pixmap".equals(symbolTypeName)) {
        // TODO
        mark = SF.mark(MARK_SQUARE, fill, stroke);
    } else if ("simple".equals(symbolTypeName)) {
        // TODO
        mark = SF.mark(MARK_SQUARE, fill, stroke);
    } else if ("truetype".equals(symbolTypeName)) {
        // TODO
        mark = SF.mark(MARK_SQUARE, fill, stroke);
    } else if ("vector".equals(symbolTypeName)) {
        // TODO
        mark = SF.mark(MARK_SQUARE, fill, stroke);
    } else {
        // can not build symbol
        return symbolizers;
    }
    // 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;
    // the visual element
    final Expression opacity = LITERAL_ONE_FLOAT;
    final Expression rotation = LITERAL_ZERO_FLOAT;
    final AnchorPoint anchor = DEFAULT_ANCHOR_POINT;
    final Displacement disp = DEFAULT_DISPLACEMENT;
    final List<GraphicalSymbol> symbols = new ArrayList<GraphicalSymbol>();
    symbols.add(mark);
    final Graphic graphic = SF.graphic(symbols, opacity, expSize, rotation, anchor, disp);
    final PointSymbolizer symbolizer = SF.pointSymbolizer(name, geometry, desc, unit, graphic);
    symbolizers.add(symbolizer);
    return symbolizers;
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) Stroke(org.opengis.style.Stroke) Fill(org.opengis.style.Fill) Description(org.opengis.style.Description) Graphic(org.opengis.style.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) Mark(org.opengis.style.Mark) Unit(javax.measure.Unit) Feature(org.opengis.feature.Feature) 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) AnchorPoint(org.opengis.style.AnchorPoint) Expression(org.opengis.filter.Expression)

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