graphic.setAnchorPoint(parseAnchorPoint(child)); } else if (childName.equalsIgnoreCase("rotation")) { graphic.setRotation(parseCssParameter(child));
graphic.setRotation(rotation);
public Graphic createDefaultGraphic() { Graphic graphic = new GraphicImpl(filterFactory); graphic.addMark(createMark()); // a default graphic is assumed to have a single Mark graphic.setSize(Expression.NIL); graphic.setOpacity(filterFactory.literal(1.0)); graphic.setRotation(filterFactory.literal(0.0)); return graphic; }
symbol.setRotation((Expression) value[i].getValue());
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.setMarks(marksCopy); copy.setOpacity((Expression) opacityCopy); copy.setRotation((Expression) rotationCopy); copy.setSize((Expression) sizeCopy); copy.setSymbols(symbolCopys);
/** Test of createPointStyle method, of class org.geotools.renderer.style.SLDStyleFactory. */ public void testCreateCompletePointStyle() { PointSymbolizer symb; Mark myMark; // full symbolizer symb = sf.createPointSymbolizer(); myMark = sf.createMark(); myMark.setFill(sf.createFill(ff.literal("#ffff00"))); symb.getGraphic().setSize(ff.literal(10)); symb.getGraphic().addMark(myMark); symb.getGraphic().setOpacity(ff.literal(1)); symb.getGraphic().setRotation(ff.literal(0)); sld.createPointStyle(null, symb, range); }
@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()); }
public Graphic createDefaultGraphic() { Graphic graphic = new GraphicImpl(); graphic.setSize(Expression.NIL); graphic.setOpacity(filterFactory.literal(1.0)); graphic.setRotation(filterFactory.literal(0.0)); return graphic; }
public Graphic createDefaultGraphic() { Graphic graphic = new GraphicImpl(filterFactory); graphic.addMark( createMark() ); // a default graphic is assumed to have a single Mark graphic.setSize(Expression.NIL); graphic.setOpacity(filterFactory.literal(1.0)); graphic.setRotation(filterFactory.literal(0.0)); return graphic; }
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 Graphic createGraphic(ExternalGraphic[] externalGraphics, Mark[] marks, Symbol[] symbols, Expression opacity, Expression size, Expression rotation) { Graphic graphic = new GraphicImpl(); symbols = symbols != null ? symbols : new Symbol[0]; graphic.setSymbols(symbols); externalGraphics = externalGraphics != null ? externalGraphics : new ExternalGraphic[0]; graphic.setExternalGraphics(externalGraphics); marks = marks != null ? marks : new Mark[0]; graphic.setMarks(marks); if (opacity == null) { opacity = Graphic.DEFAULT.getOpacity(); } graphic.setOpacity(opacity); if (size == null) { size = Graphic.DEFAULT.getSize(); } graphic.setSize(size); if (rotation == null) { rotation = Graphic.DEFAULT.getRotation(); } graphic.setRotation(rotation); return graphic; }
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()); } }
@Test public void testRotation() throws Exception { Style result; { PointSymbolizer symb = this.externalGraphic("http://example.com/foo.png", "image/png"); symb.getGraphic().setRotation(filterFactory.property("heading")); Style input = styleFromRules(catchAllRule(symb)); Map<String, String> properties = new HashMap<String, String>(); properties.put("0.0.0", ""); properties.put("0.0.0.rotation", "45.0"); result = IconPropertyInjector.injectProperties(input, properties); } { FeatureTypeStyle fts = assumeSingleElement(result.featureTypeStyles()); Rule rule = assumeSingleElement(fts.rules()); PointSymbolizer symb = assertSingleElement(rule.symbolizers(), PointSymbolizer.class); Graphic eg = symb.getGraphic(); assertThat(eg.getRotation().evaluate(null).toString(), is("45.0")); } }
@Test public void testTwoLocalFilesOneRotate() throws Exception { final PointSymbolizer symbolizer1 = externalGraphic("file:foo.png", "image/png"); final PointSymbolizer symbolizer2 = externalGraphic("file:bar.png", "image/png"); final Graphic graphic1 = symbolizer1.getGraphic(); graphic1.setRotation(toExpression("45 * field")); final Graphic graphic2 = symbolizer2.getGraphic(); graphic2.setRotation(Expression.NIL); final Style style = styleFromRules(catchAllRule(symbolizer1, symbolizer2)); IconProperties prop = IconPropertyExtractor.extractProperties(style, fieldIs1); assertEquals( "http://127.0.0.1/kml/icon/test?0.0.0=&0.0.0.rotation=45.0&0.0.1=", prop.href("http://127.0.0.1/", null, "test")); assertNull(prop.getHeading()); }
@Test public void testTwoLocalFilesRotate() throws Exception { final PointSymbolizer symbolizer1 = externalGraphic("file:foo.png", "image/png"); final PointSymbolizer symbolizer2 = externalGraphic("file:bar.png", "image/png"); final Graphic graphic1 = symbolizer1.getGraphic(); graphic1.setRotation(toExpression("45 * field")); final Graphic graphic2 = symbolizer2.getGraphic(); graphic2.setRotation(toExpression("22.5 * field")); final Style style = styleFromRules(catchAllRule(symbolizer1, symbolizer2)); IconProperties prop = IconPropertyExtractor.extractProperties(style, fieldIs1); assertEquals( "http://127.0.0.1/kml/icon/test?0.0.0=&0.0.0.rotation=45.0&0.0.1=&0.0.1.rotation=22.5", prop.href("http://127.0.0.1/", null, "test")); assertEquals(0.0d, prop.getHeading(), 0.0001); }
@Test public void testDynamicRotation() throws CQLException { final PointSymbolizer symbolizer = grayCircle(); final Graphic graphic = symbolizer.getGraphic(); graphic.setRotation(toExpression("45 * field")); final Style s = styleFromRules(catchAllRule(symbolizer)); assertEquals("0.0.0=&0.0.0.rotation=45.0", encode(s, fieldIs1)); assertEquals("0.0.0=&0.0.0.rotation=90.0", encode(s, fieldIs2)); }
@Test public void testMarkRotate() throws Exception { final PointSymbolizer symbolizer = grayCircle(); final Graphic graphic = symbolizer.getGraphic(); graphic.setRotation(toExpression("45 * field")); final Style s = styleFromRules(catchAllRule(symbolizer)); IconProperties prop = IconPropertyExtractor.extractProperties(s, fieldIs1); assertEquals( "http://127.0.0.1/kml/icon/test?0.0.0=&0.0.0.rotation=45.0", prop.href("http://127.0.0.1/", null, "test")); assertEquals(0.0d, prop.getHeading(), 0.0001); }
@Test public void testGraphicFallbacks() { FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Style style = SLD.createPointStyle("circle", Color.RED, Color.yellow, 0.5f, 10f); Graphic g = SLD.graphic(SLD.pointSymbolizer(style)); g.setRotation(ff.literal(45)); g.setOpacity(ff.literal(0.5)); Map<String, String> props = new HashMap<String, String>(); props.put("0.0.0", ""); style = IconPropertyInjector.injectProperties(style, props); g = SLD.graphic(SLD.pointSymbolizer(style)); assertEquals(10.0, g.getSize().evaluate(null, Double.class), 0.1); assertEquals(45.0, g.getRotation().evaluate(null, Double.class), 0.1); assertEquals(0.5, g.getOpacity().evaluate(null, Double.class), 0.1); } }
@Test public void testLocalFileRotate() throws Exception { final PointSymbolizer symbolizer = externalGraphic("file:foo.png", "image/png"); final Graphic graphic = symbolizer.getGraphic(); graphic.setRotation(toExpression("45 * field")); final Style style = styleFromRules(catchAllRule(symbolizer)); IconProperties prop1 = IconPropertyExtractor.extractProperties(style, fieldIs1); assertEquals( "http://127.0.0.1/styles/foo.png", prop1.href("http://127.0.0.1/", null, "test")); assertEquals(45.0d, prop1.getHeading(), 0.0001); IconProperties prop2 = IconPropertyExtractor.extractProperties(style, fieldIs2); assertEquals( "http://127.0.0.1/styles/foo.png", prop2.href("http://127.0.0.1/", null, "test")); assertEquals(90.0d, prop2.getHeading(), 0.0001); }