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;
}
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);
}
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);
}
}
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;
}
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;
}
Aggregations