/** * Retrieves all filters defined in a style * * @param style the style * @return array of filters */ public static Filter[] filters(Style style) { Rule[] rule = rules(style); return filters(rule); }
return grid(Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW); Rule rule = SLD.rules(layer.getStyle())[0];
/** * Retrieves all filters defined in a style * * @param style the style * * @return array of filters */ public static Filter[] filters(Style style) { Rule[] rule = rules(style); return filters(rule); }
public static Filter[] filters(Style style) { Rule[] rule = rules(style); return filters(rule); }
@Test public void testLegend() throws Exception { String yaml = "feature-styles:\n" + "- rules:\n" + " - legend:\n" + " symbols:\n" + " - external:\n" + " url: smileyface.png\n" + " format: image/png\n" + " symbolizers:\n" + " - point:\n" + " symbols:\n" + " - mark:\n" + " shape: circle\n" + " fill-color: '#FF0000'"; StyledLayerDescriptor sld = Ysld.parse(yaml); Rule rule = SLD.rules(SLD.defaultStyle(sld))[0]; assertThat(rule.getLegend().graphicalSymbols().get(0), instanceOf(ExternalGraphic.class)); ExternalGraphic legend = (ExternalGraphic) rule.getLegend().graphicalSymbols().get(0); assertEquals(new URL("file:smileyface.png"), legend.getLocation()); assertEquals("image/png", legend.getFormat()); PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld)); assertEquals("circle", SLD.wellKnownName(SLD.mark(p))); assertEquals(Color.RED, SLD.color(SLD.fill(p))); }
public static Symbolizer[] symbolizers(Style style) { Set symbolizers = new HashSet(); Rule[] rule = rules(style); for (int i = 0; i < rule.length; i++) { Symbolizer[] symb = rule[i].getSymbolizers(); for (int j = 0; j < symb.length; j++) { symbolizers.add(symb[j]); } } if (symbolizers.size() > 0) { return toSymbolizerArray(symbolizers.toArray()); } else { return new Symbolizer[0]; } }
public static String[] colors(Style style) { Set colorSet = new HashSet(); Rule[] rule = rules(style); for (int i = 0; i < rule.length; i++) { String[] color = colors(rule[i]); for (int j = 0; j < color.length; j++) { colorSet.add(color[j]); } } if (colorSet.size() > 0) { return toStringArray(colorSet.toArray()); } else { return new String[0]; } }
GraphicLegend legend = (GraphicLegend) SLD.rules(style)[0].getLegend(); assertEquals(32, Filters.asInt(legend.getSize()));
LineSymbolizer line = (LineSymbolizer) SLD.rules(style)[0].symbolizers().get(0); assertEquals(Color.blue, SLD.color(line)); assertEquals(1, SLD.width(line)); assertEquals(10f, SLD.lineDash(line)[0], 0.1); line = (LineSymbolizer) SLD.rules(style)[0].symbolizers().get(1); Stroke stroke = line.getStroke();
return grid(Color.RED,Color.GREEN,Color.BLUE,Color.YELLOW); Rule rule = SLD.rules( layer.getStyle() )[0];