public static Graphic graphic(PointSymbolizer sym) { if (sym == null) { return null; } return sym.getGraphic(); }
public void visit(PointSymbolizer ps) { PointSymbolizer copy = sf.getDefaultPointSymbolizer(); copy.setGeometry(copy(ps.getGeometry())); copy.setUnitOfMeasure(ps.getUnitOfMeasure()); copy.setGraphic(copy(ps.getGraphic())); copy.getOptions().putAll(ps.getOptions()); if (STRICT) { if (!copy.equals(ps)) { throw new IllegalStateException("Was unable to duplicate provided Graphic:" + ps); } } pages.push(copy); }
public PointSymbolizer createPointSymbolizer(Graphic graphic, String geometryPropertyName) { PointSymbolizer pSymb = new PointSymbolizerImpl(); pSymb.setGeometryPropertyName(geometryPropertyName); pSymb.setGraphic(graphic); return pSymb; }
@Override public void visit(PointSymbolizer ps) { if (ps.getDescription() != null) { ps.getDescription().accept(this); } if (ps.getGraphic() != null) { ps.getGraphic().accept(this); } }
ps.setGraphic(styleFactory.createDefaultGraphic()); ps.getGraphic().graphicalSymbols().add(mark);
public void visit(PointSymbolizer ps) { // adds the uom attribute according to the OGC SE specification AttributesImpl atts = new AttributesImpl(); Unit<Length> uom = ps.getUnitOfMeasure(); if (uom != null) atts.addAttribute("", "uom", "uom", "", UomOgcMapping.get(uom).getSEString()); start("PointSymbolizer", atts); encodeGeometryExpression(ps.getGeometry()); ps.getGraphic().accept(this); if (ps.getOptions() != null) { encodeVendorOptions(ps.getOptions()); } end("PointSymbolizer"); }
public PointSymbolizer build() { if (unset) { return null; } PointSymbolizer ps = sf.createPointSymbolizer(); ps.setGeometry(geometry); ps.setGraphic(graphic.build()); if (uom != null) { ps.setUnitOfMeasure(uom); } ps.getOptions().putAll(options); if (parent == null) { reset(); } return ps; }
public Builder<PointSymbolizer> reset(PointSymbolizer original) { if (original == null) { return unset(); } this.geometry = original.getGeometry(); this.graphic.reset(original.getGraphic()); this.uom = original.getUnitOfMeasure(); unset = false; return this; }
@Override public void visit(PointSymbolizer ps) { super.visit(ps); PointSymbolizer copy = (PointSymbolizer) pages.peek(); Unit<Length> uom = copy.getUnitOfMeasure(); Graphic copyGraphic = copy.getGraphic(); rescale(copyGraphic, uom); copy.setUnitOfMeasure(Units.PIXEL); }
/** * Tests size calculation of dynamically sized feature, using real-world units combined with * DPI-based resizing. */ @Test public void testCombinedResizingDpiUom() { // given: Point with dynamic size in real-world units int sizeNum = 10; double scaleDpi = 2; double scaleUom = 3; PointSymbolizer symbolizer = sb.createPointSymbolizer(); Graphic graphic = sb.createGraphic(); graphic.setSize(ff.function("strConcat", ff.property("size"), ff.literal("m"))); symbolizer.setGraphic(graphic); // when: DPI based resizing is applied RescaleStyleVisitor dpiVisitor = new GraphicsAwareDpiRescaleStyleVisitor(scaleDpi); symbolizer.accept(dpiVisitor); symbolizer = (PointSymbolizer) dpiVisitor.getCopy(); // and: UOM resizing is applied UomRescaleStyleVisitor uomVisitor = new UomRescaleStyleVisitor(scaleUom); uomVisitor.visit(symbolizer); symbolizer = (PointSymbolizer) uomVisitor.getCopy(); SimpleFeature feature = createFeatureSized(sizeNum); // then: only the UOM resizing must have an effect Double size = symbolizer.getGraphic().getSize().evaluate(feature, Double.class); assertEquals(sizeNum * scaleUom, size.doubleValue(), 0d); }
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.PointSymbolizer) */ public void visit(PointSymbolizer ps) { if (symbolizerGeometriesVisitEnabled) { if (ps.getGeometry() != null) { ps.getGeometry().accept(this, null); } else { this.defaultGeometryUsed = true; // they want the default geometry (see GEOS-469) } } if (ps.getGraphic() != null) { ps.getGraphic().accept(this); } }
/** * create a point symbolizer * * @param graphic - the graphic object to draw at the point * @return the new point symbolizer */ public PointSymbolizer createPointSymbolizer(Graphic graphic) { PointSymbolizer ps = sf.createPointSymbolizer(); ps.setGraphic(graphic); return ps; }
if (geometry instanceof PropertyName) { PropertyName propertyName = (PropertyName) geometry; ps.setGeometryPropertyName(propertyName.getPropertyName()); } else { ps.setGeometry(geometry); ps.setGraphic((Graphic) node.getChildValue("Graphic")); ps.getOptions() .put(param.getName(), param.getExpression().evaluate(null, String.class));
@Test public void testResizeExternalGraphic() throws IOException { File imageFile = new File("./src/test/resources/org/geotools/renderer/lite/test-data/draw.png") .getCanonicalFile(); assertTrue(imageFile.exists()); String fileUrl = URLs.fileToUrl(imageFile).toExternalForm(); PointSymbolizer ps = sb.createPointSymbolizer( sb.createGraphic( null, null, sb.createExternalGraphic(fileUrl, "image/png"))); GraphicsAwareDpiRescaleStyleVisitor visitor = new GraphicsAwareDpiRescaleStyleVisitor(2); ps.accept(visitor); PointSymbolizer resized = (PointSymbolizer) visitor.getCopy(); Expression size = resized.getGraphic().getSize(); assertTrue(size instanceof Literal); // original image height was 22 assertEquals(44, size.evaluate(null, Integer.class).intValue()); }
@Test public void testRescaleGraphicPointSymbolizer() { // create a graphic that needs rescaling StyleBuilder sb = new StyleBuilder(); // create a circle Mark circle = sb.createMark("circle", null, sb.createStroke(500)); Graphic g = sb.createGraphic(null, circle, null); // a point symbolizer with the specified circle PointSymbolizer ps = sb.createPointSymbolizer(g); // first see it in feet ps.setUnitOfMeasure(USCustomary.FOOT); // rescale it UomRescaleStyleVisitor visitor = new UomRescaleStyleVisitor(10); ps.accept(visitor); PointSymbolizer rps = (PointSymbolizer) visitor.getCopy(); Mark rm = (Mark) rps.getGraphic().graphicalSymbols().get(0); assertEquals(1524.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d); // now let's see the same in meters ps.setUnitOfMeasure(SI.METRE); // rescale it visitor = new UomRescaleStyleVisitor(10); ps.accept(visitor); rps = (PointSymbolizer) visitor.getCopy(); rm = (Mark) rps.getGraphic().graphicalSymbols().get(0); assertEquals(5000.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d); }
@Override public void visit(PointSymbolizer ps) { if (ps.getDescription() != null) { ps.getDescription().accept(this); } if (ps.getGeometry() != null) { //ps.getGeometry().accept(visitor, extraData) } if (ps.getGraphic() != null) { ps.getGraphic().accept(this); } }
pointSymbolizer.setName(name); Graphic graphic = pointSymbolizer.getGraphic(); graphic.setSize(ff.literal(DEFAULT_ARROW_SIZE)); List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols(); FunctionManager.getInstance() .createExpression(locationFunction, endPointArgumentList); pointSymbolizer.setGeometry(geometry);
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { PointSymbolizer ps = styleFactory.createPointSymbolizer(); //<xsd:element ref="sld:Geometry" minOccurs="0"/> if(node.hasChild("Geometry")) { Expression geometry = (Expression) node.getChildValue("Geometry"); if(geometry instanceof PropertyName) { PropertyName propertyName = (PropertyName) geometry; ps.setGeometryPropertyName(propertyName.getPropertyName()); } else { ps.setGeometry(geometry); } } //<xsd:element ref="sld:Graphic" minOccurs="0"/> if (node.hasChild("Graphic")) { ps.setGraphic((Graphic) node.getChildValue("Graphic")); } return ps; } }
symbol.setUnitOfMeasure(uomMapping.getUnit()); symbol.setGeometry(parseGeometry(child)); } else if (childName.equalsIgnoreCase(graphicSt)) { symbol.setGraphic(parseGraphic(child));
@Test public void testGeometryTransformation() { PointSymbolizer ps = sb.createPointSymbolizer(); ps.setGeometry( ff.function( "offset", ff.property("the_geom"), ff.property("offx"), ff.property("offy"))); Rule r = sb.createRule(ps); StyleAttributeExtractor extractor = new StyleAttributeExtractor(); r.accept(extractor); Set<String> atts = extractor.getAttributeNameSet(); assertEquals(3, atts.size()); assertTrue(atts.contains("the_geom")); assertTrue(atts.contains("offx")); assertTrue(atts.contains("offy")); assertFalse(extractor.getDefaultGeometryUsed()); }