Java Code Examples for org.geotools.styling.PolygonSymbolizer#setStroke()
The following examples show how to use
org.geotools.styling.PolygonSymbolizer#setStroke() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PictureFillSymbol.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public List<Symbolizer> convertToFill(String layerName, JsonElement element, int transparency) { if(element == null) return null; JsonObject obj = element.getAsJsonObject(); List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>(); Fill fill = getFill(layerName, obj, transparency); PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer(); polygon.setStroke(null); polygon.setFill(fill); symbolizerList.add(polygon); return symbolizerList; }
Example 2
Source File: SimpleFillSymbol.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public List<Symbolizer> convertToFill(String layerName, JsonElement element, int transparency) { if(element == null) return null; JsonObject obj = element.getAsJsonObject(); List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>(); Expression fillColour = getColour(obj.get(SimpleFillSymbolKeys.FILL_COLOUR)); Expression transparencyExpression = getTransparency(transparency); Fill fill = null; if(fillColour != null) { fill = styleFactory.createFill(fillColour, transparencyExpression); } PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer(); polygon.setStroke(null); polygon.setFill(fill); symbolizerList.add(polygon); return symbolizerList; }
Example 3
Source File: ExtractAttributes.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * (non-Javadoc) * * @see * org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.PolygonSymbolizer) */ @Override public void visit(PolygonSymbolizer poly) { PolygonSymbolizer copy = sf.createPolygonSymbolizer(); copy.setFill(copy(poly.getFill())); copy.setGeometry(copy(MultiPolygon.class, poly.getGeometry())); copy.setUnitOfMeasure(poly.getUnitOfMeasure()); copy.setStroke(copy(poly.getStroke())); copy.getOptions().putAll(poly.getOptions()); if (STRICT && !copy.equals(poly)) { throw new IllegalStateException( "Was unable to duplicate provided PolygonSymbolizer:" + poly); } pages.push(copy); }
Example 4
Source File: RuleRenderVisitor.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * (non-Javadoc) * * @see * org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.PolygonSymbolizer) */ public void visit(PolygonSymbolizer poly) { PolygonSymbolizer copy = sf.createPolygonSymbolizer(); copy.setFill(copy(poly.getFill())); copy.setGeometry(copy(poly.getGeometry())); copy.setUnitOfMeasure(poly.getUnitOfMeasure()); copy.setStroke(copy(poly.getStroke())); copy.getOptions().putAll(poly.getOptions()); if (STRICT && !copy.equals(poly)) { throw new IllegalStateException( "Was unable to duplicate provided PolygonSymbolizer:" + poly); } pages.push(copy); }
Example 5
Source File: ShapefileLoader.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private static Style createPolygonStyle() { PolygonSymbolizer symbolizer = styleFactory.createPolygonSymbolizer(); Fill fill = styleFactory.createFill( filterFactory.literal("#FFAA00"), filterFactory.literal(0.5) ); final Stroke stroke = styleFactory.createStroke(filterFactory.literal(Color.BLACK), filterFactory.literal(1)); symbolizer.setFill(fill); symbolizer.setStroke(stroke); Rule rule = styleFactory.createRule(); rule.symbolizers().add(symbolizer); FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(); fts.rules().add(rule); Style style = styleFactory.createStyle(); style.featureTypeStyles().add(fts); return style; }
Example 6
Source File: DefaultSymbols.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Creates the default polygon symbolizer. * * @return the polygon symbolizer */ public static PolygonSymbolizer createDefaultPolygonSymbolizer() { Stroke stroke = styleFactory.createStroke(ff.literal(DEFAULT_LINE_COLOUR), ff.literal(2)); Fill fill = styleFactory.getDefaultFill(); PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer(); polygonSymbolizer.setStroke(stroke); polygonSymbolizer.setFill(fill); return polygonSymbolizer; }
Example 7
Source File: SLDTreeLeafPolygon.java From sldeditor with GNU General Public License v3.0 | 5 votes |
@Override public void removeStroke(Symbolizer symbolizer) { if (symbolizer instanceof PolygonSymbolizer) { PolygonSymbolizer polygon = (PolygonSymbolizer) symbolizer; polygon.setStroke(null); } }
Example 8
Source File: SLDTreeLeafPolygon.java From sldeditor with GNU General Public License v3.0 | 5 votes |
@Override public void createStroke(Symbolizer symbolizer) { if (symbolizer instanceof PolygonSymbolizer) { PolygonSymbolizer polygon = (PolygonSymbolizer) symbolizer; polygon.setStroke(styleFactory.getDefaultStroke()); } }
Example 9
Source File: SLDTreeLeafPolygonTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.common.tree.leaf.SLDTreeLeafPolygon#hasStroke(org.opengis.style.Symbolizer)}. */ @Test public void testHasStroke() { SLDTreeLeafPolygon leaf = new SLDTreeLeafPolygon(); assertFalse(leaf.hasStroke(null)); assertFalse(leaf.hasStroke(DefaultSymbols.createDefaultPointSymbolizer())); PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer(); assertTrue(leaf.hasStroke(polygonSymbolizer)); polygonSymbolizer.setStroke(null); assertFalse(leaf.hasStroke(polygonSymbolizer)); }
Example 10
Source File: SLDTreeLeafPolygonTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.common.tree.leaf.SLDTreeLeafPolygon#createStroke(org.opengis.style.Symbolizer)}. */ @Test public void testCreateStroke() { SLDTreeLeafPolygon leaf = new SLDTreeLeafPolygon(); PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer(); polygonSymbolizer.setStroke(null); leaf.createStroke(polygonSymbolizer); assertTrue(polygonSymbolizer.getStroke() != null); }
Example 11
Source File: StyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Creates a default {@link Rule} for a polygon. * * @return the default rule. */ public static Rule createDefaultPolygonRule() { PolygonSymbolizer polygonSymbolizer = sf.createPolygonSymbolizer(); Fill fill = createDefaultFill(); polygonSymbolizer.setFill(fill); polygonSymbolizer.setStroke(createDefaultStroke()); Rule rule = sf.createRule(); rule.setName("New rule"); rule.symbolizers().add(polygonSymbolizer); return rule; }
Example 12
Source File: PolygonSymbolizerWrapper.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
protected void checkStrokeExists() { if (stroke == null) { if (strokeColor == null) { strokeColor = DEFAULT_COLOR; } if (strokeWidth == null) { strokeWidth = DEFAULT_WIDTH; } stroke = sf.createStroke(ff.literal(strokeColor), ff.literal(strokeWidth)); PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) getSymbolizer(); polygonSymbolizer.setStroke(stroke); strokeGraphicStroke = stroke.getGraphicStroke(); } }
Example 13
Source File: LineFillSymbol.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Convert to fill. * * @param layerName the layer name * @param element the element * @param transparency the transparency * @return the list */ /* (non-Javadoc) * @see com.sldeditor.convert.esri.symbols.EsriFillSymbolInterface#convertToFill(java.lang.String, com.google.gson.JsonElement, int) */ @Override public List<Symbolizer> convertToFill(String layerName, JsonElement element, int transparency) { if (layerName == null) { return null; } if (element == null) { return null; } List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>(); JsonObject obj = element.getAsJsonObject(); Expression size = ff.literal(getDouble(obj, LineFillSymbolKeys.SEPARATION)); Expression opacity = null; double lineAngle = normaliseAngle(getDouble(obj, CommonSymbolKeys.ANGLE)); Expression rotation = null; AnchorPoint anchorPoint = null; Displacement displacement = null; Expression fillColour = getColour(obj.get(LineFillSymbolKeys.FILL_COLOUR)); Expression fillColourOpacity = null; Expression join = null; Expression cap = null; float[] dashes = null; Expression offset = null; Expression width = ff.literal(1.0); Stroke outlineStroke = null; List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(obj.get(LineFillSymbolKeys.OUTLINE)); // TODO if((strokeList != null) && (strokeList.size() == 1)) { outlineStroke = strokeList.get(0); width = outlineStroke.getWidth(); } Expression wellKnownName = null; if(isDoubleEqual(lineAngle, 0.0) || isDoubleEqual(lineAngle, 180.0)) { wellKnownName = ff.literal("shape://horline"); } else if(isDoubleEqual(lineAngle, 90.0) || isDoubleEqual(lineAngle, 270.0)) { wellKnownName = ff.literal("shape://vertline"); } else if(isDoubleEqual(lineAngle, 45.0) || isDoubleEqual(lineAngle, 225.0)) { wellKnownName = ff.literal("shape://slash"); } else if(isDoubleEqual(lineAngle, 135.0) || isDoubleEqual(lineAngle, 315.0)) { wellKnownName = ff.literal("shape://backslash"); } else { wellKnownName = ff.literal("shape://vertline"); rotation = ff.literal(lineAngle); } Fill fill = null; Stroke markStroke = styleFactory.stroke(fillColour, fillColourOpacity, width, join, cap, dashes, offset); Mark mark = styleFactory.createMark(wellKnownName, markStroke, fill, size, rotation); List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>(); symbolList.add(mark); GraphicFill graphicFill = styleFactory.graphicFill(symbolList, opacity, size, rotation, anchorPoint, displacement); Fill completeFill = styleFactory.fill(graphicFill, null, null); PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer(); polygonSymbolizer.setFill(completeFill); polygonSymbolizer.setStroke(outlineStroke); symbolizerList.add(polygonSymbolizer); return symbolizerList; }
Example 14
Source File: StrokeDetails.java From sldeditor with GNU General Public License v3.0 | 3 votes |
/** Update symbol. */ private void updateSymbol() { if (!Controller.getInstance().isPopulating()) { Stroke stroke = getStroke(); if (symbolizer instanceof PointSymbolizer) { PointSymbolizer pointSymbol = (PointSymbolizer) symbolizer; Graphic graphic = pointSymbol.getGraphic(); GraphicalSymbol symbol = graphic.graphicalSymbols().get(0); if (symbol instanceof MarkImpl) { MarkImpl markerSymbol = (MarkImpl) symbol; markerSymbol.setStroke(stroke); SelectedSymbol.getInstance().replaceSymbolizer(pointSymbol); this.fireUpdateSymbol(); } } else if (symbolizer instanceof LineSymbolizer) { LineSymbolizer lineSymbol = (LineSymbolizer) symbolizer; lineSymbol.setStroke(stroke); SelectedSymbol.getInstance().replaceSymbolizer(lineSymbol); this.fireUpdateSymbol(); } else if (symbolizer instanceof PolygonSymbolizer) { PolygonSymbolizer polygonSymbol = (PolygonSymbolizer) symbolizer; polygonSymbol.setStroke(stroke); SelectedSymbol.getInstance().replaceSymbolizer(polygonSymbol); this.fireUpdateSymbol(); } } }
Example 15
Source File: SLDExternalImagesTest.java From sldeditor with GNU General Public License v3.0 | 2 votes |
/** * Creates the test polygon. * * @param url the url * @return the styled layer descriptor */ private StyledLayerDescriptor createTestPolygon(URL url) { StyleBuilder sb = new StyleBuilder(); StyleFactory styleFactory = sb.getStyleFactory(); StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor(); NamedLayer namedLayer = styleFactory.createNamedLayer(); sld.addStyledLayer(namedLayer); Style style = styleFactory.createStyle(); namedLayer.addStyle(style); List<FeatureTypeStyle> ftsList = style.featureTypeStyles(); FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(); ftsList.add(fts); Rule rule = styleFactory.createRule(); fts.rules().add(rule); PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer(); rule.symbolizers().add(polygon); Graphic graphicFill1 = createGraphic(url, styleFactory); Graphic graphicFill2 = createGraphic(url, styleFactory); Graphic graphicStroke = createGraphic(url, styleFactory); Fill fill = styleFactory.createFill(null, null, null, graphicFill1); polygon.setFill(fill); Stroke stroke = styleFactory.createStroke( null, null, null, null, null, null, null, graphicFill2, graphicStroke); polygon.setStroke(stroke); return sld; }