/** * Retrieve the color of a stroke object * * @param stroke a Stroke object * @return color or null if stroke was null */ public static Color color(Stroke stroke) { if (stroke == null) { return null; } return color(stroke.getColor()); }
/** * Retrieves the outline (stroke) color from a PolygonSymbolizer. * * <p>If you are using something fun like rules you will need to do your own thing. * * @param symbolizer Polygon symbolizer information. * @return Color of the polygon's stroke, or null if unavailable. */ public static Color polyColor(PolygonSymbolizer symbolizer) { if (symbolizer == null) { return null; } Stroke stroke = symbolizer.getStroke(); if (stroke == null) { return null; } Color colour = color(stroke.getColor()); if (colour != null) { return colour; } return null; }
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; }
/** 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); }
/** * Retrieve the color of a stroke object * @param stroke a Stroke object * @return color or null if stroke was null */ public static Color color(Stroke stroke) { if (stroke == null) { return null; } return color(stroke.getColor()); }
public static Color strokeColor(Stroke stroke) { if (stroke == null) { return null; } return color(stroke.getColor()); }
/** * 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); }
@Test public void testColorQuotedHash() throws Exception { String yaml = "point: \n" + " symbols: \n" + " - mark: \n" + " fill-color: '#001122'\n" + " stroke-color: '#334455'\n"; StyledLayerDescriptor sld = Ysld.parse(yaml); PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld)); assertThat(SLD.fill(p).getColor(), literal(isColor("001122"))); assertThat(SLD.stroke(p).getColor(), literal(isColor("334455"))); }
@Test public void testColorQuotedBare() throws Exception { String yaml = "point: \n" + " symbols: \n" + " - mark: \n" + " fill-color: '001122'\n" + " stroke-color: '334455'\n"; StyledLayerDescriptor sld = Ysld.parse(yaml); PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld)); assertThat(SLD.fill(p).getColor(), literal(isColor("001122"))); assertThat(SLD.stroke(p).getColor(), literal(isColor("334455"))); }
@Test public void testColorHex() throws Exception { String yaml = "point: \n" + " symbols: \n" + " - mark: \n" + " fill-color: 0x001122\n" + " stroke-color: 0x334455\n"; StyledLayerDescriptor sld = Ysld.parse(yaml); PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld)); assertThat(SLD.fill(p).getColor(), literal(isColor("001122"))); assertThat(SLD.stroke(p).getColor(), literal(isColor("334455"))); }
@Test public void testColorQuotedHex() throws Exception { String yaml = "point: \n" + " symbols: \n" + " - mark: \n" + " fill-color: '0x001122'\n" + " stroke-color: '0x334455'\n"; StyledLayerDescriptor sld = Ysld.parse(yaml); PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld)); assertThat(SLD.fill(p).getColor(), literal(isColor("001122"))); assertThat(SLD.stroke(p).getColor(), literal(isColor("334455"))); }
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"); }
@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())); } }
color = Stroke.DEFAULT.getColor();
computeExpectedRescaleSize(widthValue, scaleMetersToPixel, uom); assertEquals(stroke.getColor(), rescaledStroke.getColor()); assertEquals(expectedRescaledWidthValue, rescaledWidthValue, 0d); assertNotSame(SI.METRE, rescaledLineSymb.getUnitOfMeasure());
/** @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()); }
@Test public void testLine() { Style style = sb.createStyle(sb.createLineSymbolizer(sb.createStroke(Color.BLACK, 3))); style.accept(visitor); Style copy = (Style) visitor.getCopy(); LineSymbolizer ls = (LineSymbolizer) copy.featureTypeStyles().get(0).rules().get(0).symbolizers().get(0); Stroke stroke = ls.getStroke(); assertEquals(colorFunction, stroke.getColor()); assertEquals(Integer.valueOf(3), stroke.getWidth().evaluate(null, Integer.class)); assertNull(stroke.dashArray()); }