@Override protected void fill(Fill fill) { mark.setFill(fill); } });
} else { Mark mark = styleFactory.createMark(); mark.setFill(styleFactory.createFill(filterFactory.literal(color)));
protected MarkParser(Factory factory) { super(factory); mark = factory.style.createMark(); mark.setStroke(null); mark.setFill(null); }
public Mark createMark( Expression wellKnownName, Stroke stroke, Fill fill, Expression size, Expression rotation) { Mark mark = new MarkImpl(filterFactory, null); if (wellKnownName == null) { throw new IllegalArgumentException("WellKnownName can not be null in mark"); } mark.setWellKnownName(wellKnownName); mark.setStroke(stroke); mark.setFill(fill); return mark; }
/** * 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; }
/** * 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; }
mark.setFill(fill);
public static Symbolizer[] getSymbolizers( Class<? extends Geometry> type, Color baseColor, boolean useTransparency) { StyleBuilder builder = new StyleBuilder(); Symbolizer[] syms = new Symbolizer[1]; if (LineString.class.isAssignableFrom(type) || MultiLineString.class.isAssignableFrom(type)) syms[0] = builder.createLineSymbolizer(baseColor, 2); if (Point.class.isAssignableFrom(type) || MultiPoint.class.isAssignableFrom(type)) { PointSymbolizer point = builder.createPointSymbolizer(builder.createGraphic()); // set graphic size to 10 by default point.getGraphic() .setSize( (Expression) CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints()) .literal(10)); // danger assumes a Mark! point.getGraphic().getMarks()[0].setFill(builder.createFill(baseColor)); syms[0] = point; } if (Polygon.class.isAssignableFrom(type) || MultiPolygon.class.isAssignableFrom(type)) { syms[0] = builder.createPolygonSymbolizer( builder.createStroke(baseColor, 2), builder.createFill(baseColor, useTransparency ? .6 : 1.0)); } return syms; }
/** * 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; }
@Override protected void fill(Fill fill) { mark.setFill(fill); } });
/** * getValue ... * * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element, * org.geotools.xml.schema.ElementValue[], org.xml.sax.Attributes, java.util.Map) * @param element * @param value * @param attrs1 * @param hints * @throws OperationNotSupportedException */ public Object getValue( Element element, ElementValue[] value, Attributes attrs1, Map hints) { Mark symbol = StyleFactoryFinder.createStyleFactory().getDefaultMark(); for (int i = 0; i < value.length; i++) { if ((value[i] == null) || value[i].getElement() == null) { continue; } Element e = value[i].getElement(); if (elems[WELLKNOWNNAME].getName().equals(e.getName())) symbol.setWellKnownName((Expression) value[i].getValue()); if (elems[FILL].getName().equals(e.getName())) symbol.setFill((Fill) value[i].getValue()); if (elems[STROKE].getName().equals(e.getName())) symbol.setStroke((Stroke) value[i].getValue()); } return symbol; } }
@Test public void testScientificNotationCase() throws Exception { PointSymbolizer p = CommonFactoryFinder.getStyleFactory().createPointSymbolizer(); Mark m1 = CommonFactoryFinder.getStyleFactory().getCircleMark(); m1.setFill( CommonFactoryFinder.getStyleFactory() .createFill( CommonFactoryFinder.getFilterFactory2().literal("#112233"), CommonFactoryFinder.getFilterFactory2() .literal(Double.MIN_NORMAL))); p.getGraphic().graphicalSymbols().add(m1); StringWriter out = new StringWriter(); Ysld.encode(sld(p), out); System.out.append(out.toString()); YamlMap obj = new YamlMap(YamlUtil.getSafeYaml().load(out.toString())); YamlMap result = obj.seq("feature-styles") .map(0) .seq("rules") .map(0) .seq("symbolizers") .map(0) .map("point") .seq("symbols") .map(0) .map("mark"); assertThat( kvpLine(out.toString(), "fill-opacity"), equalTo(Double.toString(Double.MIN_NORMAL).toUpperCase())); }
@Test public void testColourCase() throws Exception { PointSymbolizer p = CommonFactoryFinder.getStyleFactory().createPointSymbolizer(); Mark m1 = CommonFactoryFinder.getStyleFactory().getCircleMark(); m1.setFill( CommonFactoryFinder.getStyleFactory() .createFill( CommonFactoryFinder.getFilterFactory2().literal("#abcdef"), CommonFactoryFinder.getFilterFactory2() .literal(Double.MIN_NORMAL))); p.getGraphic().graphicalSymbols().add(m1); StringWriter out = new StringWriter(); Ysld.encode(sld(p), out); System.out.append(out.toString()); YamlMap obj = new YamlMap(YamlUtil.getSafeYaml().load(out.toString())); YamlMap result = obj.seq("feature-styles") .map(0) .seq("rules") .map(0) .seq("symbolizers") .map(0) .map("point") .seq("symbols") .map(0) .map("mark"); assertThat(kvpLine(out.toString(), "fill-color"), equalTo("'#ABCDEF'")); }
m1.setFill( CommonFactoryFinder.getStyleFactory() .createFill(CommonFactoryFinder.getFilterFactory2().literal("#112233")));
public Mark createMark(Expression wellKnownName, Stroke stroke, Fill fill, Expression size, Expression rotation) { Mark mark = new MarkImpl(filterFactory, null); if (wellKnownName == null) { throw new IllegalArgumentException( "WellKnownName can not be null in mark"); } mark.setWellKnownName(wellKnownName); mark.setStroke(stroke); mark.setFill(fill); return mark; }
/** 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); }
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() )); if( STRICT && !copy.equals( mark )){ throw new IllegalStateException("Was unable to duplicate provided Mark:"+mark ); } pages.push(copy); }