@Override public void visit(Graphic gr) { if (gr.getAnchorPoint() != null) { gr.getAnchorPoint().accept(this); } if (gr.getDisplacement() != null) { gr.getDisplacement().accept(this); } for (ExternalGraphic eg : gr.getExternalGraphics()) { eg.accept(this); } for (Mark m : gr.getMarks()) { m.accept(this); } }
public void visit(Graphic gr) { start("Graphic"); // encodeGeometryProperty(gr.getGeometryPropertyName()); Symbol[] symbols = gr.getSymbols(); for (int i = 0; i < symbols.length; i++) { symbols[i].accept(this); } element("Opacity", gr.getOpacity(), 1.0); element("Size", gr.getSize()); element("Rotation", gr.getRotation(), 0.0); if (gr.getAnchorPoint() != null) { visit(gr.getAnchorPoint()); } if (gr.getDisplacement() != null) { visit(gr.getDisplacement()); } end("Graphic"); }
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Graphic) */ public void visit(Graphic gr) { if (gr.getSymbols() != null) { Symbol[] symbols = gr.getSymbols(); for (int i = 0; i < symbols.length; i++) { Symbol symbol = symbols[i]; symbol.accept(this); } } if (gr.getOpacity() != null) { gr.getOpacity().accept(this, null); } if (gr.getRotation() != null) { gr.getRotation().accept(this, null); } if (gr.getSize() != null) { gr.getSize().accept(this, null); } if (gr.getDisplacement() != null) gr.getDisplacement().accept(this); if (gr.getAnchorPoint() != null) gr.getAnchorPoint().accept(this); }
/** Checks if the Displacement settings are exported to XML */ public void testDisplacement() throws Exception { StyleBuilder sb = new StyleBuilder(); Graphic graphic; { graphic = sb.createGraphic(); Displacement disp = sb.createDisplacement(10.1, -5.5); graphic.setDisplacement(disp); } Displacement disp = graphic.getDisplacement(); assertNotNull(disp); assertEquals(disp.getDisplacementX().toString(), "10.1"); assertEquals(disp.getDisplacementY().toString(), "-5.5"); } }
if (gr.getDisplacement() != null) { gr.getDisplacement().accept(this); displacementCopy = (Displacement) pages.pop();
public void visit(Graphic gr) { Graphic copy = null; Displacement displacementCopy = copy(gr.getDisplacement()); ExternalGraphic[] externalGraphicsCopy = copy(gr.getExternalGraphics()); Mark[] marksCopy = copy(gr.getMarks()); Expression opacityCopy = copy(gr.getOpacity()); Expression rotationCopy = copy(gr.getRotation()); Expression sizeCopy = copy(gr.getSize()); AnchorPoint anchorCopy = copy(gr.getAnchorPoint()); // Looks like Symbols are a "view" of marks and external graphics? // Symbol[] symbolCopys = copy( gr.getSymbols() ); copy = sf.createDefaultGraphic(); copy.setDisplacement(displacementCopy); copy.setAnchorPoint(anchorCopy); copy.setExternalGraphics(externalGraphicsCopy); copy.setMarks(marksCopy); copy.setOpacity(opacityCopy); copy.setRotation(rotationCopy); copy.setSize(sizeCopy); // copy.setSymbols(symbolCopys); if (STRICT) { if (!copy.equals(gr)) { throw new IllegalStateException("Was unable to duplicate provided Graphic:" + gr); } } pages.push(copy); }
Displacement displacement = sldGraphic.getDisplacement(); if (displacement != null) { displacementX = evalToFloat(displacement.getDisplacementX(), feature, 0f);
@SuppressWarnings("unchecked") @Test public void testPointDisplacement() throws Exception { String yaml = "point: \n" + " displacement: " + tuple(10, 42) + "\n" + " symbols: \n" + " - mark: \n" + " fill-color: '#FF0000'\n"; StyledLayerDescriptor sld = Ysld.parse(yaml); PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld)); assertThat( p.getGraphic().getDisplacement(), allOf( hasProperty("displacementX", literal(10)), hasProperty("displacementY", literal(42)))); // SLD/SE 1.1 feature that may not be supported by renderer }
@Override protected void encode(Graphic g) { if (!flatten) push("graphic"); inline(new AnchorPointEncoder(g.getAnchorPoint())); inline(new DisplacementEncoder(g.getDisplacement())); put("gap", nullIf(g.getGap(), 0d), nullIf(g.getInitialGap(), 0d)); put("opacity", nullIf(g.getOpacity(), 1)); put("size", g.getSize()); put("rotation", nullIf(g.getRotation(), 0d)); put("symbols", new SymbolsEncoder(g)); } }
private void rescale(Graphic graphic, Unit<Length> unit) { if (graphic != null) { graphic.setSize(rescale(graphic.getSize(), unit)); graphic.setGap(rescale(graphic.getGap(), unit)); Displacement disp = graphic.getDisplacement(); if (disp != null) { disp.setDisplacementX(rescale(disp.getDisplacementX(), unit)); disp.setDisplacementY(rescale(disp.getDisplacementY(), unit)); graphic.setDisplacement(disp); } if (graphic.graphicalSymbols() != null) { for (GraphicalSymbol gs : graphic.graphicalSymbols()) { if (gs instanceof Mark) { Mark mark = (Mark) gs; rescaleStroke(mark.getStroke(), unit); rescaleFill(mark.getFill(), unit); } } } } }
p.getGraphic().getDisplacement(), allOf( hasProperty("displacementX", literal(10)),
/** * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Graphic) */ public void visit(Graphic gr) { if (gr.getSymbols() != null) { Symbol[] symbols = gr.getSymbols(); for (int i = 0; i < symbols.length; i++) { Symbol symbol = symbols[i]; symbol.accept(this); } } if (gr.getOpacity() != null) { gr.getOpacity().accept(this,null); } if (gr.getRotation() != null) { gr.getRotation().accept(this,null); } if (gr.getSize() != null) { gr.getSize().accept(this,null); } if (gr.getDisplacement() != null) gr.getDisplacement().accept(this); }
/** * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Graphic) */ public void visit(Graphic gr) { if (gr.getSymbols() != null) { Symbol[] symbols = gr.getSymbols(); for (int i = 0; i < symbols.length; i++) { Symbol symbol = symbols[i]; symbol.accept(this); } } if (gr.getOpacity() != null) { gr.getOpacity().accept(this,null); } if (gr.getRotation() != null) { gr.getRotation().accept(this,null); } if (gr.getSize() != null) { gr.getSize().accept(this,null); } if (gr.getDisplacement() != null) gr.getDisplacement().accept(this); }
@Override public void visit(Graphic gr) { if (gr.getAnchorPoint() != null) { gr.getAnchorPoint().accept(this); } if (gr.getDisplacement() != null) { gr.getDisplacement().accept(this); } for (ExternalGraphic eg : gr.getExternalGraphics()) { eg.accept(this); } if (gr.getGap() != null) { //gr.getGap().accept(visitor, extraData) } if (gr.getInitialGap() != null) { //gr.getInitialGap().accept(visitor, extraData) } for (Mark m : gr.getMarks()) { m.accept(this); } if (gr.getOpacity() != null) { //gr.getOpacity().accept(visitor, extraData) } if (gr.getRotation() != null) { //gr.getRotation().accept(visitor, extraData) } if (gr.getSize() != null) { //gr.getSize().accept(visitor, extraData) } }
public void visit(Graphic gr) { Graphic copy = null; Displacement displacementCopy = copy( gr.getDisplacement() ); ExternalGraphic[] externalGraphicsCopy = copy( gr.getExternalGraphics() ); Mark[] marksCopy = copy( gr.getMarks() ); Expression opacityCopy = copy( gr.getOpacity() ); Expression rotationCopy = copy( gr.getRotation() ); Expression sizeCopy = copy( gr.getSize() ); // Looks like Symbols are a "view" of marks and external graphics? // Symbol[] symbolCopys = copy( gr.getSymbols() ); copy = sf.createDefaultGraphic(); copy.setDisplacement(displacementCopy); copy.setExternalGraphics(externalGraphicsCopy); copy.setMarks(marksCopy); copy.setOpacity((Expression) opacityCopy); copy.setRotation((Expression) rotationCopy); copy.setSize((Expression) sizeCopy); // copy.setSymbols(symbolCopys); if( STRICT ){ if( !copy.equals( gr )){ throw new IllegalStateException("Was unable to duplicate provided Graphic:"+gr ); } } pages.push(copy); }
public void visit(Graphic gr) { start("Graphic"); //encodeGeometryProperty(gr.getGeometryPropertyName()); Symbol[] symbols = gr.getSymbols(); for (int i = 0; i < symbols.length; i++) { symbols[i].accept(this); } element("Opacity", gr.getOpacity(), 1.0); element("Size", gr.getSize()); element("Rotation", gr.getRotation(), 0.0); visit(gr.getDisplacement()); end("Graphic"); }
if (gr.getDisplacement() != null) { gr.getDisplacement().accept(this); displacementCopy = (Displacement) pages.pop();
public void setEdited(Graphic graphic) { if (graphic != null) { guiDisplacement.setEdited(graphic.getDisplacement()); guiGeom.setGeom(graphic.getGeometryPropertyName()); guiOpacity.setExpression(graphic.getOpacity()); guiRotation.setExpression(graphic.getRotation()); guiSize.setExpression(graphic.getSize()); // marks and external graphics are symbols so no need to handle this method //graphic.getSymbols(); guiMark.setEdited(graphic.getMarks()); guiExternal.setEdited(graphic.getExternalGraphics()); } this.graphic = graphic; }
@Override protected void encode(Graphic g) { if (!flatten) push("graphic"); inline(new AnchorPointEncoder(g.getAnchorPoint())); inline(new DisplacementEncoder(g.getDisplacement())); put("gap", nullIf(g.getGap(), 0d), nullIf(g.getInitialGap(), 0d)); put("opacity", nullIf(g.getOpacity(), 1)); put("size", g.getSize()); put("rotation", nullIf(g.getRotation(), 0d)); put("symbols", new SymbolsEncoder(g)); } }
private void rescale(Graphic graphic, double mapScale, Unit<Length> unit) { if(graphic != null) { graphic.setSize(rescale(graphic.getSize(), mapScale, unit)); graphic.setGap(rescale(graphic.getGap(), mapScale, unit)); Displacement disp = graphic.getDisplacement(); if (disp != null) { disp.setDisplacementX(rescale(disp.getDisplacementX(), mapScale, unit)); disp.setDisplacementY(rescale(disp.getDisplacementY(), mapScale, unit)); graphic.setDisplacement(disp); } if (graphic.graphicalSymbols() != null) { for (GraphicalSymbol gs : graphic.graphicalSymbols()) { if(gs instanceof Mark) { Mark mark = (Mark) gs; rescaleStroke(mark.getStroke(), mapScale, unit); rescaleFill(mark.getFill(), mapScale, unit); } } } } }