private Style2D getGraphicStroke( Symbolizer symbolizer, org.geotools.styling.Stroke stroke, Object feature, Range scaleRange) { if ((stroke == null) || (stroke.getGraphicStroke() == null)) { return null; } // sets graphic stroke if available and vector rendering is enabled return createPointStyle(feature, symbolizer, stroke.getGraphicStroke(), scaleRange, false); }
@Override public void visit(Stroke stroke) { if (stroke.getGraphicFill() != null) { stroke.getGraphicFill().accept(this); } if (stroke.getGraphicStroke() != null) { stroke.getGraphicStroke().accept(this); } }
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Stroke) */ public void visit(Stroke stroke) { try { Expression width = stroke.getWidth(); if (!isNull(width)) { evaluateWidth(width); } if (stroke.getGraphicStroke() != null) { stroke.getGraphicStroke().accept(this); } } catch (ClassCastException e) { estimateAccurate = false; LOGGER.info("Could not parse stroke width, " + "it's a literal but not a Number..."); } }
public void visit(Stroke stroke) { Stroke copy = sf.getDefaultStroke(); copy.setColor(copy(stroke.getColor())); copy.setDashArray(copyExpressions(stroke.dashArray())); copy.setDashOffset(copy(stroke.getDashOffset())); copy.setGraphicFill(copy(stroke.getGraphicFill())); copy.setGraphicStroke(copy(stroke.getGraphicStroke())); copy.setLineCap(copy(stroke.getLineCap())); copy.setLineJoin(copy(stroke.getLineJoin())); copy.setOpacity(copy(stroke.getOpacity())); copy.setWidth(copy(stroke.getWidth())); if (STRICT && !copy.equals(stroke)) { throw new IllegalStateException("Was unable to duplicate provided Stroke:" + stroke); } pages.push(copy); }
/** * Used to rescaleDashArray the provided stroke. * * @param stroke the unscaled stroke, which will be modified in-place. * @param mapScale the mapScale in pixels per meter. * @param uom the unit of measure that will be used to scale. */ protected void rescaleStroke(Stroke stroke, Unit<Length> uom) { if (stroke != null) { stroke.setWidth(rescale(stroke.getWidth(), uom)); stroke.setDashArray(rescaleDashArray(stroke.dashArray(), uom)); stroke.setDashOffset(rescale(stroke.getDashOffset(), uom)); rescale(stroke.getGraphicFill(), uom); rescale(stroke.getGraphicStroke(), uom); } }
private Style2D getGraphicStroke(org.geotools.styling.Stroke stroke, Object feature, Range scaleRange) { if ((stroke == null) || (stroke.getGraphicStroke() == null)) { return null; } // sets graphic stroke if available and vector rendering is enabled return createPointStyle(feature, stroke.getGraphicStroke(), scaleRange, false); }
@Override protected void encode(Stroke stroke) { putColor("stroke-color", stroke.getColor()); put("stroke-width", stroke.getWidth()); put("stroke-opacity", nullIf(stroke.getOpacity(), 1d)); put("stroke-linejoin", nullIf(stroke.getLineJoin(), "miter")); putName("stroke-linecap", nullIf(stroke.getLineCap(), "butt")); put("stroke-dasharray", toStringOrNull(stroke.getDashArray())); put("stroke-dashoffset", nullIf(stroke.getDashOffset(), 0)); if (stroke.getGraphicFill() != null) { push("stroke-graphic-fill").inline(new GraphicEncoder(stroke.getGraphicFill())); } if (stroke.getGraphicStroke() != null) { push("stroke-graphic").inline(new GraphicEncoder(stroke.getGraphicStroke())); } }
public void visit(Stroke stroke) { start("Stroke"); if (stroke.getGraphicFill() != null) { start("GraphicFill"); stroke.getGraphicFill().accept(this); end("GraphicFill"); } if (stroke.getGraphicStroke() != null) { start("GraphicStroke"); stroke.getGraphicStroke().accept(this); end("GraphicStroke"); } encodeCssParam("stroke", stroke.getColor(), Color.BLACK); encodeCssParam("stroke-linecap", stroke.getLineCap(), "butt"); encodeCssParam("stroke-linejoin", stroke.getLineJoin(), "miter"); encodeCssParam("stroke-opacity", stroke.getOpacity(), 1.0); encodeCssParam("stroke-width", stroke.getWidth(), 1.0); encodeCssParam("stroke-dashoffset", stroke.getDashOffset(), 0.0); encodeStrokeDasharray(stroke.dashArray()); end("Stroke"); }
if (stroke.getGraphicStroke() != null) { stroke.getGraphicStroke().accept(this);
private void addStrokeSymbolizerIfNecessary(Stroke stroke) { if (stroke != null) { List<Expression> dashArray = stroke.dashArray(); Graphic graphicStroke = stroke.getGraphicStroke(); if (graphicStroke != null || dashArray != null && dashArray.size() > 0) { addSolidLineSymbolier = true; } } } }
Stroke update(Stroke stroke) { Expression color = ff.literal(colour); Expression width = copy(stroke.getWidth()); Expression opacity = copy(stroke.getOpacity()); Expression lineJoin = copy(stroke.getLineJoin()); Expression lineCap = copy(stroke.getLineCap()); float[] dashArray = copy(stroke.getDashArray()); Expression dashOffset = copy(stroke.getDashOffset()); Graphic graphicStroke = copy(stroke.getGraphicStroke()); Graphic graphicFill = copy(stroke.getGraphicFill()); return sf.createStroke( color, width, opacity, lineJoin, lineCap, dashArray, dashOffset, graphicFill, graphicStroke); } };
/** * Increase stroke width. * * <p>Based on feedback we may need to change the dash array as well. * * <p> */ public void visit(org.geotools.styling.Stroke stroke) { Stroke copy = sf.getDefaultStroke(); copy.setColor(copy(stroke.getColor())); copy.setDashArray(rescaleDashArray(stroke.dashArray())); copy.setDashOffset(rescale(stroke.getDashOffset())); copy.setGraphicFill(copy(stroke.getGraphicFill())); copy.setGraphicStroke(copy(stroke.getGraphicStroke())); copy.setLineCap(copy(stroke.getLineCap())); copy.setLineJoin(copy(stroke.getLineJoin())); copy.setOpacity(copy(stroke.getOpacity())); copy.setWidth(rescale(stroke.getWidth())); pages.push(copy); }
@SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testStrokeGraphic() throws Exception { String yaml = "line:\n" + " stroke-graphic:\n" + " symbols:\n" + " - mark:\n" + " shape: circle\n" + " fill-color: '#995555'\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("stroke", hasProperty("graphicStroke"))); Graphic g = p.getStroke().getGraphicStroke(); List<GraphicalSymbol> symbols = g.graphicalSymbols(); ((Mark) symbols.get(0)).getFill().getColor(); assertThat( symbols, (Matcher) hasItems( allOf( instanceOf(Mark.class), hasProperty("wellKnownName", literal("circle")), hasProperty( "fill", hasProperty( "color", literal(isColor("995555"))))))); }
ps.accept(visitor); PolygonSymbolizer rps = (PolygonSymbolizer) visitor.getCopy(); Mark rm = (Mark) rps.getStroke().getGraphicStroke().graphicalSymbols().get(0); assertEquals(10.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d); rm = (Mark) rps.getFill().getGraphicFill().graphicalSymbols().get(0); rm = (Mark) lps.getStroke().getGraphicStroke().graphicalSymbols().get(0); assertEquals(10.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);
Mark rm = (Mark) rps.getStroke().getGraphicStroke().graphicalSymbols().get(0); assertEquals(2.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d); rm = (Mark) rps.getFill().getGraphicFill().graphicalSymbols().get(0); assertEquals(4.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d); AnchorPoint actualAnchorPoint = rps.getStroke().getGraphicStroke().getAnchorPoint(); assertNotNull(actualAnchorPoint); assertEquals( rm = (Mark) lps.getStroke().getGraphicStroke().graphicalSymbols().get(0); assertEquals(2.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);
Graphic g = line.getStroke().getGraphicStroke();
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Stroke) */ public void visit(Stroke stroke) { handleColor(stroke.getColor()); if (stroke.getGraphicFill() != null) { stroke.getGraphicFill().accept(this); } if (stroke.getGraphicStroke() != null) { stroke.getGraphicStroke().accept(this); } handleOpacity(stroke.getOpacity()); }
assertEquals(7.5, Filters.asDouble(stroke.getDashOffset()), 0.1); Graphic g = stroke.getGraphicStroke(); assertEquals(5, Filters.asInt(g.getSize()));
assertEquals(6f, SLD.lineDash(line)[1], 0.1); Mark mark = SLD.mark(line.getStroke().getGraphicStroke()); assertEquals("circle", SLD.wellKnownName(mark)); assertEquals(color("666666"), SLD.color(mark.getFill()));
Stroke update(Stroke stroke) { Expression color = ff.literal(colour); Expression width = copy(stroke.getWidth()); Expression opacity = copy(stroke.getOpacity()); Expression lineJoin = copy(stroke.getLineJoin()); Expression lineCap = copy(stroke.getLineCap()); float[] dashArray = copy(stroke.getDashArray()); Expression dashOffset = copy(stroke.getDashOffset()); Graphic graphicStroke = copy(stroke.getGraphicStroke()); Graphic graphicFill = copy(stroke.getGraphicFill()); return sf.createStroke(color, width, opacity, lineJoin, lineCap, dashArray, dashOffset, graphicFill, graphicStroke); } };