/** * Retrieves the first Mark used in a PointSymbolizer object. * * @param sym the PointSymbolizer * @return the first Mark object or null if unavailable. */ public static Mark mark(PointSymbolizer sym) { return mark(graphic(sym)); }
/** * Retrieves the Fill from a PointSymbolizer. * * @param sym the symbolizer * @return the Fill or null if not found. */ public static Fill fill(PointSymbolizer sym) { Mark mark = mark(sym); return (mark == null) ? null : mark.getFill(); }
/** * Retrieves the Stroke from a PointSymbolizer. * * @param sym the symbolizer * @return the Stroke or null if not found. */ public static Stroke stroke(PointSymbolizer sym) { Mark mark = mark(sym); return (mark == null) ? null : mark.getStroke(); }
/** * Retrieves the first Mark used in a Style object. * * @param style the Style * @return the first Mark object or null if unavailable. */ public static Mark pointMark(Style style) { if (style == null) { return null; } return mark(pointSymbolizer(style)); }
void assertSLD(StyledLayerDescriptor sld) { assertNotNull(sld); PointSymbolizer point = SLD.pointSymbolizer(SLD.defaultStyle(sld)); assertNotNull(point); assertEquals("triangle", SLD.mark(point).getWellKnownName().evaluate(null)); } }
/** * Retrieves the first Mark used in a PointSymbolizer object. * * @param sym the PointSymbolizer * * @return the first Mark object or null if unavailable. */ public static Mark mark(PointSymbolizer sym) { return mark(graphic(sym)); }
/** * Retrieves the Fill from a PointSymbolizer. * @param sym the symbolizer * @return the Fill or null if not found. */ public static Fill fill(PointSymbolizer sym) { Mark mark = mark(sym); return (mark == null) ? null : mark.getFill(); }
/** * Retrieves the Stroke from a PointSymbolizer. * @param sym the symbolizer * @return the Stroke or null if not found. */ public static Stroke stroke(PointSymbolizer sym) { Mark mark = mark(sym); return (mark == null) ? null : mark.getStroke(); }
public static Mark pointMark(Style style) { if (style == null) { return null; } return mark(pointSymbolizer(style)); }
public static Mark mark(PointSymbolizer sym) { return mark(graphic(sym)); }
@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))); }
assertEquals("circle", SLD.wellKnownName(SLD.mark(point))); assertEquals(color("CC3300"), SLD.color(SLD.fill(point))); assertEquals(12, SLD.pointSize(point)); assertEquals("circle", SLD.wellKnownName(SLD.mark(point))); assertEquals(color("CC3300"), SLD.color(SLD.fill(point))); assertEquals(8, SLD.pointSize(point)); assertEquals("circle", SLD.wellKnownName(SLD.mark(point))); assertEquals(color("CC3300"), SLD.color(SLD.fill(point))); assertEquals(4, SLD.pointSize(point));
@Test public void testPointSimple() throws Exception { // <UserStyle> // <Title>SLD Cook Book: Simple Point With Stroke</Title> // <FeatureTypeStyle> // <Rule> // <PointSymbolizer> // <Graphic> // <Mark> // <WellKnownName>circle</WellKnownName> // <Fill> // <CssParameter name="fill">#FF0000</CssParameter> // </Fill> // </Mark> // <Size>6</Size> // </Graphic> // </PointSymbolizer> // </Rule> // </FeatureTypeStyle> // </UserStyle> Style style = parse("point", "simple.sld"); assertEquals("SLD Cook Book: Simple Point With Stroke", style.getTitle()); PointSymbolizer point = SLD.pointSymbolizer(style); assertEquals("circle", SLD.wellKnownName(SLD.mark(point))); assertEquals(1, point.getGraphic().graphicalSymbols().size()); assertEquals(Color.red, SLD.color(SLD.fill(point))); assertEquals(6, SLD.pointSize(point)); }
assertEquals("circle", SLD.wellKnownName(SLD.mark(point))); assertEquals(1, point.getGraphic().graphicalSymbols().size()); assertEquals(Color.red, SLD.color(SLD.fill(point)));
Mark mark = SLD.mark(g); assertEquals("shape://vertline", SLD.wellKnownName(mark)); assertEquals(color("333333"), SLD.color(mark.getStroke()));
@Test public void testPointWithRotation() throws Exception { // <UserStyle> // <Title>GeoServer SLD Cook Book: Rotated square</Title> // <FeatureTypeStyle> // <Rule> // <PointSymbolizer> // <Graphic> // <Mark> // <WellKnownName>square</WellKnownName> // <Fill> // <CssParameter name="fill">#009900</CssParameter> // </Fill> // </Mark> // <Size>12</Size> // <Rotation>45</Rotation> // </Graphic> // </PointSymbolizer> // </Rule> // </FeatureTypeStyle> // </UserStyle> Style style = parse("point", "rotated-square.sld"); PointSymbolizer point = SLD.pointSymbolizer(style); assertEquals("square", SLD.wellKnownName(SLD.mark(point))); assertEquals(color("009900"), SLD.color(SLD.fill(point))); assertEquals(12, SLD.pointSize(point)); assertEquals(45, Filters.asInt(SLD.graphic(point).getRotation())); }
assertEquals("triangle", SLD.wellKnownName(SLD.mark(point))); assertEquals(color("009900"), SLD.color(SLD.fill(point))); assertEquals(0.2, SLD.opacity(SLD.fill(point)), 0.1);
Mark mark = SLD.mark(poly.getFill().getGraphicFill()); assertEquals("shape://times", Filters.asString(mark.getWellKnownName()));
assertEquals(5, Filters.asInt(g.getSize())); Mark mark = SLD.mark(g); assertEquals("circle", SLD.wellKnownName(mark)); assertEquals(color("000033"), SLD.color(mark.getStroke()));
assertEquals(6f, SLD.lineDash(line)[1], 0.1); Mark mark = SLD.mark(line.getStroke().getGraphicStroke()); assertEquals("circle", SLD.wellKnownName(mark)); assertEquals(color("666666"), SLD.color(mark.getFill()));