Java Code Examples for org.geotools.styling.LineSymbolizer#setStroke()
The following examples show how to use
org.geotools.styling.LineSymbolizer#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: 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.LineSymbolizer) */ @Override public void visit(LineSymbolizer line) { LineSymbolizer copy = sf.getDefaultLineSymbolizer(); copy.setGeometry(copy(LineString.class, line.getGeometry())); copy.setUnitOfMeasure(line.getUnitOfMeasure()); copy.setStroke(copy(line.getStroke())); copy.getOptions().putAll(line.getOptions()); copy.setPerpendicularOffset(line.getPerpendicularOffset()); if (STRICT && !copy.equals(line)) { throw new IllegalStateException( "Was unable to duplicate provided LineSymbolizer:" + line); } pages.push(copy); }
Example 2
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.LineSymbolizer) */ public void visit(LineSymbolizer line) { LineSymbolizer copy = sf.getDefaultLineSymbolizer(); copy.setGeometry(copy(line.getGeometry())); copy.setUnitOfMeasure(line.getUnitOfMeasure()); copy.setStroke(copy(line.getStroke())); copy.getOptions().putAll(line.getOptions()); copy.setPerpendicularOffset(line.getPerpendicularOffset()); if (STRICT && !copy.equals(line)) { throw new IllegalStateException( "Was unable to duplicate provided LineSymbolizer:" + line); } pages.push(copy); }
Example 3
Source File: SLDTreeLeafLine.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Removes the stroke. * * @param symbolizer the symbolizer */ /* * (non-Javadoc) * * @see * com.sldeditor.ui.tree.leaf.SLDTreeLeafInterface#removeStroke(org.opengis.style.Symbolizer) */ @Override public void removeStroke(Symbolizer symbolizer) { if (symbolizer instanceof LineSymbolizer) { LineSymbolizer line = (LineSymbolizer) symbolizer; line.setStroke(null); } }
Example 4
Source File: SLDTreeLeafLine.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Creates the stroke. * * @param symbolizer the symbolizer */ /* * (non-Javadoc) * * @see * com.sldeditor.ui.tree.leaf.SLDTreeLeafInterface#createStroke(org.opengis.style.Symbolizer) */ @Override public void createStroke(Symbolizer symbolizer) { if (symbolizer instanceof LineSymbolizer) { LineSymbolizer line = (LineSymbolizer) symbolizer; line.setStroke(styleFactory.getDefaultStroke()); } }
Example 5
Source File: SLDTreeLeafLineTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.common.tree.leaf.SLDTreeLeafLine#createStroke(org.opengis.style.Symbolizer)}. */ @Test public void testCreateStroke() { SLDTreeLeafLine leaf = new SLDTreeLeafLine(); LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer(); lineSymbolizer.setStroke(null); leaf.createStroke(lineSymbolizer); assertTrue(lineSymbolizer.getStroke() != null); }
Example 6
Source File: StyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Creates a default {@link Rule} for a line. * * @return the default rule. */ public static Rule createDefaultLineRule() { LineSymbolizer lineSymbolizer = sf.createLineSymbolizer(); lineSymbolizer.setStroke(createDefaultStroke()); Rule rule = sf.createRule(); rule.setName("New rule"); rule.symbolizers().add(lineSymbolizer); return rule; }
Example 7
Source File: SimpleStyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Creates a simple {@link Rule} for a line. * * @param color * the color. * @param width * the line width. * @return the rule. */ public static Rule createSimpleLineRule( Color color, float width ) { LineSymbolizer lineSymbolizer = StyleUtilities.sf.createLineSymbolizer(); lineSymbolizer.setStroke( StyleUtilities.sf.createStroke(StyleUtilities.ff.literal("#" + Integer.toHexString(color.getRGB() & 0xffffff)), StyleUtilities.ff.literal(width))); Rule rule = StyleUtilities.sf.createRule(); rule.setName("New rule"); rule.symbolizers().add(lineSymbolizer); return rule; }
Example 8
Source File: MultiLayerFillSymbol.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@Override public void convert(Rule rule, JsonElement element, String layerName, int transparency) { if(rule == null) return; if(element == null) return; JsonArray layerArray = element.getAsJsonArray(); List<Symbolizer> symbolizerList = rule.symbolizers(); if(layerArray.size() > 0) { for(int index = 0; index < layerArray.size(); index ++) { JsonObject obj = layerArray.get(index).getAsJsonObject(); // Handle fills List<Symbolizer> createdSymbolizerList = SymbolManager.getInstance().getFillSymbol(layerName, obj.get(MultiLayerFillSymbolKeys.FILL), transparency); if(symbolizerList != null) { symbolizerList.addAll(createdSymbolizerList); } // Handle strokes JsonElement jsonOutlineElement = obj.get(MultiLayerFillSymbolKeys.OUTLINE); List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(jsonOutlineElement); if(strokeList != null) { List<Symbolizer> createdLineSymbolizerList = new ArrayList<Symbolizer>(); for(Stroke stroke : strokeList) { LineSymbolizer lineSymbol = styleFactory.createLineSymbolizer(); lineSymbol.setStroke(stroke); createdLineSymbolizerList.add(lineSymbol); } symbolizerList.addAll(createdLineSymbolizerList); } } } }
Example 9
Source File: LineSymbolizerWrapper.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
public LineSymbolizerWrapper( Symbolizer symbolizer, RuleWrapper parent ) { super(symbolizer, parent); initEndPointSymbolizers(); LineSymbolizer lineSymbolizer = (LineSymbolizer) symbolizer; // offset Point2D offset = getOffset(lineSymbolizer); if (offset != null) { xOffset = String.valueOf(offset.getX()); yOffset = String.valueOf(offset.getY()); } else { xOffset = DEFAULT_OFFSET; yOffset = DEFAULT_OFFSET; } Stroke strokeTmp = lineSymbolizer.getStroke(); if (strokeTmp != null) { stroke = strokeTmp; } else { lineSymbolizer.setStroke(stroke); } Expression color = stroke.getColor(); if (color != null) { strokeColor = expressionToString(color); } else { stroke.setColor(ff.literal(strokeColor)); } Expression width = stroke.getWidth(); if (width != null) { strokeWidth = expressionToString(width); } else { stroke.setWidth(ff.literal(strokeWidth)); } Expression opacity = stroke.getOpacity(); if (opacity != null) { strokeOpacity = expressionToString(opacity); } else { stroke.setOpacity(ff.literal(strokeOpacity)); } strokeGraphicStroke = stroke.getGraphicStroke(); if (strokeGraphicStroke != null) { List<GraphicalSymbol> graphicalSymbolsList = strokeGraphicStroke.graphicalSymbols(); if (graphicalSymbolsList.size() > 0) { GraphicalSymbol graphicalSymbol = graphicalSymbolsList.get(0); if (graphicalSymbol instanceof ExternalGraphic) { strokeExternalGraphicStroke = (ExternalGraphic) graphicalSymbol; } } } // dash float[] dashArray = getDashArrayFloats(); if (dashArray.length > 0) { dash = getDashString(dashArray); } else { dash = ""; //$NON-NLS-1$ } // dashoffset dashOffset = stroke.getDashOffset().evaluate(null, String.class); // line cap lineCap = stroke.getLineCap().evaluate(null, String.class); // line join lineJoin = stroke.getLineJoin().evaluate(null, String.class); }
Example 10
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 11
Source File: DefaultSymbols.java From sldeditor with GNU General Public License v3.0 | 3 votes |
/** * Creates the default line symbolizer. * * @return the line symbolizer */ public static LineSymbolizer createDefaultLineSymbolizer() { Stroke stroke = styleFactory.createStroke(ff.literal(DEFAULT_LINE_COLOUR), ff.literal(2)); LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer(); lineSymbolizer.setStroke(stroke); return lineSymbolizer; }
Example 12
Source File: SLDExternalImagesTest.java From sldeditor with GNU General Public License v3.0 | 3 votes |
/** * Creates the test line. * * @param url the url * @return the styled layer descriptor */ private StyledLayerDescriptor createTestLine(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); LineSymbolizer line = styleFactory.createLineSymbolizer(); rule.symbolizers().add(line); Graphic graphicFill = createGraphic(url, styleFactory); Graphic graphicStroke = createGraphic(url, styleFactory); Stroke stroke = styleFactory.createStroke( null, null, null, null, null, null, null, graphicFill, graphicStroke); line.setStroke(stroke); return sld; }