graphic.setDisplacement(parseDisplacement(child)); } else if (childName.equalsIgnoreCase("anchorPoint")) { graphic.setAnchorPoint(parseAnchorPoint(child)); } else if (childName.equalsIgnoreCase("rotation")) { graphic.setRotation(parseCssParameter(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.setAnchorPoint((AnchorPoint) node.getChildValue("AnchorPoint"));
@Test public void testGraphicAnchor() { Graphic g = sb.createGraphic(); g.setAnchorPoint(sb.createAnchorPoint(ff.property("ax"), ff.property("ay"))); StyleAttributeExtractor extractor = new StyleAttributeExtractor(); g.accept(extractor); // check the plain names Set<String> atts = extractor.getAttributeNameSet(); assertEquals(2, atts.size()); assertTrue(atts.contains("ax")); assertTrue(atts.contains("ay")); }
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.setAnchorPoint(anchorCopy); copy.setExternalGraphics(externalGraphicsCopy); copy.setMarks(marksCopy);
@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()); }
@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; } }
double expectedAnchorPointX = 0.25; double expectedAnchorPointY = 0.75; graphic.setAnchorPoint(sb.createAnchorPoint(expectedAnchorPointX, expectedAnchorPointY)); stroke.setGraphicStroke(graphic);
copy.setAnchorPoint(anchorCopy); copy.setOpacity(LITERAL_ONE); copy.setRotation(rotationCopy);
graphic.setAnchorPoint(anchorPoint);
@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()); }