/** * create a dashed line of color and width * * @param color the color of the line * @param width the width of the line * @param dashArray an array of floats describing the length of line and spaces * @return the stroke created */ public Stroke createStroke(Color color, double width, float[] dashArray) { Stroke stroke = createStroke(color, width); stroke.setDashArray(dashArray); return stroke; }
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; }
} else if (res.equalsIgnoreCase("dasharray") || res.equalsIgnoreCase("stroke-dasharray")) { stroke.setDashArray(parseDashArray(child)); } else if (res.equalsIgnoreCase("dashoffset") || res.equalsIgnoreCase("stroke-dashoffset")) {
public Stroke getDefaultStroke() { try { Stroke stroke = createStroke( filterFactory.literal("#000000"), filterFactory.literal(Integer.valueOf(1))); stroke.setDashOffset(filterFactory.literal(Integer.valueOf(0))); stroke.setDashArray(Stroke.DEFAULT.getDashArray()); stroke.setLineCap(filterFactory.literal("butt")); stroke.setLineJoin(filterFactory.literal("miter")); stroke.setOpacity(filterFactory.literal(Integer.valueOf(1))); return stroke; } catch (org.geotools.filter.IllegalFilterException ife) { // we should never be in here throw new RuntimeException("Error creating stroke", ife); } }
@Test public void testDynamicStroke() throws Exception { Stroke original = sb.createStroke(Color.RED, 2); original.setDashArray(Arrays.asList((Expression) ff.literal("5 10"))); original.accept(visitor); Stroke clone = (Stroke) visitor.getCopy(); assertEquals(4.0d, Double.valueOf((String) clone.getWidth().evaluate(null)), 0.001); assertNotNull(original.dashArray()); assertEquals(1, original.dashArray().size()); assertEquals("10.0 20.0", ((Expression) clone.dashArray().get(0)).evaluate(null)); }
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); } }
/** * create a dashed line of color and width * * @param color the color of the line * @param width the width of the line * @param dashArray an array of floats describing the length of line and spaces * * @return the stroke created */ public Stroke createStroke(Color color, double width, float[] dashArray) { Stroke stroke = createStroke(color, width); stroke.setDashArray(dashArray); return stroke; }
/** * create a dashed line of color and width * * @param color the color of the line * @param width the width of the line * @param dashArray an array of floats describing the length of line and spaces * * @return the stroke created */ public Stroke createStroke(Color color, double width, float[] dashArray) { Stroke stroke = createStroke(color, width); stroke.setDashArray(dashArray); return stroke; }
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); }
/** * 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); }
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); }
stroke.setDashArray(dashArray); stroke.setDashOffset(dashOffset); stroke.setGraphicFill(graphicFill);
stroke().setDashArray(Util.floatArray(map.str("stroke-dasharray")));
public Stroke getDefaultStroke() { try { Stroke stroke = createStroke(filterFactory.literal("#000000"), filterFactory.literal(new Integer(1))); stroke.setDashOffset(filterFactory.literal( new Integer(0))); stroke.setDashArray(Stroke.DEFAULT.getDashArray()); stroke.setLineCap(filterFactory.literal("butt")); stroke.setLineJoin(filterFactory.literal("miter")); stroke.setOpacity(filterFactory.literal(new Integer(1))); return stroke; } catch (org.geotools.filter.IllegalFilterException ife) { //we should never be in here throw new RuntimeException("Error creating stroke", ife); } }
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); }
public void apply(){ if(stroke != null){ stroke.setLineCap(GuiStrokeLineCap.getLineCap()); stroke.setLineJoin(GuiStrokeLineJoin.getLineJoin()); stroke.setDashArray(GuiStrokeDashes.getDashes()); stroke.setDashOffset(GuiStrokeDashes.getOffset()); stroke.setOpacity(GuiStrokeAlpha.getExpression()); stroke.setWidth(GuiStrokeWidth.getExpression()); stroke.setColor(GuiStrokeColor.getExpression()); } }
/** * 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); } }
/** * 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); }
stroke().setDashArray(Util.floatArray(map.str("stroke-dasharray")));