return sf.createGraphic(exg, m, s, opacity, size, rotation);
styleFactory.createGraphic( null, null,
private static Style createPointStyle() { StyleFactory sf = CommonFactoryFinder.getStyleFactory(); URL iconUrl = ScreenMapShapefileTest.class.getResource("icon.png"); ExternalGraphic icon = sf.createExternalGraphic(iconUrl, "image/png"); Graphic graphic = sf.createGraphic(new ExternalGraphic[] {icon}, null, null, null, null, null); PointSymbolizer symbolizer = sf.createPointSymbolizer(graphic, "the_geom"); Rule rule = sf.createRule(); rule.symbolizers().add(symbolizer); FeatureTypeStyle fts = sf.createFeatureTypeStyle(); fts.rules().add(rule); Style style = sf.createStyle(); style.featureTypeStyles().add(fts); return style; }
public void testResizeGraphicFill() throws Exception { URL url = StreamingRenderer.class.getResource("test-data/"); PolygonSymbolizer symb = sf.createPolygonSymbolizer(); ExternalGraphic eg = sf.createExternalGraphic(url + "icon64.png", "image/png"); Graphic g = sf.createGraphic( new ExternalGraphic[] {eg}, null, null, null, ff.literal(20), null); Fill fill = sf.createFill(null, null, null, g); symb.setFill(fill); PolygonStyle2D ps = sld.createPolygonStyle(feature, symb, range); assertTrue(ps.getFill() instanceof TexturePaint); TexturePaint paint = (TexturePaint) ps.getFill(); assertEquals(20, paint.getImage().getWidth()); }
return sf.createGraphic(exg, m, s, opacity, size, rotation);
return sf.createGraphic(exg, m, s, opacity, size, rotation);
public void testTexturePaintNoSize() throws Exception { PolygonSymbolizer symb = sf.createPolygonSymbolizer(); Mark myMark = sf.createMark(); myMark.setWellKnownName(ff.literal("square")); org.geotools.styling.Fill fill = sf.createFill(null); fill.setGraphicFill(sf.createGraphic(null, new Mark[] {myMark}, null, null, null, null)); symb.setFill(fill); PolygonStyle2D ps = sld.createPolygonStyle(feature, symb, range); assertTrue(ps.getFill() instanceof TexturePaint); }
@Test public void testLegend() throws Exception { StyleFactory sf = CommonFactoryFinder.getStyleFactory(); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(); PointSymbolizer p = sf.createPointSymbolizer(); Mark mark = sf.mark(ff.literal("circle"), sf.fill(null, ff.literal("#FF0000"), null), null); p.setGraphic(sf.createGraphic(null, new Mark[] {mark}, null, null, null, null)); Rule rule = sf.createRule(); rule.symbolizers().add(p); ExternalGraphic eg = sf.createExternalGraphic("smileyface.png", "image/png"); rule.setLegend(sf.createGraphic(new ExternalGraphic[] {eg}, null, null, null, null, null)); StringWriter out = new StringWriter(); Ysld.encode(sld(sf.createFeatureTypeStyle(new Rule[] {rule})), out); // System.out.append(out.toString()); YamlMap obj = new YamlMap(YamlUtil.getSafeYaml().load(out.toString())); YamlMap result = obj.seq("feature-styles") .map(0) .seq("rules") .map(0) .map("legend") .seq("symbols") .map(0) .map("external"); assertEquals("smileyface.png", result.str("url")); assertEquals("image/png", result.str("format")); }
LineSymbolizer l = sf.createLineSymbolizer(); Mark mark = sf.mark(ff.literal("circle"), sf.fill(null, ff.literal("#995555"), null), null); Graphic g = sf.createGraphic(null, new Mark[] {mark}, null, null, null, null); Stroke s = sf.createStroke(null, null); s.setGraphicStroke(g);
LineSymbolizer l = sf.createLineSymbolizer(); Mark mark = sf.mark(ff.literal("circle"), sf.fill(null, ff.literal("#995555"), null), null); Graphic g = sf.createGraphic(null, new Mark[] {mark}, null, null, null, null); Stroke s = sf.createStroke(null, ff.literal(10)); s.setGraphicFill(g);
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Mark[] marks = null; ExternalGraphic[] graphics = null; if (node.getChild("Mark") != null) { List l = node.getChildValues("Mark"); marks = (Mark[]) l.toArray(new Mark[l.size()]); } else { List l = node.getChildValues("ExternalGraphic"); graphics = (ExternalGraphic[]) l.toArray(new ExternalGraphic[l.size()]); } Expression opacity = (Expression) node.getChildValue("Opacity"); Expression size = (Expression) node.getChildValue("Size"); Expression rotation = (Expression) node.getChildValue("Rotation"); return styleFactory.createGraphic(graphics, marks, null, opacity, size, rotation); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Mark[] marks = null; ExternalGraphic[] graphics = null; if (node.getChild("Mark") != null) { List l = node.getChildValues("Mark"); marks = (Mark[]) l.toArray(new Mark[l.size()]); } else { List l = node.getChildValues("ExternalGraphic"); graphics = (ExternalGraphic[]) l.toArray(new ExternalGraphic[l.size()]); } Expression opacity = (Expression) node.getChildValue("Opacity"); Expression size = (Expression) node.getChildValue("Size"); Expression rotation = (Expression) node.getChildValue("Rotation"); return styleFactory.createGraphic(graphics, marks, null, opacity, size, rotation); } }
private Literal estimateGraphicSize(ExternalGraphic eg) { Graphic testGraphic = sf.createGraphic( new ExternalGraphic[] {eg}, null, null, LITERAL_ONE, Expression.NIL, ff.literal(0)); PointSymbolizer testSymbolizer = sf.createPointSymbolizer(testGraphic, null); Style2D style = sldFactory.createStyle(null, testSymbolizer); int size = SLDStyleFactory.DEFAULT_MARK_SIZE; if (style instanceof GraphicStyle2D) { GraphicStyle2D gs2d = (GraphicStyle2D) style; size = gs2d.getImage().getWidth(); } else if (style instanceof IconStyle2D) { IconStyle2D is2d = (IconStyle2D) style; size = is2d.getIcon().getIconWidth(); } Literal sizeExpression = ff.literal(size); return sizeExpression; }
externalGraphics = new ExternalGraphic[0]; return styleFactory.createGraphic(externalGraphics, marks, symbols, opacity, size, rotation);