/** * 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(); }
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); }
public void visit(Mark mark) { start("Mark"); if (mark.getWellKnownName() != null && (!"square".equals(mark.getWellKnownName().evaluate(null)) || isExportDefaultValues())) { encodeValue("WellKnownName", null, mark.getWellKnownName(), null); } if (mark.getFill() != null) { mark.getFill().accept(this); } if (mark.getStroke() != null) { mark.getStroke().accept(this); } end("Mark"); }
/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Mark) */ public void visit(Mark mark) { if (mark.getFill() != null) { mark.getFill().accept(this); } if (mark.getStroke() != null) { mark.getStroke().accept(this); } if (mark.getWellKnownName() != null) { if (mark.getWellKnownName() instanceof Literal) { visitCqlExpression(mark.getWellKnownName().evaluate(null, String.class)); } else { mark.getWellKnownName().accept(this, null); } } }
/** * Retrieves the fill from the first Mark defined in a PointSymbolizer. * * <p>If you are using something fun like symbols you will need to do your own thing. * * @param symbolizer Point symbolizer information. * @return Color of the point's fill, or null if unavailable. */ public static Color pointFill(PointSymbolizer symbolizer) { if (symbolizer == null) { return null; } Graphic graphic = symbolizer.getGraphic(); if (graphic == null) { return null; } for (GraphicalSymbol gs : graphic.graphicalSymbols()) { if (gs != null && gs instanceof Mark) { Mark mark = (Mark) gs; Fill fill = mark.getFill(); if (fill != null) { Color colour = color(fill.getColor()); if (colour != null) { return colour; } } } } return null; }
/** * Retrieves the point opacity from a PointSymbolizer. * * <p>If you are using something fun like rules you will need to do your own thing. * * @param symbolizer Point symbolizer information. * @return double of the point's opacity, or NaN if unavailable. */ public static double pointOpacity(PointSymbolizer symbolizer) { if (symbolizer == null) { return Double.NaN; } Graphic graphic = symbolizer.getGraphic(); if (graphic == null) { return Double.NaN; } for (GraphicalSymbol gs : graphic.graphicalSymbols()) { if (gs != null && gs instanceof Mark) { Mark mark = (Mark) gs; Fill fill = mark.getFill(); if (fill != null) { Expression expr = fill.getOpacity(); if (expr != null) { return SLD.opacity(expr); } } } } return Double.NaN; }
SymbolsEncoder encode(Mark mark) { putName("shape", mark.getWellKnownName()); inline(new StrokeEncoder(mark.getStroke())); inline(new FillEncoder(mark.getFill())); // encode("stroke", new StrokeEncoder(mark.getStroke())); // encode("fill", mark.getFill()); // url: // inline: return this; }
MarkStyle2D createMarkStyle(Mark mark, Object feature, Symbolizer symbolizer, double size) { Shape shape = getShape(mark, feature); if (shape == null) { throw new IllegalArgumentException( "The specified mark " + mark.getWellKnownName() + " was not found!"); } Composite composite = getComposite(symbolizer.getOptions()); MarkStyle2D ms2d = new MarkStyle2D(); ms2d.setShape(shape); ms2d.setFill(getPaint(mark.getFill(), feature, symbolizer)); ms2d.setFillComposite( composite != null ? composite : getComposite(mark.getFill(), feature)); ms2d.setStroke(getStroke(mark.getStroke(), feature)); ms2d.setContour(getStrokePaint(mark.getStroke(), feature)); ms2d.setContourComposite( composite != null ? composite : getStrokeComposite(mark.getStroke(), feature)); // in case of Mark we don't have a natural size, so we default // to 16 if (size <= 0) { size = DEFAULT_MARK_SIZE; } ms2d.setSize(size); return ms2d; }
/** * Sets the Colour for the given point symbolizer * * @param symbolizer the point symbolizer * @param colour the new colour */ public static void setPointColour(PointSymbolizer symbolizer, Color colour) { if (symbolizer == null || colour == null) { return; } Graphic graphic = symbolizer.getGraphic(); if (graphic == null) { graphic = sf.createDefaultGraphic(); } for (GraphicalSymbol gs : graphic.graphicalSymbols()) { if (gs != null && gs instanceof Mark) { Mark mark = (Mark) gs; Stroke stroke = mark.getStroke(); if (stroke == null) { stroke = sf.createStroke(ff.literal(Color.BLACK), Stroke.DEFAULT.getWidth()); mark.setStroke(stroke); } Fill fill = mark.getFill(); if (fill != null) { fill.setColor(ff.literal(colour)); } } } }
/** * 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(); }
private void rescale(Graphic graphic, Unit<Length> unit) { if (graphic != null) { graphic.setSize(rescale(graphic.getSize(), unit)); graphic.setGap(rescale(graphic.getGap(), unit)); Displacement disp = graphic.getDisplacement(); if (disp != null) { disp.setDisplacementX(rescale(disp.getDisplacementX(), unit)); disp.setDisplacementY(rescale(disp.getDisplacementY(), unit)); graphic.setDisplacement(disp); } if (graphic.graphicalSymbols() != null) { for (GraphicalSymbol gs : graphic.graphicalSymbols()) { if (gs instanceof Mark) { Mark mark = (Mark) gs; rescaleStroke(mark.getStroke(), unit); rescaleFill(mark.getFill(), unit); } } } } }
assertEquals(Color.red, SLD.color(mark.getFill())); assertEquals(Color.black, SLD.color(mark.getStroke())); assertEquals(2, SLD.width(mark.getStroke()));
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); }
assertEquals(color("666666"), SLD.color(mark.getFill())); assertEquals(color("333333"), SLD.color(mark.getStroke())); assertEquals(1, SLD.width(mark.getStroke()));
SymbolsEncoder encode(Mark mark) { putName("shape", mark.getWellKnownName()); inline(new StrokeEncoder(mark.getStroke())); inline(new FillEncoder(mark.getFill())); // encode("stroke", new StrokeEncoder(mark.getStroke())); // encode("fill", mark.getFill()); // url: // inline: return this; }
public void setEdited(Mark mk) { this.mark = mk; if (mark != null) { guiFill.setEdited(mark.getFill()); guiRotation.setExpression(mark.getRotation()); guiSize.setExpression(mark.getSize()); guiStroke.setEdited(mark.getStroke()); guiWKN.setExpression(mark.getWellKnownName()); } }