graphic.setSize(parseCssParameter(child)); } else if (childName.equalsIgnoreCase("displacement")) { graphic.setDisplacement(parseDisplacement(child)); } else if (childName.equalsIgnoreCase("anchorPoint")) { graphic.setAnchorPoint(parseAnchorPoint(child));
@Override public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Graphic g = (Graphic) super.parse(instance, node, value); if (node.hasChild(AnchorPoint.class)) { g.setAnchorPoint((AnchorPoint) node.getChildValue(AnchorPoint.class)); } if (node.hasChild(Displacement.class)) { g.setDisplacement((Displacement) node.getChildValue(Displacement.class)); } return g; } }
graphic.setDisplacement((Displacement) node.getChildValue("Displacement"));
/** 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"); } }
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); }
copy.setDisplacement(displacementCopy); copy.setAnchorPoint(anchorCopy); copy.setExternalGraphics(externalGraphicsCopy);
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); } } } } }
@Override public void handle(YamlObject<?> obj, YamlParseContext context) { graphic(g); YamlMap map = obj.map(); if (map.has("anchor")) { g.setAnchorPoint(Util.anchor(map.get("anchor"), factory)); } if (map.has("opacity")) { g.setOpacity(Util.expression(map.str("opacity"), factory)); } if (map.has("size")) { g.setSize(Util.expression(map.str("size"), factory)); } if (map.has("displacement")) { g.setDisplacement(Util.displacement(map.get("displacement"), factory)); } if (map.has("rotation")) { g.setRotation(Util.expression(map.str("rotation"), factory)); } if (map.has("gap")) { g.setGap(Util.expression(map.str("gap"), factory)); } if (map.has("initial-gap")) { g.setInitialGap(Util.expression(map.str("initial-gap"), factory)); } context.push("symbols", new SymbolsParser()); }
graphic.setSize(parseCssParameter(child)); } else if (childName.equalsIgnoreCase("displacement")) { graphic.setDisplacement(parseDisplacement(child)); } else if (childName.equalsIgnoreCase("rotation")) { graphic.setRotation(parseCssParameter(child));
graphic.setDisplacement(parseDisplacement(child));
@Override public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Graphic g = (Graphic) super.parse(instance, node, value); if (node.hasChild(AnchorPoint.class)) { g.setAnchorPoint((AnchorPoint)node.getChildValue(AnchorPoint.class)); } if (node.hasChild(Displacement.class)) { g.setDisplacement((Displacement)node.getChildValue(Displacement.class)); } return g; } }
copy.setDisplacement(displacementCopy); copy.setAnchorPoint(anchorCopy); copy.setOpacity(LITERAL_ONE);
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 apply() { if (graphic != null) { graphic.setDisplacement(guiDisplacement.getEdited()); graphic.setGeometryPropertyName(guiGeom.getGeom()); graphic.setOpacity(guiOpacity.getExpression()); graphic.setRotation(guiRotation.getExpression()); graphic.setSize(guiSize.getExpression()); graphic.setMarks(guiMark.getEdited()); graphic.setExternalGraphics(guiExternal.getEdited()); } }
Displacement d = iconOffsetDisplacement(); d.setDisplacementY(d.getDisplacementY()); g.setDisplacement(d);
copy.setDisplacement(displacementCopy); copy.setExternalGraphics(externalGraphicsCopy); copy.setMarks(marksCopy);
copy.setDisplacement(displacementCopy); copy.setExternalGraphics(externalGraphicsCopy); copy.setMarks(marksCopy);
copy.setDisplacement(displacementCopy); copy.setExternalGraphics(externalGraphicsCopy); copy.setMarks(marksCopy);
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); } } } } }
@Override public void handle(YamlObject<?> obj, YamlParseContext context) { graphic(g); YamlMap map = obj.map(); if (map.has("anchor")) { g.setAnchorPoint(Util.anchor(map.get("anchor"), factory)); } if (map.has("opacity")) { g.setOpacity(Util.expression(map.str("opacity"), factory)); } if (map.has("size")) { g.setSize(Util.expression(map.str("size"), factory)); } if (map.has("displacement")) { g.setDisplacement(Util.displacement(map.get("displacement"), factory)); } if (map.has("rotation")) { g.setRotation(Util.expression(map.str("rotation"), factory)); } if (map.has("gap")) { g.setGap(Util.expression(map.str("gap"), factory)); } if (map.has("initial-gap")) { g.setInitialGap(Util.expression(map.str("initial-gap"), factory)); } context.push("symbols", new SymbolsParser()); }