use of org.opengis.style.PolygonSymbolizer in project geotoolkit by Geomatys.
the class MapfileToSLDProcess method createPolygonSymbolizer.
private List<Symbolizer> createPolygonSymbolizer(final Feature style) {
Expression expColor = (Expression) style.getPropertyValue(STYLE_COLOR.toString());
Expression expOpacity = (Expression) style.getPropertyValue(STYLE_OPACITY.toString());
if (expOpacity == null) {
expOpacity = DEFAULT_FILL_OPACITY;
} else {
// mapfile opacity is expressed in %, SE is in 0-1
if (expOpacity instanceof Literal) {
double d = ((Number) expOpacity.apply(null)).doubleValue();
d /= 100d;
expOpacity = FF.literal(d);
} else {
expOpacity = FF.divide(expOpacity, FF.literal(100));
}
}
if (expColor == null) {
expColor = DEFAULT_FILL_COLOR;
}
Fill fill = null;
Stroke stroke = null;
fill = SF.fill(expColor, expOpacity);
final List<Symbolizer> symbolizers = new ArrayList<Symbolizer>();
// 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;
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(4);
// final Expression opacity = LITERAL_ONE_FLOAT;
// final Stroke stroke = SF.stroke(color,width,opacity);
final PolygonSymbolizer symbolizer = SF.polygonSymbolizer(name, geometry, desc, unit, stroke, fill, disp, offset);
symbolizers.add(symbolizer);
return symbolizers;
}
use of org.opengis.style.PolygonSymbolizer 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;
}
use of org.opengis.style.PolygonSymbolizer in project geotoolkit by Geomatys.
the class Styles method shadowPolygon.
public static MutableStyle shadowPolygon() {
// first symbol classic
final PolygonSymbolizer symbol1 = SF.polygonSymbolizer(null, SF.fill(Color.ORANGE), null);
// second symbol for the shadow
final PolygonSymbolizer symbol2 = SF.polygonSymbolizer("mySymbol", (String) null, DEFAULT_DESCRIPTION, Units.POINT, null, SF.fill(Color.DARK_GRAY), SF.displacement(3, -4), LITERAL_ZERO_FLOAT);
final MutableStyle style = SF.style(symbol2, symbol1);
return style;
}
use of org.opengis.style.PolygonSymbolizer in project geotoolkit by Geomatys.
the class Styles method colorPolygon.
public static MutableStyle colorPolygon() {
// 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(4);
final Expression opacity = LITERAL_ONE_FLOAT;
final Stroke stroke = SF.stroke(color, width, opacity);
// fill element
final Fill fill = SF.fill(Color.ORANGE);
final PolygonSymbolizer symbolizer = SF.polygonSymbolizer(name, geometry, desc, unit, stroke, fill, disp, offset);
final MutableStyle style = SF.style(symbolizer);
return style;
}
use of org.opengis.style.PolygonSymbolizer in project geotoolkit by Geomatys.
the class Styles method offsetPolygon.
public static MutableStyle offsetPolygon() {
// we produce a gradient border effect by combining several
// symbolizer progressivly smaller
final PolygonSymbolizer symbol1 = SF.polygonSymbolizer("mySymbol", (String) null, DEFAULT_DESCRIPTION, Units.POINT, null, SF.fill(new Color(255, 0, 0)), DEFAULT_DISPLACEMENT, FF.literal(0));
final PolygonSymbolizer symbol2 = SF.polygonSymbolizer("mySymbol", (String) null, DEFAULT_DESCRIPTION, Units.POINT, null, SF.fill(new Color(255, 70, 70)), DEFAULT_DISPLACEMENT, FF.literal(-10));
final PolygonSymbolizer symbol3 = SF.polygonSymbolizer("mySymbol", (String) null, DEFAULT_DESCRIPTION, Units.POINT, null, SF.fill(new Color(255, 140, 140)), DEFAULT_DISPLACEMENT, FF.literal(-20));
final PolygonSymbolizer symbol4 = SF.polygonSymbolizer("mySymbol", (String) null, DEFAULT_DESCRIPTION, Units.POINT, null, SF.fill(new Color(255, 210, 210)), DEFAULT_DISPLACEMENT, FF.literal(-30));
final MutableStyle style = SF.style(symbol1, symbol2, symbol3, symbol4);
return style;
}
Aggregations