/** * Creates the default graphic object * * @return the graphic object */ public Graphic createGraphic() { Graphic gr = sf.getDefaultGraphic(); Mark mark = createMark(MARK_SQUARE, Color.decode("#808080"), Color.BLACK, 1); gr.setMarks(new Mark[] {mark}); gr.setSize(Expression.NIL); return gr; }
@Test public void testResizeMark() { PointSymbolizer ps = sb.createPointSymbolizer(sb.createGraphic(null, sb.createMark("square"), null)); GraphicsAwareDpiRescaleStyleVisitor visitor = new GraphicsAwareDpiRescaleStyleVisitor(2); ps.accept(visitor); PointSymbolizer resized = (PointSymbolizer) visitor.getCopy(); Expression size = resized.getGraphic().getSize(); assertTrue(size instanceof Literal); assertEquals(32, size.evaluate(null, Integer.class).intValue()); }
@Test public void testRescalePolygonMargin() throws Exception { // create a graphic that needs rescaling StyleBuilder sb = new StyleBuilder(); // a graphic fill Fill fill = sb.createFill(); fill.setColor(null); fill.setGraphicFill( sb.createGraphic(null, sb.createMark("square", null, sb.createStroke(2)), null)); // a polygon and line symbolizer using them PolygonSymbolizer polygonSymbolizer = sb.createPolygonSymbolizer(sb.createStroke(), fill); polygonSymbolizer.getOptions().put(PolygonSymbolizer.GRAPHIC_MARGIN_KEY, "1 2 3 4"); // rescale it polygonSymbolizer.accept(visitor); PolygonSymbolizer rps = (PolygonSymbolizer) visitor.getCopy(); Mark rm = (Mark) rps.getFill().getGraphicFill().graphicalSymbols().get(0); assertEquals(4.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d); assertEquals("2 4 6 8", rps.getOptions().get(PolygonSymbolizer.GRAPHIC_MARGIN_KEY)); } }
@Test public void testSimpleGraphic() { PointSymbolizer ps = sb.createPointSymbolizer( sb.createGraphic(null, sb.createMark(sb.MARK_CIRCLE), null)); ps.getGraphic().setSize(sb.literalExpression(15)); Style style = sb.createStyle(ps); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(style); assertEquals(16, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
public void newMark() { StyleBuilder sb = new StyleBuilder(); Mark m = sb.createMark("round"); marks.add(m); int last = marks.size() - 1; fireTableRowsInserted(last, last); }
|| (geometryAttrType.getType().getBinding() == Point.class)) { Fill fill = sb.createFill(color, opacity); Mark square = sb.createMark(StyleBuilder.MARK_SQUARE, fill, defaultStroke);
@Test public void testMarkNoSizeNoStroke() throws Exception { StyleBuilder sb = new StyleBuilder(); Mark mark = sb.createMark("square"); mark.setStroke(null); Graphic graphic = sb.createGraphic(null, mark, null); graphic.setSize(NilExpression.NIL); PointSymbolizer ps = sb.createPointSymbolizer(graphic); Style style = sb.createStyle(ps); MetaBufferEstimator estimator = new MetaBufferEstimator(); style.accept(estimator); assertTrue(estimator.isEstimateAccurate()); assertEquals(16, estimator.getBuffer()); }
public Mark getEdited() { if (mark == null) { mark = new StyleBuilder().createMark("triangle"); } apply(); return mark; }
/** * Creates the default graphic object * * @return the graphic object */ public Graphic createGraphic() { Graphic gr = sf.getDefaultGraphic(); Mark mark = createMark(MARK_SQUARE, Color.decode("#808080"), Color.BLACK, 1); gr.setMarks( new Mark[] { mark }); gr.setSize(Expression.NIL); return gr; }
/** * Creates the default graphic object * * @return the graphic object */ public Graphic createGraphic() { Graphic gr = sf.getDefaultGraphic(); Mark mark = createMark(MARK_SQUARE, Color.decode("#808080"), Color.BLACK, 1); gr.setMarks( new Mark[] { mark }); gr.setSize(Expression.NIL); return gr; }
sb.createMark( "wkt://LINESTRING(0 0, ${sin(Nagib) * 20000} ${cos(Nagib) * 20000} )", Color.red);
@Test public void testMarkStroke() throws Exception { StyleBuilder sb = new StyleBuilder(); Mark mark = sb.createMark("square"); mark.getStroke().setWidth(sb.getFilterFactory().literal(10)); Graphic graphic = sb.createGraphic(null, mark, null); graphic.setSize(NilExpression.NIL); PointSymbolizer ps = sb.createPointSymbolizer(graphic); Style style = sb.createStyle(ps); MetaBufferEstimator estimator = new MetaBufferEstimator(); style.accept(estimator); assertTrue(estimator.isEstimateAccurate()); assertEquals(26, estimator.getBuffer()); }
stroke.setColor(null); stroke.setGraphicStroke( sb.createGraphic(null, sb.createMark("square", null, sb.createStroke(1)), null)); fill.setColor(null); fill.setGraphicFill( sb.createGraphic(null, sb.createMark("square", null, sb.createStroke(2)), null));
@Test public void testRescaleGraphicPointSymbolizer() { // create a graphic that needs rescaling StyleBuilder sb = new StyleBuilder(); // create a circle Mark circle = sb.createMark("circle", null, sb.createStroke(500)); Graphic g = sb.createGraphic(null, circle, null); // a point symbolizer with the specified circle PointSymbolizer ps = sb.createPointSymbolizer(g); // first see it in feet ps.setUnitOfMeasure(USCustomary.FOOT); // rescale it UomRescaleStyleVisitor visitor = new UomRescaleStyleVisitor(10); ps.accept(visitor); PointSymbolizer rps = (PointSymbolizer) visitor.getCopy(); Mark rm = (Mark) rps.getGraphic().graphicalSymbols().get(0); assertEquals(1524.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d); // now let's see the same in meters ps.setUnitOfMeasure(SI.METRE); // rescale it visitor = new UomRescaleStyleVisitor(10); ps.accept(visitor); rps = (PointSymbolizer) visitor.getCopy(); rm = (Mark) rps.getGraphic().graphicalSymbols().get(0); assertEquals(5000.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d); }
@Test public void testGraphicSizeFunction() throws Exception { StyleBuilder sb = new StyleBuilder(); Mark mark = sb.createMark("square"); mark.setStroke(null); Graphic graphic = sb.createGraphic(null, mark, null); FilterFactory2 ff = sb.getFilterFactory(); graphic.setSize(ff.function("env", ff.literal("test"))); PointSymbolizer ps = sb.createPointSymbolizer(graphic); Style style = sb.createStyle(ps); try { EnvFunction.setGlobalValue("test", 10); MetaBufferEstimator estimator = new MetaBufferEstimator(); style.accept(estimator); assertTrue(estimator.isEstimateAccurate()); assertEquals(10, estimator.getBuffer()); } finally { EnvFunction.clearGlobalValues(); } }
stroke.setColor(null); Graphic graphic = sb.createGraphic(null, sb.createMark("square", null, sb.createStroke(1)), null); double expectedAnchorPointX = 0.25; double expectedAnchorPointY = 0.75; fill.setColor(null); fill.setGraphicFill( sb.createGraphic(null, sb.createMark("square", null, sb.createStroke(2)), null));
public PointSymbolizer createPointSymbolizer() { Fill fill = sb.createFill(randomColor(), 1); Stroke stroke = sb.createStroke(randomColor(), 1); Mark mark = sb.createMark(randomPointShape(), fill, stroke); Graphic gra = sb.createGraphic(); gra.setOpacity(sb.literalExpression(1)); gra.setMarks(new Mark[]{mark}); gra.setSize(sb.literalExpression(randomPointSize())); return sb.createPointSymbolizer(gra); }
StyleBuilder sb = new StyleBuilder(); FilterFactory2 ff = sb.getFilterFactory(); Mark testMark = sb.createMark(sb.literalExpression("Circle"), sb.createFill(sb.attributeExpression("color"),sb.attributeExpression("opacity")), null); Graphic graph = sb.createGraphic(null, // An external graphics if needed new Mark[] { testMark }, // a Mark if not an external graphics null, // aSymbol ff.literal(sb.attributeExpression("opacity")), // opacity ff.property("size"), // read from feature "size" attribute ff.literal(0)); // rotation, here read into the feature PointSymbolizer aPointSymbolizer = sb.createPointSymbolizer(graph); // creation of the style org.geotools.styling.Style style = sb.createStyle(aPointSymbolizer);
@Test public void testMixDynamicGraphicStroke() { Style style = sb.createStyle(); FeatureTypeStyle fts1 = sb.createFeatureTypeStyle("Feature", staticPolygonRule); Graphic graphic = sb.createGraphic(null, sb.createMark("square"), null); graphic.setSize(sb.getFilterFactory().property("myAttribute")); LineSymbolizer ls = sb.createLineSymbolizer(); ls.getStroke().setGraphicStroke(graphic); FeatureTypeStyle fts2 = sb.createFeatureTypeStyle(ls); style.featureTypeStyles().add(fts1); style.featureTypeStyles().add(fts2); checkSingleSymbolizer(style, ls); }
@Test public void testDynamicStrokeInGraphicMark() { Stroke markStroke = sb.createStroke(); markStroke.setWidth(sb.getFilterFactory().property("myAttribute")); Mark mark = sb.createMark("square"); mark.setStroke(markStroke); Graphic graphic = sb.createGraphic(null, mark, null); LineSymbolizer ls = sb.createLineSymbolizer(); ls.getStroke().setGraphicStroke(graphic); Style style = sb.createStyle(ls); checkSingleSymbolizer(style, ls); }