@Override public void visit(Stroke stroke) { if (stroke.getGraphicFill() != null) { stroke.getGraphicFill().accept(this); } if (stroke.getGraphicStroke() != null) { stroke.getGraphicStroke().accept(this); } }
private Paint getStrokePaint(org.geotools.styling.Stroke stroke, Object feature) { if (stroke == null) { return null; } // the foreground color Paint contourPaint = evalToColor(stroke.getColor(), feature, Color.BLACK); // if a graphic fill is to be used, prepare the paint accordingly.... org.geotools.styling.Graphic gr = stroke.getGraphicFill(); if (gr != null && gr.graphicalSymbols() != null && gr.graphicalSymbols().size() > 0) { contourPaint = getTexturePaint(gr, feature, null); } return contourPaint; }
/** * Returns the contour paint * * @return the contour paint */ public java.awt.Paint getContour() { Stroke stroke = ls.getStroke(); if (stroke == null) { return null; } // the foreground color Paint contourPaint = (Color) stroke.getColor().evaluate(feature, Color.class); if (contourPaint == null) { String text = (String) stroke.getColor().evaluate(feature, String.class); if (text != null) { contourPaint = Color.decode(text); } } // if a graphic fill is to be used, prepare the paint accordingly.... org.geotools.styling.Graphic gr = stroke.getGraphicFill(); SLDStyleFactory fac = new SLDStyleFactory(); if (gr != null) { contourPaint = fac.getTexturePaint(gr, feature, ls); } return contourPaint; }
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); } }
@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.getGraphicFill() != null) { stroke.getGraphicFill().accept(this);
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 testStrokeGraphicFill() throws Exception { String yaml = "line:\n" + " stroke-graphic-fill:\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("graphicFill"))); Graphic g = p.getStroke().getGraphicFill(); 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"))))))); }
private Paint getStrokePaint(org.geotools.styling.Stroke stroke, Object feature) { if (stroke == null) { return null; } // the foreground color Paint contourPaint = evalToColor(stroke.getColor(),feature,Color.BLACK); // if a graphic fill is to be used, prepare the paint accordingly.... org.geotools.styling.Graphic gr = stroke.getGraphicFill(); if (gr != null) { contourPaint = getTexturePaint(gr, feature); } return contourPaint; }
private Paint getStrokePaint(org.geotools.styling.Stroke stroke, Object feature) { if (stroke == null) { return null; } // the foreground color Paint contourPaint = evalToColor(stroke.getColor(), feature, Color.BLACK); // if a graphic fill is to be used, prepare the paint accordingly.... org.geotools.styling.Graphic gr = stroke.getGraphicFill(); if (gr != null) { contourPaint = getTexturePaint(gr, feature); } return contourPaint; }
/** @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()); }
/** * @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()); }
private void butFillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butFillActionPerformed JGraphicPane pane = new JGraphicPane(); pane.setLayer(layer); if(stroke != null){ pane.setEdited(stroke.getGraphicFill()); } JSimpleDialog dia = new JSimpleDialog(null,true,pane); dia.pack(); dia.setLocationRelativeTo(butFill); dia.setVisible(true); if(stroke == null){ stroke = new StyleBuilder().createStroke() ; } stroke.setGraphicFill(pane.getEdited()); }//GEN-LAST:event_butFillActionPerformed
public void visit(Stroke stroke) { Stroke copy = sf.getDefaultStroke(); copy.setColor( copy(stroke.getColor())); copy.setDashArray( copy(stroke.getDashArray())); 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 rescale 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, double mapScale, Unit<Length> uom) { if (stroke != null) { stroke.setWidth(rescale(stroke.getWidth(), mapScale, uom)); stroke.setDashArray(rescale(stroke.getDashArray(), mapScale, uom)); stroke.setDashOffset(rescale(stroke.getDashOffset(), mapScale, uom)); rescale(stroke.getGraphicFill(), mapScale, uom); rescale(stroke.getGraphicStroke(), mapScale, uom); } }
@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())); } }
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); } };