/** * create a new line symbolizer * * @param width the width of the line * @return the new line symbolizer */ public LineSymbolizer createLineSymbolizer(double width) { return createLineSymbolizer(createStroke(width), null); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Color color = (Color) value; Float width = (Float) node.getChildValue("width", Float.valueOf(1f)); return sb.createLineSymbolizer(color, width); } }
/** * create a LineSymbolizer * * @param color - the color of the line * @return the new line symbolizer */ public LineSymbolizer createLineSymbolizer(Color color) { return createLineSymbolizer(createStroke(color), null); }
/** * create a LineSymbolizer * * @param color - the color of the line * @param width - the width of the line * @return the new line symbolizer */ public LineSymbolizer createLineSymbolizer(Color color, double width) { return createLineSymbolizer(createStroke(color, width), null); }
/** * create a LineSymbolizer * * @param color - the color of the line * @param width - the width of the line * @param geometryPropertyName - the name of the geometry to be drawn * @return the new line symbolizer */ public LineSymbolizer createLineSymbolizer( Color color, double width, String geometryPropertyName) { return createLineSymbolizer(createStroke(color, width), geometryPropertyName); }
private Style createLineStyle() { StyleBuilder sb = new StyleBuilder(); return sb.createStyle(sb.createLineSymbolizer()); }
private Style createLineStyle() { StyleBuilder sb = new StyleBuilder(); return sb.createStyle(sb.createLineSymbolizer()); }
public void testRenderEmptyLine() throws SchemaException, IllegalAttributeException { GeometryFactory gf = new GeometryFactory(); StyleBuilder sb = new StyleBuilder(); SimpleFeatureType pointType = DataUtilities.createType("emptyLines", "geom:LineString,name:String"); SimpleFeature f = SimpleFeatureBuilder.build( pointType, new Object[] {gf.createLineString((Coordinate[]) null), "name"}, null); Style style = sb.createStyle(sb.createLineSymbolizer()); renderEmptyGeometry(f, style); }
@Test public void testConstantFunction() { Function cos = ff.function("cos", ff.literal(Math.toRadians(Math.PI))); Symbolizer ls = sb.createLineSymbolizer(sb.createStroke(sb.colorExpression(Color.BLACK), cos)); Rule r = sb.createRule(new Symbolizer[] {ls}); MetaBufferEstimator rbe = new MetaBufferEstimator(); // cos(pi) == 1 rbe.visit(r); assertEquals(1, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
@Test public void testSimpleStroke() { Style style = sb.createStyle(sb.createLineSymbolizer(sb.createStroke(10.0))); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(style); assertEquals(10, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
@Test public void testNullStroke() throws Exception { StyleBuilder sb = new StyleBuilder(); LineSymbolizer ls = sb.createLineSymbolizer(Stroke.NULL); Style style = sb.createStyle(ls); MetaBufferEstimator estimator = new MetaBufferEstimator(); style.accept(estimator); assertTrue(estimator.isEstimateAccurate()); assertEquals(0, estimator.getBuffer()); }
@Test public void testRescalePerpendicularOffset() throws Exception { Stroke stroke = sb.createStroke(Color.RED, 2, new float[] {5, 10}); LineSymbolizer ls = sb.createLineSymbolizer(stroke); ls.setPerpendicularOffset(ff.literal(2)); ls.accept(visitor); LineSymbolizer clone = (LineSymbolizer) visitor.getCopy(); assertEquals("4", clone.getPerpendicularOffset().evaluate(null, String.class)); }
@Test public void testNonIntegerStroke() { Style style = sb.createStyle(sb.createLineSymbolizer(sb.createStroke(10.8))); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(style); assertEquals(11, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
@Test public void testRescaleLocalPixelInPixelSymbolizer() throws Exception { Stroke stroke = sb.createStroke(Color.RED, 2, new float[] {5, 10}); stroke.setWidth(ff.literal("2px")); LineSymbolizer ls = sb.createLineSymbolizer(stroke); ls.accept(visitor); LineSymbolizer clone = (LineSymbolizer) visitor.getCopy(); assertEquals("4", clone.getStroke().getWidth().evaluate(null, String.class)); }
@Test public void testNpePreventionStroke() { Style style = sb.createStyle( sb.createLineSymbolizer( sb.createStroke( sb.colorExpression(Color.BLACK), sb.literalExpression(null)))); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(style); assertEquals(1, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
@Test public void testRescaleLocalPixelInMetersSymbolizer() throws Exception { Stroke stroke = sb.createStroke(Color.RED, 2, new float[] {5, 10}); stroke.setWidth(ff.literal("2px")); LineSymbolizer ls = sb.createLineSymbolizer(stroke); ls.setUnitOfMeasure(SI.METRE); ls.accept(visitor); LineSymbolizer clone = (LineSymbolizer) visitor.getCopy(); assertEquals("4px", clone.getStroke().getWidth().evaluate(null, String.class)); }
@Test public void testLiteralParseStroke() { Style style = sb.createStyle( sb.createLineSymbolizer( sb.createStroke( sb.colorExpression(Color.BLACK), sb.literalExpression("10.0")))); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(style); assertEquals(10, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
@Test public void testMultiSymbolizers() { Symbolizer ls = sb.createLineSymbolizer(sb.createStroke(10.8)); Symbolizer ps = sb.createPolygonSymbolizer(sb.createStroke(12), sb.createFill()); Rule r = sb.createRule(new Symbolizer[] {ls, ps}); MetaBufferEstimator rbe = new MetaBufferEstimator(); rbe.visit(r); assertEquals(12, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
@Test public void testMath() { Add add = ff.add(ff.literal("5"), ff.literal("-2")); Symbolizer ls = sb.createLineSymbolizer(sb.createStroke(sb.colorExpression(Color.BLACK), add)); Rule r = sb.createRule(new Symbolizer[] {ls}); MetaBufferEstimator rbe = new MetaBufferEstimator(); // 5-2 = 3 rbe.visit(r); assertEquals(3, rbe.getBuffer()); assertTrue(rbe.isEstimateAccurate()); }
@Test public void testFeatureBound() throws Exception { StyleBuilder sb = new StyleBuilder(); LineSymbolizer ls = sb.createLineSymbolizer(Color.BLUE); ls.getStroke().setWidth(ff.multiply(ff.literal(2), ff.property("flow"))); Style style = sb.createStyle(ls); MetaBufferEstimator estimator = new MetaBufferEstimator(riverFeatures[0]); style.accept(estimator); assertTrue(estimator.isEstimateAccurate()); assertEquals(9, estimator.getBuffer()); } }