Search in sources :

Example 11 with Graphic

use of org.opengis.style.Graphic 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)

Example 12 with Graphic

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

the class SE100toGTTransformer method visit.

// Symbolizers---------------------------------------------------------------
/**
 * Transform a SLD v1.0 point symbolizer in GT point symbolizer.
 */
public PointSymbolizer visit(final org.geotoolkit.sld.xml.v100.PointSymbolizer pst) {
    if (pst == null)
        return null;
    final Graphic graphic = (pst.getGraphic() == null) ? styleFactory.graphic() : visit(pst.getGraphic());
    final Unit uom = Units.POINT;
    final String geom = visitGeom(pst.getGeometry());
    final String name = null;
    final Description desc = StyleConstants.DEFAULT_DESCRIPTION;
    return styleFactory.pointSymbolizer(name, geom, desc, uom, graphic);
}
Also used : Description(org.opengis.style.Description) Graphic(org.opengis.style.Graphic) ExternalGraphic(org.opengis.style.ExternalGraphic) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) InternationalString(org.opengis.util.InternationalString) Unit(javax.measure.Unit)

Example 13 with Graphic

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

the class SE110toGTTransformer method visit.

/**
 *  Transform a SLD v1.1 graphic stroke in GT graphic stroke.
 */
public GraphicStroke visit(final GraphicStrokeType graphicStroke) {
    if (graphicStroke == null || graphicStroke.getGraphic() == null) {
        return null;
    }
    final Graphic graphic = visit(graphicStroke.getGraphic());
    if (graphic != null) {
        final Expression gap = visitExpression(graphicStroke.getGap());
        final Expression initialGap = visitExpression(graphicStroke.getInitialGap());
        return styleFactory.graphicStroke(graphic, gap, initialGap);
    }
    return null;
}
Also used : Expression(org.opengis.filter.Expression) Graphic(org.opengis.style.Graphic) ExternalGraphic(org.opengis.style.ExternalGraphic)

Example 14 with Graphic

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

the class DefaultStyleVisitor method visit.

@Override
public Object visit(final GraphicStroke graphicStroke, Object data) {
    data = visit((Graphic) graphicStroke, data);
    final Expression gap = graphicStroke.getGap();
    if (gap != null) {
        visit(gap, data);
    }
    final Expression igap = graphicStroke.getInitialGap();
    if (igap != null) {
        visit(igap, data);
    }
    return data;
}
Also used : Expression(org.opengis.filter.Expression) Graphic(org.opengis.style.Graphic) ExternalGraphic(org.opengis.style.ExternalGraphic)

Example 15 with Graphic

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

the class ListingPropertyVisitor method visit.

@Override
public Object visit(final GraphicStroke graphicStroke, Object data) {
    data = visit((Graphic) graphicStroke, data);
    final Expression gap = graphicStroke.getGap();
    if (gap != null) {
        visit(gap, (Collection<String>) data);
    }
    final Expression igap = graphicStroke.getInitialGap();
    if (igap != null) {
        visit(igap, (Collection<String>) data);
    }
    return data;
}
Also used : Expression(org.opengis.filter.Expression) Graphic(org.opengis.style.Graphic) ExternalGraphic(org.opengis.style.ExternalGraphic)

Aggregations

Graphic (org.opengis.style.Graphic)29 ArrayList (java.util.ArrayList)16 Expression (org.opengis.filter.Expression)16 GraphicalSymbol (org.opengis.style.GraphicalSymbol)15 ExternalGraphic (org.opengis.style.ExternalGraphic)13 PointSymbolizer (org.opengis.style.PointSymbolizer)13 Unit (javax.measure.Unit)10 Description (org.opengis.style.Description)10 Stroke (org.opengis.style.Stroke)10 Fill (org.opengis.style.Fill)9 MutableStyle (org.geotoolkit.style.MutableStyle)8 AnchorPoint (org.opengis.style.AnchorPoint)8 Displacement (org.opengis.style.Displacement)8 Mark (org.opengis.style.Mark)8 LineSymbolizer (org.opengis.style.LineSymbolizer)5 Test (org.junit.Test)4 PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)4 FeatureSet (org.apache.sis.storage.FeatureSet)3 SimpleInternationalString (org.apache.sis.util.SimpleInternationalString)3 Feature (org.opengis.feature.Feature)3