} else if (res.equalsIgnoreCase("width") || res.equalsIgnoreCase("stroke-width")) { Expression width = parseCssParameter(child, false); stroke.setWidth(width); } else if (res.equalsIgnoreCase(opacityString) || res.equalsIgnoreCase("stroke-opacity")) {
private LineSymbolizer linesym(StyleFactory sFac) throws IllegalFilterException { LineSymbolizer linesym = sFac.createLineSymbolizer(); Stroke myStroke = sFac.getDefaultStroke(); myStroke.setColor(filterFactory.literal("#0000ff")); myStroke.setWidth(filterFactory.literal(Integer.valueOf(5))); LOGGER.fine("got new Stroke " + myStroke); linesym.setStroke(myStroke); return linesym; }
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); } }
private PolygonSymbolizer polysym1(StyleFactory sFac) throws IllegalFilterException { Stroke myStroke; PolygonSymbolizer polysym = sFac.createPolygonSymbolizer(); Fill myFill = sFac.getDefaultFill(); myFill.setColor(filterFactory.literal("#00ff00")); polysym.setFill(myFill); myStroke = sFac.getDefaultStroke(); myStroke.setColor(filterFactory.literal("#00ff00")); myStroke.setWidth(filterFactory.literal(Integer.valueOf(2))); polysym.setStroke(myStroke); return polysym; }
private PolygonSymbolizer polysym(StyleFactory sFac) throws IllegalFilterException { Stroke myStroke; PolygonSymbolizer polysym = sFac.createPolygonSymbolizer(); Fill myFill = sFac.getDefaultFill(); myFill.setColor(filterFactory.literal("#ff0000")); polysym.setFill(myFill); myStroke = sFac.getDefaultStroke(); myStroke.setColor(filterFactory.literal("#0000ff")); myStroke.setWidth(filterFactory.literal(Integer.valueOf(2))); polysym.setStroke(myStroke); return polysym; }
@Test public void testRescaleLocalUOM() throws Exception { Stroke original = sb.createStroke(Color.RED, 2, new float[] {5, 10}); original.setWidth(ff.literal("2m")); original.accept(visitor); Stroke clone = (Stroke) visitor.getCopy(); assertEquals("4m", clone.getWidth().evaluate(null, String.class)); }
@Test public void testRescaleLocalPixelInPixelSymbolizer() throws Exception { Stroke stroke = sb.createStroke(Color.RED, 2, new float[] {5, 10}); stroke.setWidth(ff.literal("2px")); LineSymbolizer ls = sb.createLineSymbolizer(stroke); ls.accept(visitor); LineSymbolizer clone = (LineSymbolizer) visitor.getCopy(); assertEquals("4", clone.getStroke().getWidth().evaluate(null, String.class)); }
/** * 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 testRescaleLocalPixelInMetersSymbolizer() throws Exception { Stroke stroke = sb.createStroke(Color.RED, 2, new float[] {5, 10}); stroke.setWidth(ff.literal("2px")); LineSymbolizer ls = sb.createLineSymbolizer(stroke); ls.setUnitOfMeasure(SI.METRE); ls.accept(visitor); LineSymbolizer clone = (LineSymbolizer) visitor.getCopy(); assertEquals("4px", clone.getStroke().getWidth().evaluate(null, String.class)); }
@Test public void testSymbolizerPixelOverrideInMeters() throws Exception { Stroke original = sb.createStroke(Color.RED, 2, new float[] {5, 10}); original.setWidth(ff.literal("2m")); LineSymbolizer ls = sb.createLineSymbolizer(original); ls.accept(visitor); Stroke clone = ((LineSymbolizer) visitor.getCopy()).getStroke(); // this one has not been rescaled assertEquals("2m", clone.getWidth().evaluate(null, String.class)); // the dash array did , it's supposed to be pixels assertEquals(10f, clone.getDashArray()[0], 0f); assertEquals(20f, clone.getDashArray()[1], 0f); TextSymbolizer ts = sb.createTextSymbolizer(); ts.getOptions().put(TextSymbolizer.SPACE_AROUND_KEY, "10m"); ts.accept(visitor); TextSymbolizer clonedTs = (TextSymbolizer) visitor.getCopy(); // this one has not been rescaled assertEquals("10.0m", clonedTs.getOptions().get(TextSymbolizer.SPACE_AROUND_KEY)); } }
@Test public void testFeatureBound() throws Exception { StyleBuilder sb = new StyleBuilder(); LineSymbolizer ls = sb.createLineSymbolizer(Color.BLUE); ls.getStroke().setWidth(ff.multiply(ff.literal(2), ff.property("flow"))); Style style = sb.createStyle(ls); MetaBufferEstimator estimator = new MetaBufferEstimator(riverFeatures[0]); style.accept(estimator); assertTrue(estimator.isEstimateAccurate()); assertEquals(9, estimator.getBuffer()); } }
@Test public void testSymbolizerMeterOverrideInPixels() throws Exception { Stroke original = sb.createStroke(Color.RED, 2, new float[] {5, 10}); original.setWidth(ff.literal("2px")); LineSymbolizer ls = sb.createLineSymbolizer(original); ls.setUnitOfMeasure(SI.METRE); ls.accept(visitor); Stroke clone = ((LineSymbolizer) visitor.getCopy()).getStroke(); // this one has been rescaled assertEquals(4d, clone.getWidth().evaluate(null, Double.class), 0d); // the dash array did not, it's supposed to be meters assertEquals(5f, clone.getDashArray()[0], 0f); assertEquals(10f, clone.getDashArray()[1], 0f); TextSymbolizer ts = sb.createTextSymbolizer(); ts.getOptions().put(TextSymbolizer.SPACE_AROUND_KEY, "10px"); ts.setUnitOfMeasure(SI.METRE); ts.accept(visitor); TextSymbolizer clonedTs = (TextSymbolizer) visitor.getCopy(); // this one has been rescaled assertEquals("20.0", clonedTs.getOptions().get(TextSymbolizer.SPACE_AROUND_KEY)); }
@Test public void testMarkStroke() throws Exception { StyleBuilder sb = new StyleBuilder(); Mark mark = sb.createMark("square"); mark.getStroke().setWidth(sb.getFilterFactory().literal(10)); Graphic graphic = sb.createGraphic(null, mark, null); graphic.setSize(NilExpression.NIL); PointSymbolizer ps = sb.createPointSymbolizer(graphic); Style style = sb.createStyle(ps); MetaBufferEstimator estimator = new MetaBufferEstimator(); style.accept(estimator); assertTrue(estimator.isEstimateAccurate()); assertEquals(26, estimator.getBuffer()); }
stroke.setWidth(width);
stroke().setWidth(Util.expression(map.str("stroke-width"), factory));
myStroke.setWidth(filterFactory.literal(Integer.valueOf(3))); LOGGER.info("got new Stroke " + myStroke); linesym.setStroke(myStroke);
@Test public void testMultipleSymbolizers() { Style style = sb.createStyle(); LineSymbolizer ls = sb.createLineSymbolizer(); ls.getStroke().setWidth(sb.getFilterFactory().property("myAttribute")); FeatureTypeStyle fts = sb.createFeatureTypeStyle(sb.createPolygonSymbolizer()); style.featureTypeStyles().add(fts); fts.rules().get(0).symbolizers().add(ls); fts.rules().get(0).symbolizers().add(sb.createLineSymbolizer()); checkSingleSymbolizer(style, ls); }
@Test public void testMixDynamicStroke() { Style style = sb.createStyle(); FeatureTypeStyle fts1 = sb.createFeatureTypeStyle("Feature", staticPolygonRule); LineSymbolizer ls = sb.createLineSymbolizer(); ls.getStroke().setWidth(sb.getFilterFactory().property("myAttribute")); FeatureTypeStyle fts2 = sb.createFeatureTypeStyle(ls); style.featureTypeStyles().add(fts1); style.featureTypeStyles().add(fts2); checkSingleSymbolizer(style, ls); }
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()); } }