Search in sources :

Example 16 with Graphic

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

the class ListingPropertyVisitor method visit.

@Override
public Object visit(final PointSymbolizer pointSymbolizer, Object data) {
    visitGeomName(pointSymbolizer, data);
    final Graphic gra = pointSymbolizer.getGraphic();
    if (gra != null) {
        data = gra.accept(this, data);
    }
    return data;
}
Also used : Graphic(org.opengis.style.Graphic) ExternalGraphic(org.opengis.style.ExternalGraphic)

Example 17 with Graphic

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

the class PrepareStyleVisitor method visit.

@Override
public Object visit(PointSymbolizer ps, Object o) {
    final Graphic orig = ps.getGraphic();
    if (orig == null) {
        return ps;
    }
    final Graphic opt = (Graphic) orig.accept(this, o);
    if (opt == orig) {
        return ps;
    }
    // recreate symbolizer
    return SF.pointSymbolizer(ps.getName(), visitGeometryExpression(ps, o), ps.getDescription(), ps.getUnitOfMeasure(), opt);
}
Also used : Graphic(org.opengis.style.Graphic) ExternalGraphic(org.opengis.style.ExternalGraphic)

Example 18 with Graphic

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

the class CategoryStyleBuilder method derivateSymbolizer.

/**
 * Derivate a symbolizer with a new color.
 */
public Symbolizer derivateSymbolizer(final Symbolizer symbol, final Color color) {
    if (symbol instanceof PolygonSymbolizer) {
        PolygonSymbolizer ps = (PolygonSymbolizer) symbol;
        Fill fill = sf.fill(sf.literal(color), ps.getFill().getOpacity());
        return sf.polygonSymbolizer(ps.getName(), ps.getGeometryPropertyName(), ps.getDescription(), ps.getUnitOfMeasure(), ps.getStroke(), fill, ps.getDisplacement(), ps.getPerpendicularOffset());
    } else if (symbol instanceof LineSymbolizer) {
        LineSymbolizer ls = (LineSymbolizer) symbol;
        Stroke oldStroke = ls.getStroke();
        Stroke stroke = sf.stroke(sf.literal(color), oldStroke.getOpacity(), oldStroke.getWidth(), oldStroke.getLineJoin(), oldStroke.getLineCap(), oldStroke.getDashArray(), oldStroke.getDashOffset());
        return sf.lineSymbolizer(ls.getName(), ls.getGeometryPropertyName(), ls.getDescription(), ls.getUnitOfMeasure(), stroke, ls.getPerpendicularOffset());
    } else if (symbol instanceof PointSymbolizer) {
        PointSymbolizer ps = (PointSymbolizer) symbol;
        Graphic oldGraphic = ps.getGraphic();
        Mark oldMark = (Mark) oldGraphic.graphicalSymbols().get(0);
        Fill fill = sf.fill(sf.literal(color), oldMark.getFill().getOpacity());
        List<GraphicalSymbol> symbols = new ArrayList<GraphicalSymbol>();
        symbols.add(sf.mark(oldMark.getWellKnownName(), fill, oldMark.getStroke()));
        Graphic graphic = sf.graphic(symbols, oldGraphic.getOpacity(), oldGraphic.getSize(), oldGraphic.getRotation(), oldGraphic.getAnchorPoint(), oldGraphic.getDisplacement());
        return sf.pointSymbolizer(graphic, ps.getGeometryPropertyName());
    } else {
        throw new IllegalArgumentException("unexpected symbolizer type : " + symbol);
    }
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) Fill(org.opengis.style.Fill) Stroke(org.opengis.style.Stroke) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) Graphic(org.opengis.style.Graphic) LineSymbolizer(org.opengis.style.LineSymbolizer) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) Mark(org.opengis.style.Mark)

Example 19 with Graphic

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

the class MeridianTest method createFeatureLayer.

private static MapLayers createFeatureLayer(MultiPoint geometry) {
    final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
    ftb.setName("test");
    ftb.addAttribute(MultiPoint.class).setName("geom").setCRS(CommonCRS.WGS84.normalizedGeographic()).addRole(AttributeRole.DEFAULT_GEOMETRY);
    final FeatureType type = ftb.build();
    final Feature feature = type.newInstance();
    JTS.setCRS(geometry, CommonCRS.WGS84.normalizedGeographic());
    feature.setPropertyValue("geom", geometry);
    final FeatureSet col = new InMemoryFeatureSet(type, Arrays.asList(feature));
    final List<GraphicalSymbol> symbols = new ArrayList<>();
    symbols.add(SF.mark(StyleConstants.MARK_SQUARE, SF.fill(Color.RED), SF.stroke(Color.BLACK, 0)));
    final Graphic graphic = SF.graphic(symbols, StyleConstants.LITERAL_ONE_FLOAT, FF.literal(2), StyleConstants.LITERAL_ZERO_FLOAT, null, null);
    final PointSymbolizer ps = SF.pointSymbolizer(graphic, null);
    final MutableStyle style = SF.style(ps);
    final MapLayer layer = MapBuilder.createLayer(col);
    layer.setStyle(style);
    final MapLayers context = MapBuilder.createContext();
    context.getComponents().add(layer);
    return context;
}
Also used : MultiPoint(org.locationtech.jts.geom.MultiPoint) FeatureTypeBuilder(org.apache.sis.feature.builder.FeatureTypeBuilder) FeatureType(org.opengis.feature.FeatureType) PointSymbolizer(org.opengis.style.PointSymbolizer) InMemoryFeatureSet(org.geotoolkit.storage.memory.InMemoryFeatureSet) Graphic(org.opengis.style.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) MapLayer(org.apache.sis.portrayal.MapLayer) ArrayList(java.util.ArrayList) Feature(org.opengis.feature.Feature) MutableStyle(org.geotoolkit.style.MutableStyle) InMemoryFeatureSet(org.geotoolkit.storage.memory.InMemoryFeatureSet) FeatureSet(org.apache.sis.storage.FeatureSet) MapLayers(org.apache.sis.portrayal.MapLayers)

Example 20 with Graphic

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

the class SE100toGTTransformer method visit.

/**
 *  Transform a SLD v1.0 graphic stroke in GT graphic stroke.
 */
private GraphicStroke visit(final org.geotoolkit.sld.xml.v100.GraphicStroke graphicStroke) {
    if (graphicStroke == null || graphicStroke.getGraphic() == null) {
        return null;
    }
    final Graphic graphic = visit(graphicStroke.getGraphic());
    if (graphic != null) {
        final Expression gap = filterFactory.literal(0);
        final Expression initialGap = filterFactory.literal(0);
        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)

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