public RuleImpl rule( String name, Description description, GraphicLegend legend, double min, double max, List<org.opengis.style.Symbolizer> symbolizers, Filter filter) { RuleImpl rule = new RuleImpl(); rule.setName(name); rule.setDescription(description); rule.setLegend(legend); rule.setMinScaleDenominator(min); rule.setMaxScaleDenominator(max); if (symbolizers != null) { for (org.opengis.style.Symbolizer symbolizer : symbolizers) { rule.symbolizers().add(cast(symbolizer)); } } if (filter != null) { rule.setFilter(filter); rule.setElseFilter(false); } else { rule.setElseFilter(true); } return rule; }
protected RuleImpl( org.geotools.styling.Symbolizer[] symbolizers, org.opengis.style.Description desc, org.geotools.styling.Graphic[] legends, String name, Filter filter, boolean isElseFilter, double maxScale, double minScale) { setSymbolizers(symbolizers); description.setAbstract(desc.getAbstract()); description.setTitle(desc.getTitle()); setLegendGraphic(legends); this.name = name; this.filter = filter; hasElseFilter = isElseFilter; this.maxScaleDenominator = maxScale; this.minScaleDenominator = minScale; }
public FeatureTypeStyleImpl(org.opengis.style.FeatureTypeStyle fts) { this.description = new DescriptionImpl(fts.getDescription()); this.featureInstances = fts.getFeatureInstanceIDs(); this.featureTypeNames = new LinkedHashSet<Name>(fts.featureTypeNames()); this.name = fts.getName(); this.rules = new ArrayList<Rule>(); if (fts.rules() != null) { for (org.opengis.style.Rule rule : fts.rules()) { rules.add(RuleImpl.cast(rule)); // need to deep copy? } } this.semantics = new LinkedHashSet<SemanticType>(fts.semanticTypeIdentifiers()); this.online = fts.getOnlineResource(); this.transformation = fts.getTransformation(); }
public BasicLineStyle(Stroke stroke) { LineSymbolizerImpl linesym = new LineSymbolizerImpl(); linesym.setStroke(stroke); RuleImpl rule = new RuleImpl(); rule.setSymbolizers(new org.geotools.styling.Symbolizer[] {linesym}); FeatureTypeStyleImpl fts = new FeatureTypeStyleImpl(); fts.setRules(new Rule[] {rule}); this.setFeatureTypeStyles(new org.geotools.styling.FeatureTypeStyle[] {fts}); }
static RuleImpl cast(Rule rule) { if (rule == null) { return null; } else if (rule instanceof RuleImpl) { return (RuleImpl) rule; } else { RuleImpl copy = new RuleImpl(rule); // replace with casting ... return copy; } } }
private RuleImpl buildDynamicGeometryRule( Rule base, Expression geom, Symbolizer symbolizer, String... geometryTypes) { List<Filter> typeChecks = new ArrayList<>(); for (String geometryType : geometryTypes) { typeChecks.add( ff.equal(ff.function("geometryType", geom), ff.literal(geometryType), false)); } Filter geomCheck = ff.or(typeChecks); Filter ruleFilter = base.getFilter(); Filter filter = ruleFilter == null || ruleFilter == Filter.INCLUDE ? geomCheck : ff.and(geomCheck, ruleFilter); RuleImpl extra = new RuleImpl(base); extra.setFilter(filter); extra.symbolizers().clear(); extra.symbolizers().add(symbolizer); return extra; }
pointsym.setGraphic(graphic); RuleImpl rule = new RuleImpl(); rule.symbolizers().add(pointsym);
/** Copy constructor */ public RuleImpl(Rule rule) { this.symbolizers = new ArrayList<Symbolizer>(); for (org.opengis.style.Symbolizer sym : rule.symbolizers()) { if (sym instanceof Symbolizer) { this.symbolizers.add((Symbolizer) sym); } } if (rule.getDescription() != null && rule.getDescription().getTitle() != null) { this.description.setTitle(rule.getDescription().getTitle()); } if (rule.getDescription() != null && rule.getDescription().getAbstract() != null) { this.description.setTitle(rule.getDescription().getAbstract()); } if (rule.getLegend() instanceof org.geotools.styling.Graphic) { org.geotools.styling.Graphic graphic = (org.geotools.styling.Graphic) rule.getLegend(); setLegendGraphic(new org.geotools.styling.Graphic[] {graphic}); } this.name = rule.getName(); this.filter = rule.getFilter(); this.hasElseFilter = rule.isElseFilter(); this.maxScaleDenominator = rule.getMaxScaleDenominator(); this.minScaleDenominator = rule.getMinScaleDenominator(); }
public BasicPolygonStyle(Fill fill, Stroke stroke) { PolygonSymbolizerImpl polysym = new PolygonSymbolizerImpl(); polysym.setFill(fill); polysym.setStroke(stroke); RuleImpl rule = new RuleImpl(); rule.setSymbolizers(new Symbolizer[] {polysym}); FeatureTypeStyleImpl fts = new FeatureTypeStyleImpl(); fts.setRules(new Rule[] {rule}); this.setFeatureTypeStyles(new FeatureTypeStyle[] {fts}); }
public Rule createRule( org.geotools.styling.Symbolizer[] symbolizers, Description desc, Graphic[] legends, String name, Filter filter, boolean isElseFilter, double maxScale, double minScale) { Rule r = new RuleImpl( symbolizers, desc, legends, name, filter, isElseFilter, maxScale, minScale); return r; }
/** Copy constructor */ public RuleImpl(Rule rule) { this.symbolizers = new ArrayList<Symbolizer>(); for( org.opengis.style.Symbolizer sym : rule.symbolizers() ){ if( sym instanceof Symbolizer ){ this.symbolizers.add( (Symbolizer) sym ); } } if( rule.getDescription() != null && rule.getDescription().getTitle() != null ){ this.description.setTitle( rule.getDescription().getTitle() ); } if( rule.getDescription() != null && rule.getDescription().getAbstract() != null ){ this.description.setTitle( rule.getDescription().getAbstract() ); } if( rule.getLegend() instanceof org.geotools.styling.Graphic ){ org.geotools.styling.Graphic graphic = (org.geotools.styling.Graphic) rule.getLegend(); setLegendGraphic( new org.geotools.styling.Graphic[]{ graphic } ); } this.name = rule.getName(); this.filter = rule.getFilter(); this.hasElseFilter = rule.isElseFilter(); this.maxScaleDenominator = rule.getMaxScaleDenominator(); this.minScaleDenominator = rule.getMinScaleDenominator(); }
public RuleImpl rule(String name, Description description, GraphicLegend legend, double min, double max, List<org.opengis.style.Symbolizer> symbolizers, Filter filter) { RuleImpl rule = new RuleImpl(); rule.setName(name); rule.setDescription(description); rule.setLegend(legend); rule.setMinScaleDenominator(min); rule.setMaxScaleDenominator(max); if( symbolizers != null ){ for (org.opengis.style.Symbolizer symbolizer : symbolizers) { rule.symbolizers().add( cast( symbolizer ) ); } } if( filter != null){ rule.setFilter( filter ); rule.setElseFilter(false); } else { rule.setElseFilter(true); } return rule; }
public BasicLineStyle(Stroke stroke) { LineSymbolizerImpl linesym = new LineSymbolizerImpl(); linesym.setStroke(stroke); RuleImpl rule = new RuleImpl(); rule.setSymbolizers(new org.geotools.styling.Symbolizer[] { linesym }); FeatureTypeStyleImpl fts = new FeatureTypeStyleImpl(); fts.setRules(new Rule[] { rule }); this.setFeatureTypeStyles(new org.geotools.styling.FeatureTypeStyle[] { fts }); }
/** * Reprojects spatial filters so that they match the feature source native CRS, and assuming all * literal geometries are specified in the specified declaredCRS */ private Rule reprojectSpatialFilters( Rule rule, CoordinateReferenceSystem declaredCRS, FeatureType schema) { // NPE avoidance Filter filter = rule.getFilter(); if (filter == null) { return rule; } // try to reproject the filter Filter reprojected = reprojectSpatialFilter(declaredCRS, schema, filter); if (reprojected == filter) { return rule; } // clone the rule (the style can be reused over and over, we cannot alter it) and set the // new filter Rule rr = new RuleImpl(rule); rr.setFilter(reprojected); return rr; }
protected RuleImpl(org.geotools.styling.Symbolizer[] symbolizers, org.opengis.style.Description desc, org.geotools.styling.Graphic[] legends, String name, Filter filter, boolean isElseFilter, double maxScale, double minScale){ setSymbolizers(symbolizers); description.setAbstract(desc.getAbstract()); description.setTitle(desc.getTitle()); setLegendGraphic(legends); this.name = name; this.filter = filter; hasElseFilter = isElseFilter; this.maxScaleDenominator = maxScale; this.minScaleDenominator = minScale; }
public FeatureTypeStyleImpl(org.opengis.style.FeatureTypeStyle fts){ this.description = new DescriptionImpl( fts.getDescription() ); this.featureInstances = fts.getFeatureInstanceIDs(); this.featureTypeNames = new LinkedHashSet<Name>(fts.featureTypeNames()); this.name = fts.getName(); this.rules = new ArrayList<Rule>(); if( fts.rules() != null ){ for (org.opengis.style.Rule rule : fts.rules()) { rules.add( RuleImpl.cast(rule) ); // need to deep copy? } } this.semantics = new LinkedHashSet<SemanticType>(fts.semanticTypeIdentifiers()); }
public BasicLineStyle(Stroke stroke) { LineSymbolizerImpl linesym = new LineSymbolizerImpl(); linesym.setStroke(stroke); RuleImpl rule = new RuleImpl(); rule.setSymbolizers(new Symbolizer[] { linesym }); FeatureTypeStyleImpl fts = new FeatureTypeStyleImpl(); fts.setRules(new Rule[] { rule }); this.setFeatureTypeStyles(new FeatureTypeStyle[] { fts }); }
public FeatureTypeStyleImpl featureTypeStyle( String name, Description description, Id definedFor, Set<Name> featureTypeNames, Set<SemanticType> types, List<org.opengis.style.Rule> rules) { FeatureTypeStyleImpl featureTypeStyle = new FeatureTypeStyleImpl(); featureTypeStyle.setName(name); if (description != null && description.getTitle() != null) { featureTypeStyle.setTitle(description.getTitle().toString()); } if (description != null && description.getAbstract() != null) { featureTypeStyle.setAbstract(description.getAbstract().toString()); } // featureTypeStyle.setFeatureInstanceIDs( defainedFor ); featureTypeStyle.featureTypeNames().addAll(featureTypeNames); featureTypeStyle.semanticTypeIdentifiers().addAll(types); for (org.opengis.style.Rule rule : rules) { if (rule instanceof RuleImpl) { featureTypeStyle.rules().add((RuleImpl) rule); } else { featureTypeStyle.rules().add(new RuleImpl(rule)); } } return featureTypeStyle; }
/** * Creates a deep copy clone of the rule. * * @see org.geotools.styling.Rule#clone() */ public Object clone() { try { RuleImpl clone = (RuleImpl) super.clone(); clone.graphics = new GTList(clone, "graphics"); clone.symbolizers = new GTList(clone, "symbolizers"); clone.filter = filter; // TODO: we must duplicate! Graphic[] legends = new Graphic[graphics.size()]; for (int i = 0; i < legends.length; i++) { Graphic legend = (Graphic) graphics.get(i); legends[i] = (Graphic) ((Cloneable) legend).clone(); } clone.setLegendGraphic(legends); Symbolizer[] symbArray = new Symbolizer[symbolizers.size()]; for (int i = 0; i < symbArray.length; i++) { Symbolizer symb = (Symbolizer) symbolizers.get(i); symbArray[i] = (Symbolizer) ((Cloneable) symb).clone(); } clone.setSymbolizers(symbArray); return clone; } catch (CloneNotSupportedException e) { throw new RuntimeException("This will never happen", e); } }
public BasicPolygonStyle(Fill fill, Stroke stroke) { PolygonSymbolizerImpl polysym = new PolygonSymbolizerImpl(); polysym.setFill(fill); polysym.setStroke(stroke); RuleImpl rule = new RuleImpl(); rule.setSymbolizers(new Symbolizer[] { polysym }); FeatureTypeStyleImpl fts = new FeatureTypeStyleImpl(); fts.setRules(new Rule[] { rule }); this.setFeatureTypeStyles(new FeatureTypeStyle[] { fts }); }