/** * create a fill of color * * @param fillColor the color of the fill * @return the fill created */ public Fill createFill(Color fillColor) { return createFill(colorExpression(fillColor)); }
/** * create a polygon symbolizer * * @param fillColor - the color to fill the polygon * @return the new polygon symbolizer */ public PolygonSymbolizer createPolygonSymbolizer(Color fillColor) { return createPolygonSymbolizer(null, createFill(fillColor)); }
/** * create a textsymbolizer which doesn't change * * @param color the color of the text * @param font the font to use * @param label the label to use * @return the new textsymbolizer */ public TextSymbolizer createStaticTextSymbolizer(Color color, Font font, String label) { return createTextSymbolizer( createFill(color), new Font[] {font}, null, literalExpression(label), null, null); }
/** * wrapper round StyleFactory method to create default halo * * @return the new halo */ public Halo createHalo() { return sf.createHalo(createFill(Color.WHITE), literalExpression(1)); }
/** * create a textsymbolizer which doesn't change * * @param color the color of the text * @param fonts an array of fonts to use from the first to last * @param label the label to use * @return the new textsymbolizer */ public TextSymbolizer createStaticTextSymbolizer(Color color, Font[] fonts, String label) { return createTextSymbolizer( createFill(color), fonts, null, literalExpression(label), null, null); }
/** * create a textsymbolizer * * @param color the color of the text * @param fonts an array of fonts to use from the first to last * @param attributeName the attribute to use for the label * @return the new textsymbolizer * @throws org.geotools.filter.IllegalFilterException - if the attribute name does not exist */ public TextSymbolizer createTextSymbolizer(Color color, Font[] fonts, String attributeName) throws org.geotools.filter.IllegalFilterException { return createTextSymbolizer( createFill(color), fonts, null, attributeExpression(attributeName), null, null); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Color color = (Color) value; TextSymbolizer textSymbolizer = sb.createTextSymbolizer(); textSymbolizer.setFill(sb.createFill(color)); return textSymbolizer; } }
/** * wrapper round StyleFactory method to create halo * * @param color - the color of the halo * @param radius - the width of the halo * @return the new halo */ public Halo createHalo(Color color, double radius) { return sf.createHalo(createFill(color), literalExpression(radius)); }
/** * wrapper round StyleFactory method to create halo * * @param color - the color of the halo * @param opacity - the opacity of the halo fill 0 - transparent 1 - solid * @param radius - the width of the halo * @return the new halo */ public Halo createHalo(Color color, double opacity, double radius) { return sf.createHalo(createFill(color, opacity), literalExpression(radius)); }
/** * create a polygon symbolizer * * @param fillColor - the color to fill the polygon * @param borderColor - the outline color of the polygon * @param borderWidth - the width of the outline * @return the new polygon symbolizer */ public PolygonSymbolizer createPolygonSymbolizer( Color fillColor, Color borderColor, double borderWidth) { return createPolygonSymbolizer( createStroke(borderColor, borderWidth), createFill(fillColor)); }
/** * create a textsymbolizer * * @param color the color of the text * @param font the font to use * @param attributeName the attribute to use for the label * @return the new textsymbolizer * @throws org.geotools.filter.IllegalFilterException - if the attribute name does not exist */ public TextSymbolizer createTextSymbolizer(Color color, Font font, String attributeName) throws org.geotools.filter.IllegalFilterException { return createTextSymbolizer( createFill(color), new Font[] {font}, null, attributeExpression(attributeName), null, null); }
/** * create a default polygon symbolizer * * @return the new polygon symbolizer */ public PolygonSymbolizer createPolygonSymbolizer() { PolygonSymbolizer ps = sf.createPolygonSymbolizer(); ps.setFill(createFill()); ps.setStroke(createStroke()); return ps; }
/** * Creates a default text symbolizer. Warning: there is no definition of a default text * symbolizer in the SLD standard, this is provided just for convenience and uniformity with the * other symbolizers * * @return the default text symbolizer */ public TextSymbolizer createTextSymbolizer() { TextSymbolizer ts = sf.createTextSymbolizer(); ts.setFill(createFill(Color.BLACK)); ts.setLabel(literalExpression("Label")); ts.fonts().add(createFont("Lucida Sans", 10)); return ts; }
/** * create a mark of the supplied color and a default outline (black) * * @param wellKnownName the well known name of the mark * @param fillColor the color of the mark * @return the created mark */ public Mark createMark(String wellKnownName, Color fillColor) { Mark mark = sf.createMark(); mark.setWellKnownName(literalExpression(wellKnownName)); mark.setFill(createFill(fillColor, 1.0)); mark.setStroke(null); return mark; }
/** * create the named mark with the colors etc supplied * * @param wellKnownName the well known name of the mark * @param fillColor the color of the mark * @param borderColor the outline color of the mark * @param borderWidth the width of the outline * @return the mark created */ public Mark createMark( String wellKnownName, Color fillColor, Color borderColor, double borderWidth) { Mark mark = sf.createMark(); mark.setWellKnownName(literalExpression(wellKnownName)); mark.setStroke(createStroke(borderColor, borderWidth)); mark.setFill(createFill(fillColor)); return mark; }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Color color = (Color) value; PolygonSymbolizer poly = sb.createPolygonSymbolizer(); Boolean fill = (Boolean) node.getChildValue("fill", Boolean.TRUE); Boolean outline = (Boolean) node.getChildValue("outline", Boolean.TRUE); if (fill) { poly.setFill(sb.createFill(color)); } else { poly.setFill(null); } if (outline) { poly.setStroke(sb.createStroke()); } else { poly.setStroke(null); } return poly; } }
@Test public void testVisitPolygonSymbolizer_NullStroke() { try { UomRescaleStyleVisitor visitor = null; StyleBuilder styleBuilder = new StyleBuilder(); Fill fill = styleBuilder.createFill(Color.RED); PolygonSymbolizerImpl polySymb = (PolygonSymbolizerImpl) styleBuilder.createPolygonSymbolizer(null, fill); visitor = new UomRescaleStyleVisitor(10); polySymb.accept(visitor); PolygonSymbolizer rescaledPolySymb = (PolygonSymbolizer) visitor.getCopy(); assertEquals(polySymb.getFill(), rescaledPolySymb.getFill()); assertNull(rescaledPolySymb.getStroke()); assertNotSame(rescaledPolySymb, polySymb); } catch (Exception e2) { java.util.logging.Logger.getGlobal().log(java.util.logging.Level.INFO, "", e2); fail(e2.getClass().getSimpleName() + " should not be thrown."); } }
@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 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 testPropertyWidth() { Symbolizer ls = sb.createLineSymbolizer( sb.createStroke( sb.colorExpression(Color.BLACK), sb.attributeExpression("gimbo"))); 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()); }