Java Code Examples for org.geotools.styling.Rule#setMaxScaleDenominator()
The following examples show how to use
org.geotools.styling.Rule#setMaxScaleDenominator() .
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: ScaleUtilTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Test method for {@link * com.sldeditor.common.utils.ScaleUtil#isPresent(org.opengis.style.Rule)}. */ @Test public void testIsPresent() { assertFalse(ScaleUtil.isPresent(null)); Rule rule = DefaultSymbols.createNewRule(); assertFalse(ScaleUtil.isPresent(rule)); // Set max scale denominator rule.setMaxScaleDenominator(10000.0); assertTrue(ScaleUtil.isPresent(rule)); // Set both min and max scale denominator rule.setMinScaleDenominator(100.0); assertTrue(ScaleUtil.isPresent(rule)); // Set min scale denominator rule.setMaxScaleDenominator(0.0); assertTrue(ScaleUtil.isPresent(rule)); }
Example 2
Source File: ScaleSLDData.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Update scales. * * @param sldWriter the sld writer */ public boolean updateScales(SLDWriterInterface sldWriter) { boolean refreshUI = false; if ((rule != null) && (sldWriter != null)) { if (isMinimumScaleUpdated()) { rule.setMinScaleDenominator(minScale); minimumScaleUpdated = false; } if (isMaximumScaleUpdated()) { rule.setMaxScaleDenominator(maxScale); maximumScaleUpdated = false; } String sldContents = sldWriter.encodeSLD(null, this.sld); SLDDataInterface current = SLDEditorFile.getInstance().getSLDData(); if (current.getSLDFile().equals(sldData.getSLDFile()) || current.getSLDURL().equals(sldData.getSLDURL())) { Rule currentFule = SLDUtils.findRule(sld, rule, SelectedSymbol.getInstance().getSld()); if (currentFule != null) { currentFule.setMinScaleDenominator(minScale); currentFule.setMaxScaleDenominator(maxScale); refreshUI = true; } } sldData.updateSLDContents(sldContents); } return refreshUI; }
Example 3
Source File: SimpleRenderer.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@Override public StyledLayerDescriptor convert(JsonObject json, String layerName, double minScale, double maxScale, int transparency) { StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor(); NamedLayer namedLayer = styleFactory.createNamedLayer(); String label = json.get(CommonRendererKeys.LABEL).getAsString(); namedLayer.setName(label); sld.addStyledLayer(namedLayer); Style style = styleFactory.createStyle(); namedLayer.addStyle(style); List<FeatureTypeStyle> ftsList = style.featureTypeStyles(); // style.setAbstract(json.get(IntermediateFileKeys.DESCRIPTION).getAsString()); FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(); ftsList.add(fts); Rule rule = styleFactory.createRule(); if(minScale > 0.0) { rule.setMinScaleDenominator(minScale); } if(maxScale > 0.0) { rule.setMaxScaleDenominator(maxScale); } JsonElement jsonElement = json.get(CommonRendererKeys.SYMBOL); rule.setName(label); SymbolManager.getInstance().convertSymbols(rule, layerName, transparency, jsonElement); fts.rules().add(rule); return sld; }
Example 4
Source File: UniqueValueRenderer.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@Override public StyledLayerDescriptor convert(JsonObject json, String layerName, double minScale, double maxScale, int transparency) { StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor(); NamedLayer namedLayer = styleFactory.createNamedLayer(); boolean useDefaultSymbol = false; JsonElement useDefaultSymbolElement = json.get(UniqueValueRendererKeys.USE_DEFAULTSYMBOL); if(useDefaultSymbolElement != null) { useDefaultSymbol = useDefaultSymbolElement.getAsBoolean(); } JsonElement jsonElement = json.get(CommonRendererKeys.LABEL); if(jsonElement != null) { namedLayer.setName(jsonElement.getAsString()); } sld.addStyledLayer(namedLayer); Style style = styleFactory.createStyle(); namedLayer.addStyle(style); List<FeatureTypeStyle> ftsList = style.featureTypeStyles(); // style.setAbstract(json.get(IntermediateFileKeys.DESCRIPTION).getAsString()); FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(); ftsList.add(fts); JsonElement element = json.get(UniqueValueRendererKeys.VALUES); if(element != null) { JsonArray valueList = element.getAsJsonArray(); for(int index = 0; index < valueList.size(); index ++) { JsonElement valueElement = valueList.get(index); if(valueElement != null) { Rule rule = styleFactory.createRule(); JsonObject valueObj = valueElement.getAsJsonObject(); String value = getString(valueObj, UniqueValueRendererKeys.VALUES_VALUE); String label = getString(valueObj, UniqueValueRendererKeys.VALUES_LABEL); rule.setName(label); createFilter(rule, json.get(UniqueValueRendererKeys.FIELDS), json.get(UniqueValueRendererKeys.FIELD_DELIMETER), value); // Heading /description String heading = getString(valueObj, UniqueValueRendererKeys.VALUES_HEADING); @SuppressWarnings("unused") String description = getString(valueObj, UniqueValueRendererKeys.VALUES_DESCRIPTION); if((heading != null) && !heading.isEmpty() || (label != null) && !label.isEmpty()) { if(label == null) { label = ""; } InternationalString titleString = Text.text(label); if(heading == null) { heading = ""; } InternationalString descriptionString = Text.text(heading); Description descriptionObj = styleFactory.description(titleString, descriptionString); rule.setDescription(descriptionObj); } if(minScale > 0.0) { rule.setMinScaleDenominator(minScale); } if(maxScale > 0.0) { rule.setMaxScaleDenominator(maxScale); } JsonElement jsonSymbolElement = valueObj.get(UniqueValueRendererKeys.VALUES_SYMBOL); SymbolManager.getInstance().convertSymbols(rule, layerName, transparency, jsonSymbolElement); if(useDefaultSymbol && value == null) { rule.setIsElseFilter(true); } fts.rules().add(rule); } } } return sld; }
Example 5
Source File: LabelEngineLayerProperties.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@Override public void convert(List<Rule> labelRuleList, Rule rule, JsonElement json, int transparency) { if((json != null) && (rule != null) && (labelRuleList != null)) { JsonObject jsonObj = json.getAsJsonObject(); TextSymbolizer textSymbolizer = styleFactory.createTextSymbolizer(); textSymbolizer.setUnitOfMeasure(NonSI.PIXEL); textSymbolizer.setLabel(extractExpression(jsonObj)); JsonElement jsonElement = jsonObj.get(LabelEngineLayerPropertiesKey.SYMBOL); SymbolManager.getInstance().convertTextSymbols(textSymbolizer, transparency, jsonElement); // Yes, this really is round the wrong way double maxScale = extractDouble(jsonObj, LabelEngineLayerPropertiesKey.ANNOTATION_MINIMUM_SCALE); double minScale = extractDouble(jsonObj, LabelEngineLayerPropertiesKey.ANNOTATION_MAXIMUM_SCALE); if((minScale > 0.0) || (maxScale > 0.0)) { Rule labelRule = styleFactory.createRule(); labelRule.setName(extractString(jsonObj, LabelEngineLayerPropertiesKey.CLASS)); if(minScale > 0.0) { labelRule.setMinScaleDenominator(minScale); } if(maxScale > 0.0) { labelRule.setMaxScaleDenominator(maxScale); } labelRule.symbolizers().add(textSymbolizer); labelRuleList.add(labelRule); } else { rule.symbolizers().add(textSymbolizer); } } }
Example 6
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); }