@Test public void testSEStyleWithRelativePathProtocol() throws IOException { StyleInfo si = getCatalog().getStyleByName("relative_protocol"); assertNotNull(si); Style style = si.getStyle(); PolygonSymbolizer ps = (PolygonSymbolizer) style.featureTypeStyles().get(0).rules().get(0).symbolizers().get(0); ExternalGraphic eg = (ExternalGraphic) ps.getFill().getGraphicFill().graphicalSymbols().get(0); URI uri = eg.getOnlineResource().getLinkage(); assertNotNull(uri); File actual = URLs.urlToFile(uri.toURL()).getCanonicalFile(); assertEquals(rockFillSymbolFile, actual); }
@Test public void testSEStyleWithRelativePath() throws IOException { StyleInfo si = getCatalog().getStyleByName("relative"); assertNotNull(si); Style style = si.getStyle(); PolygonSymbolizer ps = (PolygonSymbolizer) style.featureTypeStyles().get(0).rules().get(0).symbolizers().get(0); ExternalGraphic eg = (ExternalGraphic) ps.getFill().getGraphicFill().graphicalSymbols().get(0); URI uri = eg.getOnlineResource().getLinkage(); assertNotNull(uri); File actual = URLs.urlToFile(uri.toURL()).getCanonicalFile(); assertEquals(rockFillSymbolFile, actual); }
@Override public void visit(Fill fill) { if (fill.getGraphicFill() != null) { fill.getGraphicFill().accept(this); } }
private void rescaleFill(Fill copyFill, Unit<Length> unit) { // rescale the graphic fill, if any if (copyFill != null) { rescale(copyFill.getGraphicFill(), unit); } }
LOGGER.finest("fill graphic " + fill.getGraphicFill());
protected Paint getPaint(Fill fill, Object feature, Symbolizer symbolizer) { if (fill == null) { return null; } // get fill color Paint fillPaint = evalToColor(fill.getColor(), feature, null); // if a graphic fill is to be used, prepare the paint accordingly.... org.geotools.styling.Graphic gr = fill.getGraphicFill(); if (gr != null && gr.graphicalSymbols() != null && gr.graphicalSymbols().size() > 0) { fillPaint = getTexturePaint(gr, feature, symbolizer); } return fillPaint; }
@Override protected void encode(Fill fill) { putColor("fill-color", fill.getColor()); put("fill-opacity", nullIf(fill.getOpacity(), 1d)); if (fill.getGraphicFill() != null) { push("fill-graphic").inline(new GraphicEncoder(fill.getGraphicFill())); } } }
public void visit(Fill fill) { start("Fill"); if (fill.getGraphicFill() != null) { start("GraphicFill"); fill.getGraphicFill().accept(this); end("GraphicFill"); } encodeCssParam("fill", fill.getColor(), "#808080"); encodeCssParam("fill-opacity", fill.getOpacity(), 1.0); end("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); }
/** Computes and returns the fill based on the feature and the symbolizer */ public java.awt.Paint getFill() { Fill fill = ps.getFill(); if (fill == null) { return null; } Paint fillPaint = (Color) fill.getColor().evaluate(feature, Color.class); // if a graphic fill is to be used, prepare the paint accordingly.... org.geotools.styling.Graphic gr = fill.getGraphicFill(); if (gr != null) { SLDStyleFactory fac = new SLDStyleFactory(); fillPaint = fac.getTexturePaint(gr, feature, ps); } return fillPaint; }
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Fill) */ public void visit(Fill fill) { if (fill.getBackgroundColor() != null) { fill.getBackgroundColor().accept(this, null); } if (fill.getColor() != null) { fill.getColor().accept(this, null); } if (fill.getGraphicFill() != null) { fill.getGraphicFill().accept(this); } if (fill.getOpacity() != null) { fill.getOpacity().accept(this, null); } }
if (fill.getGraphicFill() != null) { double size = evalToDouble(fill.getGraphicFill().getSize(), feature, 0); if (isVectorRenderingEnabled() || size > MAX_RASTERIZATION_SIZE) { feature, symbolizer, fill.getGraphicFill(), scaleRange, false); if (!(style2DFill instanceof GraphicStyle2D)) { style.setGraphicFill(style2DFill);
private void rescaleFill(Fill copyFill, double mapScale, Unit<Length> unit) { // rescale the graphic fill, if any if (copyFill != null) { rescale(copyFill.getGraphicFill(), mapScale, unit); } }
Graphic g = poly.getFill().getGraphicFill();
@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)); } }
@Override public void visit(Fill fill) { if (fill.getColor() != null) { //fill.getColor().accept(visitor, extraData) } if (fill.getGraphicFill() != null) { fill.getGraphicFill().accept(this); } if (fill.getOpacity() != null) { //fill.getOpacity().accept(visitor, extraData) } }
Mark mark = SLD.mark(poly.getFill().getGraphicFill()); assertEquals("shape://times", Filters.asString(mark.getWellKnownName())); assertEquals(1, SLD.width(mark.getStroke())); assertEquals(16, Filters.asInt(poly.getFill().getGraphicFill().getSize()));
Mark rm = (Mark) rps.getStroke().getGraphicStroke().graphicalSymbols().get(0); assertEquals(10.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d); rm = (Mark) rps.getFill().getGraphicFill().graphicalSymbols().get(0); assertEquals(20.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);
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); }
Mark rm = (Mark) rps.getStroke().getGraphicStroke().graphicalSymbols().get(0); assertEquals(2.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d); rm = (Mark) rps.getFill().getGraphicFill().graphicalSymbols().get(0); assertEquals(4.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);