/** * create a stroke with the color and width supplied * * @param color an Expression representing the color of the line * @param width an Expression representing the width of the line * @return the Stroke created */ public Stroke createStroke(Expression color, Expression width) { return sf.createStroke(color, width); }
/** * create a stroke with color, width and opacity supplied * * @param color an Expression representing the color of the line * @param width an Expression representing the width of the line * @param opacity an Expression representing opacity the opacity or <I>see throughness</I> of * the line, 0 - is transparent, 1 is completely drawn * @return the stroke created */ public Stroke createStroke(Expression color, Expression width, Expression opacity) { return sf.createStroke(color, width, opacity); }
LineSymbolizer ls = styleFactory.createLineSymbolizer(); ls.setStroke( styleFactory.createStroke( filterFactory.literal(color), filterFactory.literal(2)));
protected abstract void stroke(Stroke stroke); }
/** * create a stroke with the supplied width and color * * @param color the color of the line * @param width the width of the line * @return the created stroke */ public Stroke createStroke(Color color, double width) { return sf.createStroke(colorExpression(color), literalExpression(width)); }
/** * create a stroke with color, width and opacity supplied * * @param color the color of the line * @param width the width of the line * @param opacity the opacity or <I>see throughness</I> of the line, 0 - is transparent, 1 is * completely drawn * @return the stroke created */ public Stroke createStroke(Color color, double width, double opacity) { return sf.createStroke( colorExpression(color), literalExpression(width), literalExpression(opacity)); }
/** * Create a line style with given color and line width * * @param lineColor color of lines * @param width width of lines * @return a new Style instance */ public static Style createLineStyle(Color lineColor, float width) { Stroke stroke = sf.createStroke(ff.literal(lineColor), ff.literal(width)); return wrapSymbolizers(sf.createLineSymbolizer(stroke, null)); }
public Stroke build() { if (unset) { return null; } Stroke stroke = sf.createStroke( color, width, opacity, lineJoin, lineCap, dashArray, dashOffset, graphicFill.build(), this.graphicStroke.build()); if (dashArrayExpressions != null && !dashArrayExpressions.isEmpty()) { stroke.setDashArray(dashArrayExpressions); } if (parent == null) { reset(); } return stroke; }
/** * Sets the Colour for the given Line symbolizer * * @param symbolizer * @param colour */ public static void setLineColour(LineSymbolizer symbolizer, Color colour) { if (symbolizer == null || colour == null) { return; } Stroke stroke = symbolizer.getStroke(); if (stroke == null) { stroke = sf.createStroke(ff.literal(colour), Stroke.DEFAULT.getWidth()); symbolizer.setStroke(stroke); } else { stroke.setColor(ff.literal(colour)); } }
/** * Create a polygon style with the given colors and opacity. * * @param outlineColor color of polygon outlines * @param fillColor color for the fill * @param opacity proportional opacity (0 to 1) * @return a new Style instance */ public static Style createPolygonStyle(Color outlineColor, Color fillColor, float opacity) { Stroke stroke = sf.createStroke(ff.literal(outlineColor), ff.literal(1.0f)); Fill fill = Fill.NULL; if (fillColor != null) { fill = sf.createFill(ff.literal(fillColor), ff.literal(opacity)); } return wrapSymbolizers(sf.createPolygonSymbolizer(stroke, fill, null)); }
/** See http://jira.codehaus.org/browse/UDIG-1374 */ public void testStroke() { Stroke stroke = sf.createStroke(ff.literal("#FF0000"), ff.literal("3")); assertEquals("width", 3, SLD.width(stroke)); assertEquals("color", Color.RED, SLD.color(stroke)); stroke = sf.createStroke(ff.literal("#FF0000"), ff.literal("3.0")); assertEquals("width", 3, SLD.width(stroke)); }
/** * Sets the colour to use for outline (stroke) and fill in a polygon symbolizer * * @param symbolizer the polygon symbolizer * @param colour the colour for polygon outlines and fill */ public static void setPolyColour(PolygonSymbolizer symbolizer, Color colour) { if (symbolizer == null || colour == null) { return; } Expression colourExp = ff.literal(colour); Stroke stroke = symbolizer.getStroke(); if (stroke == null) { stroke = sf.createStroke(colourExp, Stroke.DEFAULT.getWidth()); symbolizer.setStroke(stroke); } else { stroke.setColor(ff.literal(colour)); } Fill fill = symbolizer.getFill(); if (fill != null) { fill.setColor(colourExp); } }
/** * Sets the Colour for the given point symbolizer * * @param symbolizer the point symbolizer * @param colour the new colour */ public static void setPointColour(PointSymbolizer symbolizer, Color colour) { if (symbolizer == null || colour == null) { return; } Graphic graphic = symbolizer.getGraphic(); if (graphic == null) { graphic = sf.createDefaultGraphic(); } for (GraphicalSymbol gs : graphic.graphicalSymbols()) { if (gs != null && gs instanceof Mark) { Mark mark = (Mark) gs; Stroke stroke = mark.getStroke(); if (stroke == null) { stroke = sf.createStroke(ff.literal(Color.BLACK), Stroke.DEFAULT.getWidth()); mark.setStroke(stroke); } Fill fill = mark.getFill(); if (fill != null) { fill.setColor(ff.literal(colour)); } } } }
Stroke stroke = sf.createStroke(ff.literal(lineColor), ff.literal(width)); LineSymbolizer lineSym = sf.createLineSymbolizer(stroke, null);
public void testStroke() { Stroke stroke = sf.getDefaultStroke(); Stroke clone = visitor.copy(stroke); assertCopy(stroke, clone); Stroke notEq = sf.createStroke(ff.literal("#FF0000"), ff.literal(10)); assertEqualsContract(clone, notEq, stroke); // a stroke is a complex object with lots of properties, // need more extensive tests here. Stroke dashArray = sf.getDefaultStroke(); dashArray.setDashArray(new float[] {1.0f, 2.0f, 3.0f}); Stroke dashArray2 = (Stroke) ((Cloneable) dashArray).clone(); assertEqualsContract(dashArray, dashArray2); }
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); } };
m1.setStroke( CommonFactoryFinder.getStyleFactory() .createStroke( CommonFactoryFinder.getFilterFactory2().literal("#005566"), CommonFactoryFinder.getFilterFactory2().literal(3)));
Mark mark = sf.mark(ff.literal("circle"), sf.fill(null, ff.literal("#995555"), null), null); Graphic g = sf.createGraphic(null, new Mark[] {mark}, null, null, null, null); Stroke s = sf.createStroke(null, ff.literal(10)); s.setGraphicFill(g); l.setStroke(s);
public void testStroke() { Stroke stroke = styleFactory.getDefaultStroke(); DuplicatingStyleVisitor duplicate = new DuplicatingStyleVisitor(styleFactory); stroke.accept(duplicate); Stroke clone = (Stroke) duplicate.getCopy(); assertClone(stroke, clone); Stroke notEq = styleFactory.createStroke( filterFactory.literal("#FF0000"), filterFactory.literal(10)); assertEqualsContract(clone, notEq, stroke); // a stroke is a complex object with lots of properties, // need more extensive tests here. Stroke dashArray = styleFactory.getDefaultStroke(); dashArray.setDashArray(new float[] {1.0f, 2.0f, 3.0f}); dashArray.accept(duplicate); Stroke dashArray2 = (Stroke) duplicate.getCopy(); assertEqualsContract(dashArray, dashArray2); }
public void testDefaultLineSymbolizerWithColor() throws Exception { LineSymbolizer symb = sf.createLineSymbolizer(); symb.setStroke(sf.createStroke(ff.literal("#0000FF"), ff.literal(1.0))); symb.setPerpendicularOffset(ff.literal(10)); Style2D s = sld.createLineStyle(feature, symb, range); assertNotNull(s); DynamicLineStyle2D s2 = (DynamicLineStyle2D) sld.createDynamicLineStyle(feature, symb, range); assertNotNull(s2); assertEquals(Color.BLUE, s2.getContour()); assertNotNull(s2.getStroke()); assertEquals(10, s2.getPerpendicularOffset(), 0d); }