/** * Null safe copy of stroke. * * @param stroke * @return copy of stroke if provided */ protected Stroke copy(Stroke stroke) { if (stroke == null) return null; stroke.accept(this); return (Stroke) pages.pop(); }
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.LineSymbolizer) */ public void visit(LineSymbolizer line) { if (line.getStroke() != null) { line.getStroke().accept(this); } }
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.PolygonSymbolizer) */ public void visit(PolygonSymbolizer poly) { if (poly.getStroke() != null) { poly.getStroke().accept(this); } }
public void visit(LineSymbolizer line) { if (isAcceptable(line)) { if (line.getStroke() != null) line.getStroke().accept(this); } }
@Override public void visit(LineSymbolizer line) { if (line.getDescription() != null) { line.getDescription().accept(this); } if (line.getStroke() != null) { line.getStroke().accept(this); } }
@Override public void visit(Mark mark) { // if (mark.getExternalMark() != null) { // mark.getExternalMark().accept(this, null); // } if (mark.getFill() != null) { mark.getFill().accept(this); } if (mark.getStroke() != null) { mark.getStroke().accept(this); } }
public void visit(PolygonSymbolizer poly) { if (isAcceptable(poly)) { if (poly.getStroke() != null) poly.getStroke().accept(this); if (poly.getFill() != null) poly.getFill().accept(this); } }
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.PolygonSymbolizer) */ public void visit(PolygonSymbolizer poly) { if (symbolizerGeometriesVisitEnabled) { if (poly.getGeometry() != null) { poly.getGeometry().accept(this, null); } else { this.defaultGeometryUsed = true; // they want the default geometry (see GEOS-469) } } if (poly.getStroke() != null) { poly.getStroke().accept(this); } if (poly.getFill() != null) { poly.getFill().accept(this); } }
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.LineSymbolizer) */ public void visit(LineSymbolizer line) { if (symbolizerGeometriesVisitEnabled) { if (line.getGeometry() != null) { line.getGeometry().accept(this, null); } else { this.defaultGeometryUsed = true; // they want the default geometry (see GEOS-469) } } if (line.getPerpendicularOffset() != null) { line.getPerpendicularOffset().accept(this, null); } if (line.getStroke() != null) { line.getStroke().accept(this); } }
public void visit(PolygonSymbolizer poly) { // adds the uom attribute according to the OGC SE specification AttributesImpl atts = new AttributesImpl(); Unit<Length> uom = poly.getUnitOfMeasure(); if (uom != null) atts.addAttribute("", "uom", "uom", "", UomOgcMapping.get(uom).getSEString()); start("PolygonSymbolizer", atts); encodeGeometryExpression(poly.getGeometry()); if (poly.getFill() != null) { poly.getFill().accept(this); } if (poly.getStroke() != null) { poly.getStroke().accept(this); } if (poly.getOptions() != null) { encodeVendorOptions(poly.getOptions()); } end("PolygonSymbolizer"); }
public void visit(Mark mark) { start("Mark"); if (mark.getWellKnownName() != null && (!"square".equals(mark.getWellKnownName().evaluate(null)) || isExportDefaultValues())) { encodeValue("WellKnownName", null, mark.getWellKnownName(), null); } if (mark.getFill() != null) { mark.getFill().accept(this); } if (mark.getStroke() != null) { mark.getStroke().accept(this); } end("Mark"); }
public void visit(LineSymbolizer line) { // adds the uom attribute according to the OGC SE specification AttributesImpl atts = new AttributesImpl(); Unit<Length> uom = line.getUnitOfMeasure(); if (uom != null) atts.addAttribute("", "uom", "uom", "", UomOgcMapping.get(uom).getSEString()); start("LineSymbolizer", atts); encodeGeometryExpression(line.getGeometry()); if (line.getStroke() != null) { line.getStroke().accept(this); } if (line.getOptions() != null) { encodeVendorOptions(line.getOptions()); } if (line.getPerpendicularOffset() != null) { element("PerpendicularOffset", line.getPerpendicularOffset()); } end("LineSymbolizer"); }
@Override public void visit(PolygonSymbolizer poly) { if (poly.getDescription() != null) { poly.getDescription().accept(this); } if (poly.getDisplacement() != null) { poly.getDisplacement().accept(this); } if (poly.getFill() != null) { poly.getFill().accept(this); } if (poly.getStroke() != null) { poly.getStroke().accept(this); } }
@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)); }
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Mark) */ public void visit(Mark mark) { if (mark.getFill() != null) { mark.getFill().accept(this); } if (mark.getStroke() != null) { mark.getStroke().accept(this); } if (mark.getWellKnownName() != null) { if (mark.getWellKnownName() instanceof Literal) { visitCqlExpression(mark.getWellKnownName().evaluate(null, String.class)); } else { mark.getWellKnownName().accept(this, null); } } }
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); }
@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 testStroke() throws Exception { Stroke original = sb.createStroke(Color.RED, 2, new float[] {5, 10}); original.accept(visitor); Stroke clone = (Stroke) visitor.getCopy(); assertEquals(4.0d, clone.getWidth().evaluate(null, Double.class), 0d); assertEquals(10.0f, clone.getDashArray()[0], 0d); assertEquals(20.0f, clone.getDashArray()[1], 0d); }
public void visit(LineSymbolizer line) { start("LineSymbolizer"); encodeGeometryProperty(line.getGeometryPropertyName()); line.getStroke().accept(this); end("LineSymbolizer"); }
/** * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.PolygonSymbolizer) */ public void visit(PolygonSymbolizer poly) { if (poly.getStroke() != null) { poly.getStroke().accept(this); } if (poly.getFill() != null) { poly.getFill().accept(this); } }