ps.setGraphic(styleFactory.createDefaultGraphic()); ps.getGraphic().graphicalSymbols().add(mark);
public void visit(Graphic gr) { Graphic copy = null; Displacement displacementCopy = copy(gr.getDisplacement()); ExternalGraphic[] externalGraphicsCopy = copy(gr.getExternalGraphics()); Mark[] marksCopy = copy(gr.getMarks()); Expression opacityCopy = copy(gr.getOpacity()); Expression rotationCopy = copy(gr.getRotation()); Expression sizeCopy = copy(gr.getSize()); AnchorPoint anchorCopy = copy(gr.getAnchorPoint()); // Looks like Symbols are a "view" of marks and external graphics? // Symbol[] symbolCopys = copy( gr.getSymbols() ); copy = sf.createDefaultGraphic(); copy.setDisplacement(displacementCopy); copy.setAnchorPoint(anchorCopy); copy.setExternalGraphics(externalGraphicsCopy); copy.setMarks(marksCopy); copy.setOpacity(opacityCopy); copy.setRotation(rotationCopy); copy.setSize(sizeCopy); // copy.setSymbols(symbolCopys); if (STRICT) { if (!copy.equals(gr)) { throw new IllegalStateException("Was unable to duplicate provided Graphic:" + gr); } } pages.push(copy); }
/** * 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)); } } } }
copy = sf.createDefaultGraphic(); copy.setDisplacement(displacementCopy); copy.setAnchorPoint(anchorCopy);
ff.literal(wellKnownName), stroke, fill, ff.literal(size), ff.literal(0)); Graphic graphic = sf.createDefaultGraphic(); graphic.graphicalSymbols().clear(); graphic.graphicalSymbols().add(mark);
copy = sf.createDefaultGraphic(); copy.setDisplacement(displacementCopy); copy.setAnchorPoint(anchorCopy);
/** * Create a Style to draw point features as circles with blue outlines * and cyan fill */ private Style createPointStyle() { Graphic gr = styleFactory.createDefaultGraphic(); Mark mark = styleFactory.getCircleMark(); mark.setStroke(styleFactory .createStroke(filterFactory.literal(Color.BLUE), filterFactory.literal(1))); mark.setFill(styleFactory.createFill(filterFactory.literal(Color.RED))); gr.graphicalSymbols().clear(); gr.graphicalSymbols().add(mark); gr.setSize(filterFactory.literal(5)); /* * Setting the geometryPropertyName arg to null signals that we want to * draw the default geomettry of features */ PointSymbolizer sym = styleFactory.createPointSymbolizer(gr, null); Rule rule = styleFactory.createRule(); rule.symbolizers().add(sym); FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[] { rule }); Style style = styleFactory.createStyle(); style.featureTypeStyles().add(fts); return style; }
public void visit(Graphic gr) { Graphic copy = null; Displacement displacementCopy = copy( gr.getDisplacement() ); ExternalGraphic[] externalGraphicsCopy = copy( gr.getExternalGraphics() ); Mark[] marksCopy = copy( gr.getMarks() ); Expression opacityCopy = copy( gr.getOpacity() ); Expression rotationCopy = copy( gr.getRotation() ); Expression sizeCopy = copy( gr.getSize() ); // Looks like Symbols are a "view" of marks and external graphics? // Symbol[] symbolCopys = copy( gr.getSymbols() ); copy = sf.createDefaultGraphic(); copy.setDisplacement(displacementCopy); copy.setExternalGraphics(externalGraphicsCopy); copy.setMarks(marksCopy); copy.setOpacity((Expression) opacityCopy); copy.setRotation((Expression) rotationCopy); copy.setSize((Expression) sizeCopy); // copy.setSymbols(symbolCopys); if( STRICT ){ if( !copy.equals( gr )){ throw new IllegalStateException("Was unable to duplicate provided Graphic:"+gr ); } } pages.push(copy); }
/** * 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)); } } } }
copy = sf.createDefaultGraphic(); copy.setGeometryPropertyName(gr.getGeometryPropertyName()); copy.setDisplacement(displacementCopy);
private void setDefaultSymbolizer(SimpleFeatureCollection inputFeatures) { GeometryDescriptor geomDesc = inputFeatures.getSchema().getGeometryDescriptor(); String geometryPropertyName = geomDesc.getLocalName(); Class<?> geomBinding = geomDesc.getType().getBinding(); SimpleShapeType shapeType = FeatureTypes.getSimpleShapeType(geomBinding); switch (shapeType) { case POINT: case POLYGON: // default Point Symbolizer Mark mark = sf.getCircleMark(); // createStroke(Expression color, Expression width, Expression opacity) Stroke markStroke = sf.createStroke(ff.literal(Color.WHITE), ff.literal(outlineWidth), ff.literal(outlineOpacity)); mark.setStroke(markStroke); mark.setFill(sf.createFill(ff.literal(Color.RED), ff.literal(fillOpacity))); Graphic graphic = sf.createDefaultGraphic(); graphic.graphicalSymbols().clear(); graphic.graphicalSymbols().add(mark); graphic.setSize(ff.literal(minSize)); this.templateSymbol = sf.createPointSymbolizer(graphic, null); break; case LINESTRING: // Default Line Symbolizer Stroke stroke = sf.createStroke(ff.literal(new Color(0, 112, 255)), ff.literal(lineWidth), ff.literal(outlineOpacity)); this.templateSymbol = sf.createLineSymbolizer(stroke, geometryPropertyName); break; } }
copy = sf.createDefaultGraphic(); copy.setGeometryPropertyName(gr.getGeometryPropertyName()); copy.setDisplacement(displacementCopy);
copy = sf.createDefaultGraphic(); copy.setDisplacement(displacementCopy); copy.setExternalGraphics(externalGraphicsCopy);
mark.setFill(sf.createFill(color, ff.literal(fillOpacity))); Graphic graphic = sf.createDefaultGraphic(); graphic.graphicalSymbols().clear(); graphic.graphicalSymbols().add(mark);
stroke, fill, ff.literal(size), ff.literal(0)); Graphic graphic = sf.createDefaultGraphic(); graphic.graphicalSymbols().clear(); graphic.graphicalSymbols().add(mark);