/** * Sets the colour for the first polygon symbolizer defined in the provided style * * @param style the Style object * @param colour the colour for polygon outlines and fill */ public static void setPolyColour(Style style, Color colour) { if (style == null) { return; } setPolyColour(polySymbolizer(style), colour); }
@Test public void testPolygonSimple() throws Exception { // <UserStyle> // <Title>SLD Cook Book: Simple polygon</Title> // <FeatureTypeStyle> // <Rule> // <PolygonSymbolizer> // <Fill> // <CssParameter name="fill">#000080</CssParameter> // </Fill> // </PolygonSymbolizer> // </Rule> // </FeatureTypeStyle> // </UserStyle> Style style = parse("poly", "simple.sld"); PolygonSymbolizer poly = SLD.polySymbolizer(style); assertEquals(color("000080"), SLD.color(poly.getFill())); }
/** * Sets the colour for a polygon symbolizer * * @param style * @param colour */ public static void setPolyColour(Style style, Color colour) { if (style == null) { return; } setPolyColour(polySymbolizer(style), colour); }
/** * Sets the colour for the first polygon symbolizer defined in * the provided style * * @param style the Style object * @param colour the colour for polygon outlines and fill */ public static void setPolyColour(Style style, Color colour) { if (style == null) { return; } setPolyColour(polySymbolizer(style), colour); }
PolygonSymbolizer poly = SLD.polySymbolizer(style); Graphic g = poly.getFill().getGraphicFill();
@Test public void testPolygonWithStroke() throws Exception { // <UserStyle> // <Title>SLD Cook Book: Simple polygon with stroke</Title> // <FeatureTypeStyle> // <Rule> // <PolygonSymbolizer> // <Fill> // <CssParameter name="fill">#000080</CssParameter> // </Fill> // <Stroke> // <CssParameter name="stroke">#FFFFFF</CssParameter> // <CssParameter name="stroke-width">2</CssParameter> // </Stroke> // </PolygonSymbolizer> // </Rule> // </FeatureTypeStyle> // </UserStyle> Style style = parse("poly", "stroke.sld"); PolygonSymbolizer poly = SLD.polySymbolizer(style); assertEquals(color("000080"), SLD.color(poly.getFill())); assertEquals(color("FFFFFF"), SLD.color(poly.getStroke())); assertEquals(2, SLD.width(poly.getStroke())); }
@Test public void testPolygonWithTransparent() throws Exception { // <UserStyle> // <Title>SLD Cook Book: Transparent polygon</Title> // <FeatureTypeStyle> // <Rule> // <PolygonSymbolizer> // <Fill> // <CssParameter name="fill">#000080</CssParameter> // <CssParameter name="fill-opacity">0.5</CssParameter> // </Fill> // <Stroke> // <CssParameter name="stroke">#FFFFFF</CssParameter> // <CssParameter name="stroke-width">2</CssParameter> // </Stroke> // </PolygonSymbolizer> // </Rule> // </FeatureTypeStyle> // </UserStyle> Style style = parse("poly", "transparent.sld"); PolygonSymbolizer poly = SLD.polySymbolizer(style); assertEquals(color("000080"), SLD.color(poly.getFill())); assertEquals(0.5, SLD.opacity(poly.getFill()), 0.1); assertEquals(color("FFFFFF"), SLD.color(poly.getStroke())); assertEquals(2, SLD.width(poly.getStroke())); }
PolygonSymbolizer poly = SLD.polySymbolizer(style); assertEquals(color("40FF40"), SLD.color(poly.getFill())); assertEquals(color("FFFFFF"), SLD.color(poly.getStroke()));
PolygonSymbolizer poly = SLD.polySymbolizer(style);
PolygonSymbolizer poly = SLD.polySymbolizer(style); assertEquals(color("40FF40"), SLD.color(poly.getFill())); assertEquals(color("FFFFFF"), SLD.color(poly.getStroke()));
PolygonSymbolizer poly = SLD.polySymbolizer(style); assertEquals(color("40FF40"), SLD.color(poly.getFill())); assertEquals(color("FFFFFF"), SLD.color(poly.getStroke()));
@Test public void testParseThroughStyles() throws IOException { String css = "* { fill: lightgrey; }"; StyledLayerDescriptor sld = Styles.handler(CssHandler.FORMAT).parse(css, null, null, null); assertNotNull(sld); PolygonSymbolizer ps = SLD.polySymbolizer(Styles.style(sld)); assertNotNull(ps); } }