/** * This param determines where the dash pattern should start from. * * @return where the dash should start from. */ public Expression getDashOffset() { if (dashOffset == null) { return Stroke.DEFAULT.getDashOffset(); } return dashOffset; }
float dashOffset = evalToFloat(stroke.getDashOffset(), feature, 0);
float width = ((Float) stroke.getWidth().evaluate(feature, Float.class)).floatValue(); float dashOffset = ((Float) stroke.getDashOffset().evaluate(feature, Float.class)).floatValue();
/** * This param determines where the dash pattern should start from. * * @return where the dash should start from. */ public Expression getDashOffset() { if ( dashOffset == null ) { return Stroke.DEFAULT.getDashOffset(); } return dashOffset; }
/** Reset stroke to default values. */ public StrokeBuilder reset() { color = Stroke.DEFAULT.getColor(); width = Stroke.DEFAULT.getWidth(); opacity = Stroke.DEFAULT.getOpacity(); lineCap = Stroke.DEFAULT.getLineCap(); lineJoin = Stroke.DEFAULT.getLineJoin(); dashArray = Stroke.DEFAULT.getDashArray(); dashArrayExpressions = Stroke.DEFAULT.dashArray(); dashOffset = Stroke.DEFAULT.getDashOffset(); graphicFill.unset(); graphicStroke.unset(); unset = false; return this; }
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); } }
if (stroke.getDashOffset() != null) { stroke.getDashOffset().accept(this, null);
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); }
@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"); }
assertEquals(7.5, Filters.asDouble(stroke.getDashOffset()), 0.1);
public void addStrokeProperties(String prefix, Stroke stroke, Map<String, String> props) { if (stroke.getColor() != null && !isStatic(stroke.getColor())) { props.put(prefix + COLOR, stroke.getColor().evaluate(feature, String.class)); } if (stroke.getDashOffset() != null && !isStatic(stroke.getDashOffset())) { props.put(prefix + DASHOFFSET, stroke.getDashOffset().evaluate(feature, String.class)); } if (stroke.getLineCap() != null && !isStatic(stroke.getLineCap())) { props.put(prefix + LINECAP, stroke.getLineCap().evaluate(feature, String.class)); } if (stroke.getLineJoin() != null && !isStatic(stroke.getLineJoin())) { props.put(prefix + LINEJOIN, stroke.getLineJoin().evaluate(feature, String.class)); } if (stroke.getOpacity() != null && !isStatic(stroke.getOpacity())) { props.put(prefix + OPACITY, stroke.getOpacity().evaluate(feature, String.class)); } if (stroke.getWidth() != null && !isStatic(stroke.getWidth())) { props.put(prefix + WIDTH, stroke.getWidth().evaluate(feature, String.class)); } if (stroke.getGraphicStroke() != null) { addGraphicProperties(prefix + GRAPHIC, stroke.getGraphicStroke(), props); } if (stroke.getGraphicFill() != null) { addGraphicProperties(prefix + GRAPHIC, stroke.getGraphicFill(), props); } }
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); } }
public void setEdited(Stroke stroke) { this.stroke = stroke; if (stroke != null) { // implemented using two buttons // stroke.getGraphicFill(); // stroke.getGraphicStroke(); GuiStrokeLineCap.setLineCap(stroke.getLineCap()); GuiStrokeLineJoin.setLineJoin(stroke.getLineJoin()); GuiStrokeDashes.setDashes(stroke.getDashArray()); GuiStrokeDashes.setOffset(stroke.getDashOffset()); GuiStrokeWidth.setExpression(stroke.getWidth()); GuiStrokeColor.setExpression(stroke.getColor()); GuiStrokeAlpha.setExpression(stroke.getOpacity()); } }
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( rescale(stroke.getDashArray())); 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); }
@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())); } }