Search in sources :

Example 51 with LineSymbolizer

use of org.geotools.styling.LineSymbolizer in project polymap4-core by Polymap4.

the class LineStyleSerializer method serialize.

@Override
public void serialize(LineStyle style, FeatureTypeStyle fts) {
    accessor.set(rule -> rule.symbolizers().stream().map(s -> (LineSymbolizer) s).collect(Collectors.toList()));
    // inner line: 2nd LineSymbolizer
    style.fill.opt().ifPresent(fillStroke -> {
        new StrokeCompositeSerializer(context).accessor.put(rule -> accessor.get().apply(rule).get(1).getStroke()).serialize(fillStroke, fts);
    });
    // stroke line: 1st LineSymbolizer
    style.stroke.opt().ifPresent(outerStroke -> {
        set(fts, outerStroke.width, (value, syms) -> {
            Literal innerWidth = (Literal) syms.get(1).getStroke().getWidth();
            syms.get(0).getStroke().setWidth(ff.add(ff.multiply(value, ff.literal(2)), innerWidth));
        });
        set(fts, outerStroke.color, (value, syms) -> syms.get(0).getStroke().setColor(value));
        set(fts, outerStroke.opacity, (value, syms) -> syms.get(0).getStroke().setOpacity(value));
    // XXX linestyle
    });
}
Also used : Style(org.geotools.styling.Style) List(java.util.List) LineStyle(org.polymap.core.style.model.feature.LineStyle) Literal(org.opengis.filter.expression.Literal) Context(org.polymap.core.style.serialize.FeatureStyleSerializer.Context) Collectors(java.util.stream.Collectors) LineSymbolizer(org.geotools.styling.LineSymbolizer) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Literal(org.opengis.filter.expression.Literal)

Aggregations

LineSymbolizer (org.geotools.styling.LineSymbolizer)51 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)24 PointSymbolizer (org.geotools.styling.PointSymbolizer)23 Test (org.junit.Test)18 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)17 Style (org.geotools.styling.Style)17 Rule (org.geotools.styling.Rule)16 Symbolizer (org.geotools.styling.Symbolizer)15 Stroke (org.geotools.styling.Stroke)12 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)10 TextSymbolizer (org.geotools.styling.TextSymbolizer)10 NamedLayer (org.geotools.styling.NamedLayer)9 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)7 StyledLayer (org.geotools.styling.StyledLayer)5 JsonObject (com.google.gson.JsonObject)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 Graphic (org.geotools.styling.Graphic)4 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)4 SelectedSymbol (com.sldeditor.common.data.SelectedSymbol)3 SLDTreeLeafLine (com.sldeditor.common.tree.leaf.SLDTreeLeafLine)3