use of org.opengis.style.LineSymbolizer in project geotoolkit by Geomatys.
the class MapfileToSLDProcess method createLineSymbolizer.
private List<Symbolizer> createLineSymbolizer(final Feature style) {
Expression expColor = (Expression) style.getPropertyValue(STYLE_COLOR.toString());
Expression expWidth = (Expression) style.getPropertyValue(STYLE_WIDTH.toString());
Expression expOpacity = (Expression) style.getPropertyValue(STYLE_OPACITY.toString());
float[] dashes = (float[]) style.getPropertyValue(STYLE_PATTERN.toString());
Literal explinecap = (Literal) style.getPropertyValue(STYLE_LINECAP.toString());
Literal explinejoin = (Literal) style.getPropertyValue(STYLE_LINEJOIN.toString());
Expression expOutlineColor = (Expression) style.getPropertyValue(STYLE_OUTLINECOLOR.toString());
Expression expOutlineWidth = (Expression) style.getPropertyValue(STYLE_OUTLINEWIDTH.toString());
if (expOpacity == null) {
expOpacity = DEFAULT_STROKE_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 (expWidth == null) {
expWidth = DEFAULT_STROKE_WIDTH;
}
if (explinecap == null) {
explinecap = STROKE_CAP_ROUND;
}
if (explinejoin == null) {
explinejoin = DEFAULT_STROKE_JOIN;
} else {
// mapfile write 'miter' not 'mitre' like in sld/se
if ("miter".equalsIgnoreCase(String.valueOf(explinejoin.getValue()))) {
explinejoin = STROKE_JOIN_MITRE;
}
}
final List<Symbolizer> symbolizers = new ArrayList<>();
// this produce a line border effect
if (expOutlineColor != null && expOutlineWidth != null) {
final Expression width = FF.add(expWidth, FF.multiply(expOutlineWidth, FF.literal(2)));
final Stroke stroke = SF.stroke(expOutlineColor, expOpacity, width, explinejoin, explinecap, null, LITERAL_ZERO_FLOAT);
final LineSymbolizer outline = SF.lineSymbolizer("", (String) null, DEFAULT_DESCRIPTION, Units.POINT, stroke, LITERAL_ZERO_FLOAT);
symbolizers.add(outline);
}
if (expColor != null) {
// 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 Expression offset = LITERAL_ZERO_FLOAT;
// the visual element
final Expression dashOffset = LITERAL_ZERO_FLOAT;
final Stroke stroke = SF.stroke(expColor, expOpacity, expWidth, explinejoin, explinecap, dashes, dashOffset);
final LineSymbolizer symbolizer = SF.lineSymbolizer(name, geometry, desc, unit, stroke, offset);
symbolizers.add(symbolizer);
}
return symbolizers;
}
use of org.opengis.style.LineSymbolizer in project geotoolkit by Geomatys.
the class Styles method graphicStrokeLine.
public static MutableStyle graphicStrokeLine() 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 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 Expression initialGap = LITERAL_ZERO_FLOAT;
final Expression strokeGap = FF.literal(10);
final GraphicStroke graphicStroke = SF.graphicStroke(graphic, strokeGap, initialGap);
// 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(graphicStroke, 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;
}
use of org.opengis.style.LineSymbolizer in project geotoolkit by Geomatys.
the class Styles method defaultLine.
// ////////////////////////////////////////////////////////////////////
// LINE SYMBOLIZER //////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////
public static MutableStyle defaultLine() {
final LineSymbolizer symbol = DEFAULT_LINE_SYMBOLIZER;
final MutableStyle style = SF.style(symbol);
return style;
}
Aggregations