001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2002, Centre for Computational Geography
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.styling;
018:
019: import org.opengis.filter.Filter;
020: import org.geotools.event.GTComponent;
021:
022: /**
023: * A rule is used to attach a condition to, and group, the individual
024: * symbolizers used for rendering. The Title and Abstract describe the rule
025: * and may be used to generate a legend, as may the LegendGraphic. The Filter,
026: * ElseFilter, MinScale and MaxScale elements allow the selection of features
027: * and rendering scales for a rule. The scale selection works as follows.
028: * When a map is to be rendered, the scale denominator is computed and all
029: * rules in all UserStyles that have a scale outside of the request range are
030: * dropped. (This also includes Rules that have an ElseFilter.) An
031: * ElseFilter is simply an ELSE condition to the conditions (Filters) of all
032: * other rules in the same UserStyle. The exact meaning of the ElseFilter is
033: * determined after Rules have been eliminated for not fitting the rendering
034: * scale. This definition of the behaviour of ElseFilters may seem a little
035: * strange, but it allows for scale-dependent and scale-independent ELSE
036: * conditions. For the Filter, only SqlExpression is available for
037: * specification, but this is a hack and should be replaced with Filter as
038: * defined in WFS. A missing Filter element means "always true". If a set of
039: * Rules has no ElseFilters, then some features may not be rendered (which is
040: * presumably the desired behavior). The Scales are actually scale
041: * denominators (as double floats), so "10e6" would be interpreted as 1:10M. A
042: * missing MinScale means there is no lower bound to the scale-denominator
043: * range (lim[x->0+](x)), and a missing MaxScale means there is no upper bound
044: * (infinity). 0.28mm
045: *
046: * <p>
047: * The details of this object are taken from the <a
048: * href="https://portal.opengeospatial.org/files/?artifact_id=1188"> OGC
049: * Styled-Layer Descriptor Report (OGC 02-070) version 1.0.0.</a>:
050: * <pre><code>
051: * <xsd:element name="Rule">
052: * <xsd:annotation>
053: * <xsd:documentation>
054: * A Rule is used to attach property/scale conditions to and group
055: * the individual symbolizers used for rendering.
056: * </xsd:documentation>
057: * </xsd:annotation>
058: * <xsd:complexType>
059: * <xsd:sequence>
060: * <xsd:element ref="sld:Name" minOccurs="0"/>
061: * <xsd:element ref="sld:Title" minOccurs="0"/>
062: * <xsd:element ref="sld:Abstract" minOccurs="0"/>
063: * <xsd:element ref="sld:LegendGraphic" minOccurs="0"/>
064: * <xsd:choice minOccurs="0">
065: * <xsd:element ref="ogc:Filter"/>
066: * <xsd:element ref="sld:ElseFilter"/>
067: * </xsd:choice>
068: * <xsd:element ref="sld:MinScaleDenominator" minOccurs="0"/>
069: * <xsd:element ref="sld:MaxScaleDenominator" minOccurs="0"/>
070: * <xsd:element ref="sld:Symbolizer" maxOccurs="unbounded"/>
071: * </xsd:sequence>
072: * </xsd:complexType>
073: * </xsd:element>
074: * </code></pre>
075: * </p>
076: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/api/src/main/java/org/geotools/styling/Rule.java $
077: */
078: public interface Rule extends GTComponent {
079: /**
080: * Gets the name of the rule.
081: *
082: * @return The name of the rule. This provides a way to identify a rule.
083: */
084: String getName();
085:
086: /**
087: * Sets the name of the rule.
088: *
089: * @param name The name of the rule. This provides a way to identify a
090: * rule.
091: */
092: void setName(String name);
093:
094: /**
095: * Gets the title.
096: *
097: * @return The title of the rule. This is a brief, human readable,
098: * description of the rule.
099: */
100: String getTitle();
101:
102: /**
103: * Sets the title.
104: *
105: * @param title The title of the rule. This is a brief, human readable,
106: * description of the rule.
107: */
108: void setTitle(String title);
109:
110: /**
111: * Gets the abstract text for the rule.
112: *
113: * @return The abstract text, a more detailed description of the rule.
114: */
115: String getAbstract();
116:
117: /**
118: * Sets the abstract text for the rule.
119: *
120: * @param abstractStr The abstract text, a more detailed description of the
121: * rule.
122: */
123: void setAbstract(String abstractStr);
124:
125: /**
126: * The smallest value for scale denominator at which symbolizers contained
127: * by this rule should be applied.
128: *
129: * @return The smallest (inclusive) denominator value that this rule will
130: * be active for.
131: */
132: double getMinScaleDenominator();
133:
134: /**
135: * The smallest value for scale denominator at which symbolizers contained
136: * by this rule should be applied.
137: *
138: * @param scale The smallest (inclusive) denominator value that this rule
139: * will be active for.
140: */
141: void setMinScaleDenominator(double scale);
142:
143: /**
144: * The largest value for scale denominator at which symbolizers contained
145: * by this rule should be applied.
146: *
147: * @return The largest (exclusive) denominator value that this rule will be
148: * active for.
149: */
150: double getMaxScaleDenominator();
151:
152: /**
153: * The largest value for scale denominator at which symbolizers contained
154: * by this rule should be applied.
155: *
156: * @param scale The largest (exclusive) denominator value that this rule
157: * will be active for.
158: */
159: void setMaxScaleDenominator(double scale);
160:
161: Filter getFilter();
162:
163: void setFilter(Filter filter);
164:
165: boolean hasElseFilter();
166:
167: void setIsElseFilter(boolean defaultb);
168:
169: /**
170: * A set of equivalent Graphics in different formats which can be used as a
171: * legend against features stylized by the symbolizers in this rule.
172: *
173: * @return An array of Graphic objects, any of which can be used as the
174: * legend.
175: */
176: Graphic[] getLegendGraphic();
177:
178: /**
179: * A set of equivalent Graphics in different formats which can be used as a
180: * legend against features stylized by the symbolizers in this rule.
181: *
182: * @param graphics An array of Graphic objects, any of which can be used as
183: * the legend.
184: */
185: void setLegendGraphic(Graphic[] graphics);
186:
187: /**
188: * The symbolizers contain the actual styling information for different
189: * geometry types. A single feature may be rendered by more than one of
190: * the symbolizers returned by this method. It is important that the
191: * symbolizers be applied in the order in which they are returned if the
192: * end result is to be as intended. All symbolizers should be applied to
193: * all features which make it through the filters in this rule regardless
194: * of the features' geometry. For example, a polygon symbolizer should be
195: * applied to line geometries and even points. If this is not the desired
196: * beaviour, ensure that either the filters block inappropriate features
197: * or that the FeatureTypeStyler which contains this rule has its
198: * FeatureTypeName or SemanticTypeIdentifier set appropriately.
199: *
200: * @return An array of symbolizers to be applied, in sequence, to all of
201: * the features addressed by the FeatureTypeStyler which contains
202: * this rule.
203: */
204: Symbolizer[] getSymbolizers();
205:
206: /**
207: * The symbolizers contain the actual styling information for different
208: * geometry types. A single feature may be rendered by more than one of
209: * the symbolizers returned by this method. It is important that the
210: * symbolizers be applied in the order in which they are returned if the
211: * end result is to be as intended. All symbolizers should be applied to
212: * all features which make it through the filters in this rule regardless
213: * of the features' geometry. For example, a polygon symbolizer should be
214: * applied to line geometries and even points. If this is not the desired
215: * beaviour, ensure that either the filters block inappropriate features
216: * or that the FeatureTypeStyler which contains this rule has its
217: * FeatureTypeName or SemanticTypeIdentifier set appropriately.
218: *
219: * @param symbolizers An array of symbolizers to be applied, in sequence,
220: * to all of the features addressed by the FeatureTypeStyler which
221: * contains this rule.
222: */
223: void setSymbolizers(Symbolizer[] symbolizers);
224:
225: void accept(StyleVisitor visitor);
226: }
|