sym = rs; } else { Mark mark = styleFactory.createMark(); mark.setFill(styleFactory.createFill(filterFactory.literal(color)));
/** * create the named mark * * @param wellKnownName the wellknown name of the mark * @return the mark created */ public Mark createMark(String wellKnownName) { Mark mark = sf.createMark(); mark.setWellKnownName(literalExpression(wellKnownName)); return mark; }
protected MarkParser(Factory factory) { super(factory); mark = factory.style.createMark(); mark.setStroke(null); mark.setFill(null); }
/** * create a mark with the supplied fill and stroke * * @param wellKnownName an Expression representing the well known name of the mark * @param fill the fill to use * @param stroke the stroke to use * @return the mark created */ public Mark createMark(Expression wellKnownName, Fill fill, Stroke stroke) { Mark mark = sf.createMark(); mark.setWellKnownName(wellKnownName); mark.setStroke(stroke); mark.setFill(fill); return mark; }
Mark mark = factory.createMark(); mark.setFill(null); mark.setStroke(null);
/** * create a mark with default fill (50% gray) and the supplied outline * * @param wellKnownName the well known name of the mark * @param borderColor the outline color * @param borderWidth the outline width * @return the mark created */ public Mark createMark(String wellKnownName, Color borderColor, double borderWidth) { Mark mark = sf.createMark(); mark.setWellKnownName(literalExpression(wellKnownName)); mark.setStroke(createStroke(borderColor, borderWidth)); return mark; }
/** * create a mark with the supplied fill and stroke * * @param wellKnownName the well known name of the mark * @param fill the fill to use * @param stroke the stroke to use * @return the mark created */ public Mark createMark(String wellKnownName, Fill fill, Stroke stroke) { Mark mark = sf.createMark(); mark.setWellKnownName(literalExpression(wellKnownName)); mark.setStroke(stroke); mark.setFill(fill); return mark; }
public void visit(Mark mark) { Mark copy = null; copy = sf.createMark(); copy.setFill(copy(mark.getFill())); copy.setStroke(copy(mark.getStroke())); copy.setWellKnownName(copy(mark.getWellKnownName())); copy.setExternalMark(copy(mark.getExternalMark())); if (STRICT && !copy.equals(mark)) { throw new IllegalStateException("Was unable to duplicate provided Mark:" + mark); } pages.push(copy); }
/** * create a mark of the supplied color and a default outline (black) * * @param wellKnownName the well known name of the mark * @param fillColor the color of the mark * @return the created mark */ public Mark createMark(String wellKnownName, Color fillColor) { Mark mark = sf.createMark(); mark.setWellKnownName(literalExpression(wellKnownName)); mark.setFill(createFill(fillColor, 1.0)); mark.setStroke(null); return mark; }
Fill fill = (Fill) node.getChildValue("Fill"); Mark mark = styleFactory.createMark();
/** * create the named mark with the colors etc supplied * * @param wellKnownName the well known name of the mark * @param fillColor the color of the mark * @param borderColor the outline color of the mark * @param borderWidth the width of the outline * @return the mark created */ public Mark createMark( String wellKnownName, Color fillColor, Color borderColor, double borderWidth) { Mark mark = sf.createMark(); mark.setWellKnownName(literalExpression(wellKnownName)); mark.setStroke(createStroke(borderColor, borderWidth)); mark.setFill(createFill(fillColor)); return mark; }
public void testCreateIncompletePointStyle() { PointSymbolizer symb; Mark myMark; // full symbolizer symb = sf.createPointSymbolizer(); myMark = sf.createMark(); symb.getGraphic().addMark(myMark); sld.createPointStyle(null, symb, range); }
public void testCreateDynamicMark() throws Exception { PointSymbolizer symb = sf.createPointSymbolizer(); Mark myMark = sf.createMark(); final String ttfUrl = "ttf://Serif#${symb}"; myMark.setWellKnownName(ff.literal(ttfUrl)); symb.getGraphic().addMark(myMark); MarkStyle2D ms = (MarkStyle2D) sld.createStyle(feature, symb, range); assertNotNull(ms.getShape()); // make sure the style has been recognized as dynamic SymbolizerKey key = new SymbolizerKey(symb, range); assertTrue(sld.dynamicSymbolizers.containsKey(key)); Shape expected = new TTFMarkFactory().getShape(null, ff.literal("ttf://Serif#0xF054"), feature); // no general path equality implemented, we have to check manually PathIterator piExpected = expected.getPathIterator(new AffineTransform()); PathIterator pi = ms.getShape().getPathIterator(new AffineTransform()); double[] coordsExpected = new double[6]; double[] coords = new double[6]; assertEquals(piExpected.getWindingRule(), pi.getWindingRule()); while (!piExpected.isDone()) { assertFalse(pi.isDone()); piExpected.currentSegment(coordsExpected); pi.currentSegment(coords); assertEquals(coordsExpected[0], coords[0], 0.00001); assertEquals(coordsExpected[1], coords[1], 0.00001); piExpected.next(); pi.next(); } assertTrue(pi.isDone()); }
public void testDefaultSizeMark() throws Exception { PointSymbolizer symb = sf.createPointSymbolizer(); Mark myMark = sf.createMark(); myMark.setWellKnownName(ff.literal("square")); symb.getGraphic().addMark(myMark); MarkStyle2D ms = (MarkStyle2D) sld.createPointStyle(feature, symb, range); assertEquals(16.0, ms.getSize()); }
public void testMarkSizeCalculation() throws Exception { assertFalse(MarkStyle2D.isMaxMarkSizeEnabled()); PointSymbolizer symb = sf.createPointSymbolizer(); Mark myMark = sf.createMark(); myMark.setWellKnownName(ff.literal("square")); symb.getGraphic().graphicalSymbols().add(myMark); MarkStyle2D ms = (MarkStyle2D) sld.createPointStyle(feature, symb, range); assertFalse(MarkStyle2D.isMaxMarkSizeEnabled()); MarkStyle2D.setMaxMarkSizeEnabled(true); ms = (MarkStyle2D) sld.createPointStyle(feature, symb, range); assertTrue(MarkStyle2D.isMaxMarkSizeEnabled()); }
public void testExternalMark() throws URISyntaxException { OnLineResourceImpl or = new OnLineResourceImpl(); or.setLinkage(new URI("ttf://wingdings")); ExternalMark externalMark = sf.externalMark(or, "ttf", 15); Mark mark = sf.createMark(); mark.setExternalMark(externalMark); Mark clone = visitor.copy(mark); assertCopy(mark, clone); assertCopy(mark.getExternalMark(), clone.getExternalMark()); ExternalMark emCopy = clone.getExternalMark(); assertEquals("ttf", emCopy.getFormat()); assertEquals("ttf://wingdings", emCopy.getOnlineResource().getLinkage().toASCIIString()); assertEquals(15, emCopy.getMarkIndex()); }
public void testTexturePaintNoSize() throws Exception { PolygonSymbolizer symb = sf.createPolygonSymbolizer(); Mark myMark = sf.createMark(); myMark.setWellKnownName(ff.literal("square")); org.geotools.styling.Fill fill = sf.createFill(null); fill.setGraphicFill(sf.createGraphic(null, new Mark[] {myMark}, null, null, null, null)); symb.setFill(fill); PolygonStyle2D ps = sld.createPolygonStyle(feature, symb, range); assertTrue(ps.getFill() instanceof TexturePaint); }
@Test public void testNameExpressionAttribute() throws Exception { PointSymbolizer p = CommonFactoryFinder.getStyleFactory().createPointSymbolizer(); Expression nameExpression = CommonFactoryFinder.getFilterFactory2().property("test"); Mark mark = CommonFactoryFinder.getStyleFactory().createMark(); mark.setWellKnownName(nameExpression); p.getGraphic().graphicalSymbols().add(mark); StringWriter out = new StringWriter(); Ysld.encode(sld(p), out); YamlMap obj = new YamlMap(YamlUtil.getSafeYaml().load(out.toString())); String result = obj.seq("feature-styles") .map(0) .seq("rules") .map(0) .seq("symbolizers") .map(0) .map("point") .seq("symbols") .map(0) .map("mark") .str("shape"); assertThat(result, equalTo("${test}")); }
@Test public void testNameExpressionLiteral() throws Exception { PointSymbolizer p = CommonFactoryFinder.getStyleFactory().createPointSymbolizer(); Expression nameExpression = CommonFactoryFinder.getFilterFactory2().literal("test"); Mark mark = CommonFactoryFinder.getStyleFactory().createMark(); mark.setWellKnownName(nameExpression); p.getGraphic().graphicalSymbols().add(mark); StringWriter out = new StringWriter(); Ysld.encode(sld(p), out); YamlMap obj = new YamlMap(YamlUtil.getSafeYaml().load(out.toString())); String result = obj.seq("feature-styles") .map(0) .seq("rules") .map(0) .seq("symbolizers") .map(0) .map("point") .seq("symbols") .map(0) .map("mark") .str("shape"); assertThat(result, equalTo("test")); }
/** Test of createPointStyle method, of class org.geotools.renderer.style.SLDStyleFactory. */ public void testCreateCompletePointStyle() { PointSymbolizer symb; Mark myMark; // full symbolizer symb = sf.createPointSymbolizer(); myMark = sf.createMark(); myMark.setFill(sf.createFill(ff.literal("#ffff00"))); symb.getGraphic().setSize(ff.literal(10)); symb.getGraphic().addMark(myMark); symb.getGraphic().setOpacity(ff.literal(1)); symb.getGraphic().setRotation(ff.literal(0)); sld.createPointStyle(null, symb, range); }