001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/graphics/sld/FeatureTypeStyle.java $
002: /*---------------- FILE HEADER ------------------------------------------
003:
004: This file is part of deegree.
005: Copyright (C) 2001-2008 by:
006: EXSE, Department of Geography, University of Bonn
007: http://www.giub.uni-bonn.de/deegree/
008: lat/lon GmbH
009: http://www.lat-lon.de
010:
011: This library is free software; you can redistribute it and/or
012: modify it under the terms of the GNU Lesser General Public
013: License as published by the Free Software Foundation; either
014: version 2.1 of the License, or (at your option) any later version.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: Contact:
026:
027: Andreas Poth
028: lat/lon GmbH
029: Aennchenstr. 19
030: 53115 Bonn
031: Germany
032: E-Mail: poth@lat-lon.de
033:
034: Prof. Dr. Klaus Greve
035: Department of Geography
036: University of Bonn
037: Meckenheimer Allee 166
038: 53115 Bonn
039: Germany
040: E-Mail: greve@giub.uni-bonn.de
041:
042:
043: ---------------------------------------------------------------------------*/
044: package org.deegree.graphics.sld;
045:
046: import java.util.ArrayList;
047: import java.util.List;
048:
049: import org.deegree.framework.xml.Marshallable;
050:
051: /**
052: * The FeatureTypeStyle defines the styling that is to be applied to a single feature type of a
053: * layer). This element may also be externally re-used outside of the scope of WMSes and layers.
054: * <p>
055: * </p>
056: * The FeatureTypeStyle element identifies that explicit separation in SLD between the handling of
057: * layers and the handling of features of specific feature types. The layer concept is unique to WMS
058: * and SLD, but features are used more generally, such as in WFS and GML, so this explicit
059: * separation is important.
060: * <p>
061: * ----------------------------------------------------------------------
062: * </p>
063: *
064: * @author <a href="mailto:k.lupp@web.de">Katharina Lupp</a>
065: * @version $Revision: 9340 $ $Date: 2007-12-27 04:32:12 -0800 (Thu, 27 Dec 2007) $
066: */
067: public class FeatureTypeStyle implements Marshallable {
068: private List<Rule> rules = null;
069:
070: private List<String> semanticTypeIdentifier = null;
071:
072: private String abstract_ = null;
073:
074: private String featureTypeName = null;
075:
076: private String name = null;
077:
078: private String title = null;
079:
080: /**
081: * default constructor
082: */
083: FeatureTypeStyle() {
084: semanticTypeIdentifier = new ArrayList<String>();
085: rules = new ArrayList<Rule>();
086: }
087:
088: /**
089: * constructor initializing the class with the <FeatureTypeStyle>
090: */
091: FeatureTypeStyle(String name, String title, String abstract_,
092: String featureTypeName, String[] semanticTypeIdentifier,
093: Rule[] rules) {
094: this ();
095: setName(name);
096: setTitle(title);
097: setAbstract(abstract_);
098: setFeatureTypeName(featureTypeName);
099: setSemanticTypeIdentifier(semanticTypeIdentifier);
100: setRules(rules);
101: }
102:
103: /**
104: * The Name element does not have an explicit use at present, though it conceivably might be
105: * used to reference a feature style in some feature-style library.
106: *
107: * @return name
108: *
109: */
110: public String getName() {
111: return name;
112: }
113:
114: /**
115: * The Name element does not have an explicit use at present, though it conceivably might be
116: * used to reference a feature style in some feature-style library. Sets the <Name> o
117: *
118: * @param name
119: * the name
120: *
121: */
122: public void setName(String name) {
123: this .name = name;
124: }
125:
126: /**
127: * human-readable information about the style
128: *
129: * @return the title of the FeatureTypeStyle
130: *
131: */
132: public String getTitle() {
133: return title;
134: }
135:
136: /**
137: * sets the <Title>
138: *
139: * @param title
140: * the title of the FeatureTypeStyle
141: *
142: */
143: public void setTitle(String title) {
144: this .title = title;
145: }
146:
147: /**
148: * human-readable information about the style
149: *
150: * @return an abstract of the FeatureTypeStyle
151: */
152: public String getAbstract() {
153: return abstract_;
154: }
155:
156: /**
157: * sets <Abstract>
158: *
159: * @param abstract_
160: * an abstract of the FeatureTypeStyle
161: */
162: public void setAbstract(String abstract_) {
163: this .abstract_ = abstract_;
164: }
165:
166: /**
167: * returns the name of the affected feature type
168: *
169: * @return the name of the FeatureTypeStyle as String
170: *
171: */
172: public String getFeatureTypeName() {
173: return featureTypeName;
174: }
175:
176: /**
177: * sets the name of the affected feature type
178: *
179: * @param featureTypeName
180: * the name of the FeatureTypeStyle
181: *
182: */
183: public void setFeatureTypeName(String featureTypeName) {
184: this .featureTypeName = featureTypeName;
185: }
186:
187: /**
188: * The SemanticTypeIdentifier is experimental and is intended to be used to identify what the
189: * feature style is suitable to be used for using community- controlled name(s). For example, a
190: * single style may be suitable to use with many different feature types. The syntax of the
191: * SemanticTypeIdentifier string is undefined, but the strings generic:line, generic:polygon,
192: * generic:point, generic:text, generic:raster, and generic:any are reserved to indicate that a
193: * FeatureTypeStyle may be used with any feature type with the corresponding default geometry
194: * type (i.e., no feature properties are referenced in the feature-type style).
195: *
196: * @return the SemanticTypeIdentifiers from the FeatureTypeStyle as String-Array
197: *
198: */
199: public String[] getSemanticTypeIdentifier() {
200: return semanticTypeIdentifier
201: .toArray(new String[semanticTypeIdentifier.size()]);
202: }
203:
204: /**
205: * Sets the SemanticTypeIdentifiers.
206: *
207: * @param semanticTypeIdentifiers
208: * SemanticTypeIdentifiers for the FeatureTypeStyle
209: */
210: public void setSemanticTypeIdentifier(
211: String[] semanticTypeIdentifiers) {
212: semanticTypeIdentifier.clear();
213:
214: if (semanticTypeIdentifiers != null) {
215: for (int i = 0; i < semanticTypeIdentifiers.length; i++) {
216: semanticTypeIdentifier.add(semanticTypeIdentifiers[i]);
217: }
218: }
219: }
220:
221: /**
222: * adds the <SemanticTypeIdentifier>
223: *
224: * @param semanticTypeIdentifier
225: * SemanticTypeIdentifier to add
226: */
227: public void addSemanticTypeIdentifier(String semanticTypeIdentifier) {
228: this .semanticTypeIdentifier.add(semanticTypeIdentifier);
229: }
230:
231: /**
232: * Removes an <SemanticTypeIdentifier>.
233: *
234: * @param semanticTypeIdentifier
235: * SemanticTypeIdentifier to remove
236: */
237: public void removeSemanticTypeIdentifier(
238: String semanticTypeIdentifier) {
239: this .semanticTypeIdentifier.remove(this .semanticTypeIdentifier
240: .indexOf(semanticTypeIdentifier));
241: }
242:
243: /**
244: * Rules are used to group rendering instructions by feature-property conditions and map scales.
245: * Rule definitions are placed immediately inside of feature-style definitions.
246: *
247: * @return the rules of the FeatureTypeStyle as Array
248: *
249: */
250: public Rule[] getRules() {
251: return rules.toArray(new Rule[rules.size()]);
252: }
253:
254: /**
255: * sets the <Rules>
256: *
257: * @param rules
258: * the rules of the FeatureTypeStyle as Array
259: */
260: public void setRules(Rule[] rules) {
261: this .rules.clear();
262:
263: if (rules != null) {
264: for (int i = 0; i < rules.length; i++) {
265: this .rules.add(rules[i]);
266: }
267: }
268: }
269:
270: /**
271: * adds the <Rules>
272: *
273: * @param rule
274: * a rule
275: */
276: public void addRule(Rule rule) {
277: rules.add(rule);
278: }
279:
280: /**
281: * removes a rule
282: *
283: * @param rule
284: * a rule
285: */
286: public void removeRule(Rule rule) {
287: rules.remove(rules.indexOf(rule));
288: }
289:
290: /**
291: * exports the content of the FeatureTypeStyle as XML formated String
292: *
293: * @return xml representation of the FeatureTypeStyle
294: */
295: public String exportAsXML() {
296:
297: StringBuffer sb = new StringBuffer(1000);
298: sb.append("<FeatureTypeStyle>");
299: if (name != null && !name.equals("")) {
300: sb.append("<Name>").append(name).append("</Name>");
301: }
302: if (title != null && !title.equals("")) {
303: sb.append("<Title>").append(title).append("</Title>");
304: }
305: if (abstract_ != null && !abstract_.equals("")) {
306: sb.append("<Abstract>").append(abstract_).append(
307: "</Abstract>");
308: }
309: if (featureTypeName != null && !featureTypeName.equals("")) {
310: sb.append("<FeatureTypeName>").append(featureTypeName)
311: .append("</FeatureTypeName>");
312: }
313: for (int i = 0; i < semanticTypeIdentifier.size(); i++) {
314: sb.append("<SemanticTypeIdentifier>").append(
315: semanticTypeIdentifier.get(i)).append(
316: "</SemanticTypeIdentifier>");
317: }
318: for (int i = 0; i < rules.size(); i++) {
319: sb.append(((Marshallable) rules.get(i)).exportAsXML());
320: }
321: sb.append("</FeatureTypeStyle>");
322:
323: return sb.toString();
324: }
325: }
|