fill.setColor(parseCssParameter(child)); } else if (res.equalsIgnoreCase(opacityString) || res.equalsIgnoreCase("fill-opacity")) {
public Fill getDefaultFill() { Fill fill = new FillImpl(filterFactory); try { fill.setColor(filterFactory.literal("#808080")); fill.setOpacity(filterFactory.literal(new Double(1.0))); fill.setBackgroundColor(filterFactory.literal("#FFFFFF")); } catch (org.geotools.filter.IllegalFilterException ife) { throw new RuntimeException("Error creating fill", ife); } return fill; }
public void visit(Fill fill) { Fill copy = sf.getDefaultFill(); copy.setBackgroundColor(copy(fill.getBackgroundColor())); copy.setColor(copy(fill.getColor())); copy.setGraphicFill(copy(fill.getGraphicFill())); copy.setOpacity(copy(fill.getOpacity())); if (STRICT && !copy.equals(fill)) { throw new IllegalStateException("Was unable to duplicate provided Fill:" + fill); } pages.push(copy); }
/** * create a default fill 50% gray * * @return the fill created */ public Fill createFill() { Fill f = sf.getDefaultFill(); f.setColor(literalExpression("#808080")); f.setBackgroundColor(literalExpression("#808080")); f.setOpacity(literalExpression(1.0)); return f; }
public Fill createFill( Expression color, Expression backgroundColor, Expression opacity, Graphic graphicFill) { Fill fill = new FillImpl(filterFactory); if (color == null) { color = Fill.DEFAULT.getColor(); } fill.setColor(color); if (backgroundColor == null) { backgroundColor = Fill.DEFAULT.getBackgroundColor(); } fill.setBackgroundColor(backgroundColor); if (opacity == null) { opacity = Fill.DEFAULT.getOpacity(); } // would be nice to check if this was within bounds but we have to wait until use since it // may depend on an attribute fill.setOpacity(opacity); fill.setGraphicFill(graphicFill); return fill; }
/** * Sets the colour to use for outline (stroke) and fill in a polygon symbolizer * * @param symbolizer the polygon symbolizer * @param colour the colour for polygon outlines and fill */ public static void setPolyColour(PolygonSymbolizer symbolizer, Color colour) { if (symbolizer == null || colour == null) { return; } Expression colourExp = ff.literal(colour); Stroke stroke = symbolizer.getStroke(); if (stroke == null) { stroke = sf.createStroke(colourExp, Stroke.DEFAULT.getWidth()); symbolizer.setStroke(stroke); } else { stroke.setColor(ff.literal(colour)); } Fill fill = symbolizer.getFill(); if (fill != null) { fill.setColor(colourExp); } }
@Override public void handle(YamlObject<?> obj, YamlParseContext context) { YamlMap map = obj.map(); if (map.has("fill-color")) { fill().setColor(Util.color(map.get("fill-color"), factory)); } if (map.has("fill-opacity")) { fill().setOpacity(Util.expression(map.str("fill-opacity"), factory)); } context.push( "fill-graphic", new GraphicParser(factory) { @Override protected void graphic(Graphic g) { fill().setGraphicFill(g); } }); }
/** * Sets the Colour for the given point symbolizer * * @param symbolizer the point symbolizer * @param colour the new colour */ public static void setPointColour(PointSymbolizer symbolizer, Color colour) { if (symbolizer == null || colour == null) { return; } Graphic graphic = symbolizer.getGraphic(); if (graphic == null) { graphic = sf.createDefaultGraphic(); } for (GraphicalSymbol gs : graphic.graphicalSymbols()) { if (gs != null && gs instanceof Mark) { Mark mark = (Mark) gs; Stroke stroke = mark.getStroke(); if (stroke == null) { stroke = sf.createStroke(ff.literal(Color.BLACK), Stroke.DEFAULT.getWidth()); mark.setStroke(stroke); } Fill fill = mark.getFill(); if (fill != null) { fill.setColor(ff.literal(colour)); } } } }
private PolygonSymbolizer polysym(StyleFactory sFac) throws IllegalFilterException { Stroke myStroke; PolygonSymbolizer polysym = sFac.createPolygonSymbolizer(); Fill myFill = sFac.getDefaultFill(); myFill.setColor(filterFactory.literal("#ff0000")); polysym.setFill(myFill); myStroke = sFac.getDefaultStroke(); myStroke.setColor(filterFactory.literal("#0000ff")); myStroke.setWidth(filterFactory.literal(Integer.valueOf(2))); polysym.setStroke(myStroke); return polysym; }
private PolygonSymbolizer polysym1(StyleFactory sFac) throws IllegalFilterException { Stroke myStroke; PolygonSymbolizer polysym = sFac.createPolygonSymbolizer(); Fill myFill = sFac.getDefaultFill(); myFill.setColor(filterFactory.literal("#00ff00")); polysym.setFill(myFill); myStroke = sFac.getDefaultStroke(); myStroke.setColor(filterFactory.literal("#00ff00")); myStroke.setWidth(filterFactory.literal(Integer.valueOf(2))); polysym.setStroke(myStroke); return polysym; }
@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)); } }
private void init() { try { radius = filterFactory.literal(1); } catch (org.geotools.filter.IllegalFilterException ife) { LOGGER.severe("Failed to build defaultHalo: " + ife); } fill.setColor(filterFactory.literal("#FFFFFF")); // default halo is white }
/** * Creates a new instance of DefaultTextSymbolizer */ protected TextSymbolizerImpl( FilterFactory factory ) { this.filterFactory = factory; fill = new FillImpl(); fill.setColor(filterFactory.literal("#000000")); // default text fill is black halo = null; placement = new PointPlacementImpl(); }
@Override public void visit(Fill fill) { super.visit(fill); Fill copy = (Fill) pages.peek(); if (copy.getGraphicFill() != null) { copy.setGraphicFill(null); copy.setColor(sb.colorExpression(Color.BLACK)); } }
public Fill getDefaultFill() { Fill fill = new FillImpl(filterFactory); try { fill.setColor(filterFactory.literal("#808080")); fill.setOpacity(filterFactory.literal( new Double(1.0))); fill.setBackgroundColor(filterFactory.literal("#FFFFFF")); } catch (org.geotools.filter.IllegalFilterException ife) { throw new RuntimeException("Error creating fill", ife); } return fill; }
polysym.setGeometryPropertyName("polygon"); Fill myFill = sFac.getDefaultFill(); myFill.setColor(filterFactory.literal("#ff0000")); polysym.setFill(myFill); polysym.setStroke(sFac.getDefaultStroke());
fill.setColor(null); fill.setGraphicFill( sb.createGraphic(null, sb.createMark("square", null, sb.createStroke(2)), null));
public void visit(Fill fill) { Fill copy = sf.getDefaultFill(); copy.setBackgroundColor( copy( fill.getBackgroundColor()) ); copy.setColor(copy( fill.getColor())); copy.setGraphicFill( copy(fill.getGraphicFill())); copy.setOpacity( copy(fill.getOpacity())); if( STRICT && !copy.equals( fill )){ throw new IllegalStateException("Was unable to duplicate provided Fill:"+fill ); } pages.push(copy); }
fill.setColor(null); fill.setGraphicFill( sb.createGraphic(null, sb.createMark("square", null, sb.createStroke(2)), null));
/** * create a default fill 50% gray * * @return the fill created */ public Fill createFill() { Fill f = sf.getDefaultFill(); f.setColor(literalExpression("#808080")); f.setBackgroundColor(literalExpression("#808080")); f.setOpacity(literalExpression(1.0)); return f; }