Java Code Examples for org.geotools.styling.Rule#symbolizers()
The following examples show how to use
org.geotools.styling.Rule#symbolizers() .
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: RuleWrapper.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
public RuleWrapper( Rule rule, FeatureTypeStyleWrapper parent ) { this.rule = rule; this.parent = parent; name = rule.getName(); try { maxScale = String.valueOf(rule.getMaxScaleDenominator()); minScale = String.valueOf(rule.getMinScaleDenominator()); } catch (Exception e) { maxScale = DEFAULT_MAXSCALE; minScale = DEFAULT_MINSCALE; } List<Symbolizer> symbolizers = rule.symbolizers(); for( Symbolizer symbolizer : symbolizers ) { SymbolizerWrapper wrapper = getWrapper(symbolizer); symbolizersWrapperList.add(wrapper); } }
Example 2
Source File: CartographicLineSymbol.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Convert. * * @param rule the rule * @param element the element * @param layerName the layer name * @param transparency the transparency */ @Override public void convert(Rule rule, JsonElement element, String layerName, int transparency) { if(rule == null) return; if(element == null) return; JsonObject obj = element.getAsJsonObject(); List<Symbolizer> symbolizerList = rule.symbolizers(); List<Stroke> strokeList = convert(obj); Stroke stroke = null; if(!strokeList.isEmpty()) { stroke = strokeList.get(0); } LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer(stroke, null); symbolizerList.add(lineSymbolizer); }
Example 3
Source File: SimpleMarkerSymbol.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public void convert(Rule rule, JsonElement element, String layerName, int transparency) { if(element == null) return; if(rule == null) return; List<Symbolizer> symbolizerList = rule.symbolizers(); List<Graphic> markerList = convert(element); if(markerList != null) { for(Graphic marker : markerList) { PointSymbolizer pointSymbolizer = styleFactory.createPointSymbolizer(marker, null); symbolizerList.add(pointSymbolizer); } } }
Example 4
Source File: SimpleLineSymbol.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public void convert(Rule rule, JsonElement element, String layerName, int transparency) { if(element == null) return; if(rule == null) return; JsonObject obj = element.getAsJsonObject(); @SuppressWarnings("unused") int style = getInt(obj, CommonSymbolKeys.STYLE); List<Symbolizer> symbolizerList = rule.symbolizers(); List<Stroke> strokeList = convert(obj); Stroke stroke = null; if(!strokeList.isEmpty()) { stroke = strokeList.get(0); } LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer(stroke, null); symbolizerList.add(lineSymbolizer); }
Example 5
Source File: SLDTree.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Populate styles. * * @param styledLayerTreeNode the styled layer tree node * @param styleList the style list */ private void populateStyles(DefaultMutableTreeNode styledLayerTreeNode, List<Style> styleList) { for (Style style : styleList) { DefaultMutableTreeNode styleTreeNode = addObject(styledLayerTreeNode, style, true); for (FeatureTypeStyle fts : style.featureTypeStyles()) { DefaultMutableTreeNode ftsTreeNode = addObject(styleTreeNode, fts, true); for (Rule rule : fts.rules()) { DefaultMutableTreeNode ruleTreeNode = addObject(ftsTreeNode, rule, true); for (Symbolizer symbolizer : rule.symbolizers()) { populateSymbolizer(ruleTreeNode, symbolizer); } } } } }
Example 6
Source File: SLDUtils.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Traverse symbolizers. * * @param sld the sld * @param traverseSymbolizersInterface the traverse symbolizers interface */ public static void traverseSymbolizers( StyledLayerDescriptor sld, TraverseSymbolizersInterface traverseSymbolizersInterface) { List<StyledLayer> styledLayerList = sld.layers(); for (StyledLayer styledLayer : styledLayerList) { List<Style> styleList = SLDUtils.getStylesList(styledLayer); for (Style style : styleList) { for (FeatureTypeStyle fts : style.featureTypeStyles()) { for (Rule rule : fts.rules()) { for (org.opengis.style.Symbolizer symbolizer : rule.symbolizers()) { processSymbolizer(symbolizer, traverseSymbolizersInterface); } } } } } }
Example 7
Source File: SelectedSymbol.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Checks if the selected Style contains a raster symbol. * * @return true, if is raster symbol */ public boolean isRasterSymbol() { Style style = getStyle(); if (style != null) { for (FeatureTypeStyle fts : style.featureTypeStyles()) { for (Rule rule : fts.rules()) { for (Symbolizer symbolizer : rule.symbolizers()) { if (symbolizer instanceof RasterSymbolizer) { return true; } } } } } return false; }
Example 8
Source File: SimpleFillSymbol.java From sldeditor with GNU General Public License v3.0 | 5 votes |
@Override public void convert(Rule rule, JsonElement element, String layerName, int transparency) { if(element == null) return; if(rule == null) return; JsonObject obj = element.getAsJsonObject(); @SuppressWarnings("unused") int style = getInt(obj, CommonSymbolKeys.STYLE); List<Symbolizer> symbolizerList = rule.symbolizers(); JsonElement jsonOutlineElement = obj.get(SimpleFillSymbolKeys.OUTLINE); List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(jsonOutlineElement); Stroke stroke = null; if(strokeList != null) { if(!strokeList.isEmpty()) { stroke = strokeList.get(0); } } Expression fillColour = getColour(obj.get(SimpleFillSymbolKeys.FILL_COLOUR)); Fill fill = null; if(fillColour != null) { fill = styleFactory.createFill(fillColour, getTransparency(transparency)); } PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer(stroke, fill, null); symbolizerList.add(polygonSymbolizer); }
Example 9
Source File: MultiLayerLineSymbol.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Convert. * * @param rule the rule * @param element the element * @param layerName the layer name * @param transparency the transparency */ @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(); List<Stroke> strokeList = null; JsonElement jsonOutlineElement = obj.get(MultiLayerLineSymbolKeys.LINE); strokeList = SymbolManager.getInstance().getStrokeList(jsonOutlineElement); if(strokeList != null) { for(Stroke stroke : strokeList) { LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer(stroke, null); symbolizerList.add(lineSymbolizer); } } } } }
Example 10
Source File: MultiLayerMarkerSymbol.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Convert. * * @param rule the rule * @param element the element * @param layerName the layer name * @param transparency the transparency */ @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(); JsonElement jsonElement = obj.get(MultiLayerMarkerSymbolKeys.MARKER); if (jsonElement != null) { JsonObject asJsonObject = jsonElement.getAsJsonObject(); if (asJsonObject != null) { List<Graphic> markerList = SymbolManager.getInstance() .getMarkerList(asJsonObject); if (markerList != null) { for (Graphic marker : markerList) { PointSymbolizer pointSymbolizer = styleFactory .createPointSymbolizer(marker, null); symbolizerList.add(pointSymbolizer); } } } } } } }
Example 11
Source File: MinimumVersion.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Find minimum version. * * @param sld the sld */ public void findMinimumVersion(StyledLayerDescriptor sld) { vendorOptionsPresentList.clear(); Object parentObj = null; if ((sld != null) && (uiMgr != null)) { uiMgr.getMinimumVersion(parentObj, sld, vendorOptionsPresentList); List<StyledLayer> styledLayerList = sld.layers(); parentObj = sld; for (StyledLayer styledLayer : styledLayerList) { uiMgr.getMinimumVersion(parentObj, styledLayer, vendorOptionsPresentList); List<Style> styleList = SLDUtils.getStylesList(styledLayer); parentObj = styledLayer; for (Style style : styleList) { uiMgr.getMinimumVersion(parentObj, style, vendorOptionsPresentList); parentObj = style; for (FeatureTypeStyle fts : style.featureTypeStyles()) { uiMgr.getMinimumVersion(parentObj, fts, vendorOptionsPresentList); parentObj = fts; for (Rule rule : fts.rules()) { uiMgr.getMinimumVersion(parentObj, rule, vendorOptionsPresentList); parentObj = rule; for (Symbolizer symbolizer : rule.symbolizers()) { uiMgr.getMinimumVersion( parentObj, symbolizer, vendorOptionsPresentList); } } } } } } removeStrictSLD(); }
Example 12
Source File: BatchUpdateFontUtils.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Contains font details. * * @param sldData the sld data * @return the scale sld data, returns null if invalid SLD string supplied. */ public static List<BatchUpdateFontData> containsFonts(SLDDataInterface sldData) { List<BatchUpdateFontData> dataList = null; StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData); if (sld != null) { List<StyledLayer> styledLayerList = sld.layers(); for (StyledLayer styledLayer : styledLayerList) { if (styledLayer instanceof NamedLayerImpl) { NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer; for (Style style : namedLayerImpl.styles()) { for (FeatureTypeStyle fts : style.featureTypeStyles()) { for (Rule rule : fts.rules()) { for (Symbolizer symbolizer : rule.symbolizers()) { if (symbolizer instanceof TextSymbolizer) { TextSymbolizer textSymbol = (TextSymbolizer) symbolizer; Font font = textSymbol.getFont(); if (font != null) { if (dataList == null) { dataList = new ArrayList<>(); } BatchUpdateFontData fontSLDData = new BatchUpdateFontData(sld, sldData); fontSLDData.setNamedLayer(namedLayerImpl.getName()); fontSLDData.setFeatureTypeStyle(fts.getName()); fontSLDData.setStyle(style.getName()); fontSLDData.setRule(rule); fontSLDData.setSymbolizer(textSymbol); fontSLDData.setFont(font); dataList.add(fontSLDData); } } } } } } } } } return dataList; }
Example 13
Source File: SymbolizerFilterVisitor.java From geomajas-project-server with GNU Affero General Public License v3.0 | 4 votes |
/** * Overridden to skip some symbolizers. */ @Override public void visit(Rule rule) { Rule copy = null; Filter filterCopy = null; if (rule.getFilter() != null) { Filter filter = rule.getFilter(); filterCopy = copy(filter); } List<Symbolizer> symsCopy = new ArrayList<Symbolizer>(); for (Symbolizer sym : rule.symbolizers()) { if (!skipSymbolizer(sym)) { Symbolizer symCopy = copy(sym); symsCopy.add(symCopy); } } Graphic[] legendCopy = rule.getLegendGraphic(); for (int i = 0; i < legendCopy.length; i++) { legendCopy[i] = copy(legendCopy[i]); } Description descCopy = rule.getDescription(); descCopy = copy(descCopy); copy = sf.createRule(); copy.symbolizers().addAll(symsCopy); copy.setDescription(descCopy); copy.setLegendGraphic(legendCopy); copy.setName(rule.getName()); copy.setFilter(filterCopy); copy.setElseFilter(rule.isElseFilter()); copy.setMaxScaleDenominator(rule.getMaxScaleDenominator()); copy.setMinScaleDenominator(rule.getMinScaleDenominator()); if (STRICT && !copy.equals(rule)) { throw new IllegalStateException( "Was unable to duplicate provided Rule:" + rule); } pages.push(copy); }
Example 14
Source File: SelectedSymbolTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.common.data.SelectedSymbol#removeFeatureTypeStyle(org.geotools.styling.FeatureTypeStyle)}. */ @Test public void testRemove() { SelectedSymbol.destroyInstance(); SelectedSymbol instance = SelectedSymbol.getInstance(); Rule rule1 = DefaultSymbols.createNewRule(); Rule rule2 = DefaultSymbols.createNewRule(); FeatureTypeStyle fts1 = DefaultSymbols.createNewFeatureTypeStyle(); FeatureTypeStyle fts2 = DefaultSymbols.createNewFeatureTypeStyle(); Style style1 = DefaultSymbols.createNewStyle(); Style style2 = DefaultSymbols.createNewStyle(); Style style3 = DefaultSymbols.createNewStyle(); NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer(); StyledLayerDescriptor sld = DefaultSymbols.createNewSLD(); PolygonSymbolizer polygonSymbolizer1 = DefaultSymbols.createDefaultPolygonSymbolizer(); PolygonSymbolizer polygonSymbolizer2 = DefaultSymbols.createDefaultPolygonSymbolizer(); PolygonSymbolizer polygonSymbolizer3 = DefaultSymbols.createDefaultPolygonSymbolizer(); instance.createNewSLD(sld); instance.setSld(sld); instance.addNewStyledLayer(namedLayer); instance.setStyledLayer(namedLayer); instance.addNewStyledLayer(namedLayer); instance.addNewStyle(style1); instance.addNewStyle(style2); instance.addNewStyle(style3); instance.setStyle(style1); instance.addNewFeatureTypeStyle(fts1); instance.addNewFeatureTypeStyle(fts2); instance.setFeatureTypeStyle(fts1); instance.addNewRule(rule1); instance.setRule(rule1); instance.addSymbolizerToRule(polygonSymbolizer1); instance.addSymbolizerToRule(polygonSymbolizer2); instance.addSymbolizerToRule(polygonSymbolizer3); instance.addNewRule(rule2); Rule ruleToTest = instance.getRule(); List<Symbolizer> symbolizerList = ruleToTest.symbolizers(); assertEquals(3, symbolizerList.size()); instance.removeSymbolizer(polygonSymbolizer3); assertEquals(2, symbolizerList.size()); instance.removeSymbolizer(polygonSymbolizer3); assertEquals(2, symbolizerList.size()); instance.removeSymbolizer(polygonSymbolizer2); assertEquals(1, symbolizerList.size()); instance.removeSymbolizer(polygonSymbolizer1); assertEquals(0, symbolizerList.size()); List<Rule> ruleList = instance.getFeatureTypeStyle().rules(); assertEquals(2, ruleList.size()); instance.removeRule(rule2); assertEquals(1, ruleList.size()); instance.removeRule(rule1); assertEquals(0, ruleList.size()); instance.removeRule(rule2); assertEquals(0, ruleList.size()); List<FeatureTypeStyle> ftsList = instance.getStyle().featureTypeStyles(); assertEquals(2, ftsList.size()); instance.removeFeatureTypeStyle(fts2); assertEquals(1, ftsList.size()); instance.removeFeatureTypeStyle(fts2); assertEquals(1, ftsList.size()); instance.removeFeatureTypeStyle(fts1); assertEquals(0, ftsList.size()); List<Style> styleList = ((NamedLayer) instance.getStyledLayer()).styles(); assertEquals(3, styleList.size()); instance.removeStyle(style3); assertEquals(2, styleList.size()); instance.removeStyle(style2); assertEquals(1, styleList.size()); instance.removeStyle(style2); assertEquals(1, styleList.size()); instance.removeStyle(style1); assertEquals(0, styleList.size()); instance.removeStyledLayerDescriptor(sld); assertEquals(sld, instance.getSld()); instance.removeUserNamedLayer(namedLayer); assertEquals(1, instance.getSld().layers().size()); instance.removeUserNamedLayer(namedLayer); assertEquals(0, instance.getSld().layers().size()); instance.removeUserNamedLayer(namedLayer); assertEquals(0, instance.getSld().layers().size()); }
Example 15
Source File: SelectedSymbol.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Update internal data based on the supplied mask. * * @param maskValue the mask value */ private void updateInternalData(SelectedSymbolMask.SymbolMaskEnum maskValue) { SymbolData localSymbolData = new SymbolData(); SelectedSymbolMask mask = new SelectedSymbolMask(maskValue); if (sld == null) { return; } List<StyledLayer> styledLayers = sld.layers(); if (!styledLayers.isEmpty()) { localSymbolData.initialiseSelectedStyledLayerIndex(); for (StyledLayer styledLayer : styledLayers) { localSymbolData.setStyledLayer(styledLayer); if (styledLayer == symbolData.getStyledLayer()) { this.symbolData.update(localSymbolData); return; } List<Style> styleList = null; if (mask.shouldContinue(SelectedSymbolMask.SymbolMaskEnum.E_STYLED_LAYER)) { styleList = SLDUtils.getStylesList(styledLayer); } if (mask.shouldContinue(SelectedSymbolMask.SymbolMaskEnum.E_STYLE) && (styleList != null) && !styleList.isEmpty()) { localSymbolData.initialiseSelectedStyleIndex(); for (Style style : styleList) { localSymbolData.setStyle(style); if (style == symbolData.getStyle()) { this.symbolData.update(localSymbolData); return; } if (mask.shouldContinue( SelectedSymbolMask.SymbolMaskEnum.E_FEATURE_TYPE_STYLE)) { localSymbolData.initialiseSelectedFTSIndex(); for (FeatureTypeStyle fts : style.featureTypeStyles()) { localSymbolData.setFeatureTypeStyle(fts); if (fts == symbolData.getFeatureTypeStyle()) { this.symbolData.update(localSymbolData); return; } if (mask.shouldContinue(SelectedSymbolMask.SymbolMaskEnum.E_RULE)) { localSymbolData.initialiseSelectedRuleIndex(); for (Rule rule : fts.rules()) { localSymbolData.setRule(rule); if (rule == symbolData.getRule()) { this.symbolData.update(localSymbolData); return; } if (mask.shouldContinue( SelectedSymbolMask.SymbolMaskEnum.E_SYMBOLIZER)) { localSymbolData.initialiseSelectedSymbolizerIndex(); for (Symbolizer symbol : rule.symbolizers()) { localSymbolData.setSymbolizer(symbol); if (symbol == this.symbolData.getSymbolizer()) { this.symbolData.update(localSymbolData); return; } else { localSymbolData .incrementSelectedSymbolizerIndex(); } } } localSymbolData.incrementSelectedRuleIndex(); } } localSymbolData.incrementSelectedFTSIndex(); } } localSymbolData.incrementSelectedStyleIndex(); } } localSymbolData.incrementSelectedStyledLayerIndex(); } } }
Example 16
Source File: PictureFillSymbol.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; JsonObject obj = element.getAsJsonObject(); List<Symbolizer> symbolizerList = rule.symbolizers(); List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(obj.get(PictureFillSymbolKeys.OUTLINE)); Stroke stroke = null; if(!strokeList.isEmpty()) { stroke = strokeList.get(0); } Fill fill = getFill(layerName, obj, transparency); PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer(stroke, fill, null); symbolizerList.add(polygonSymbolizer); }
Example 17
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); } } } }