001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/graphics/sld/CssParameter.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 org.deegree.framework.xml.Marshallable;
047: import org.deegree.model.feature.Feature;
048: import org.deegree.model.filterencoding.FilterEvaluationException;
049:
050: /**
051: * The simple SVG/CSS2 styling parameters are given with the CssParameter element, which is defined
052: * as follows:
053: *
054: * <pre>
055: *
056: * <xs:element name="CssParameter" type="sld:ParameterValueType"/>
057: * <xs:complexType name="ParameterValueType" mixed="true">
058: * <xs:choice minOccurs="0" maxOccurs="unbounded">
059: * <xs:element ref="wfs:expression"/>
060: * </xs:choice>
061: * </xs:complexType>
062: *
063: * </pre>
064: *
065: * The parameter values are allowed to be complex expressions for maximum flexibility. The
066: * mixed="true" definition means that regular text may be mixed in with various sub-expressions,
067: * implying a text-substitution model for parameter values. Numeric and character-string data types
068: * are not distinguished, which may cause some complications.
069: * <p>
070: * </p>
071: * Here are some usage examples:
072: *
073: * <pre>
074: *
075: * 1. <CssParameter name="stroke-width">3</CssParameter>
076: * 2. <CssParameter name="stroke-width">
077: * <wfs:Literal>3</wfs:Literal>
078: * </CssParameter>
079: * 3. <CssParameter name="stroke-width">
080: * <wfs:Add>
081: * <wfs:PropertyName>/A</wfs:PropertyName>
082: * <wfs:Literal>2</wfs:Literal>
083: * </wfs:Add>
084: * </CssParameter>
085: * 4. <Label>This is city "<wfs:PropertyName>/NAME</wfs:PropertyName>"
086: * of state <wfs:PropertyName>/STATE</wfs:PropertyName></Label>
087: *
088: * </pre>
089: *
090: * The allowed SVG/CSS styling parameters for a stroke are: stroke (color), stroke-opacity,
091: * stroke-width, stroke-linejoin, stroke-linecap, stroke-dasharray, and stroke-dashoffset. The
092: * chosen parameter is given by the name attribute of the CssParameter element.
093: * <p>
094: *
095: * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
096: * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider </a>
097: * @version $Revision: 9340 $ $Date: 2007-12-27 04:32:12 -0800 (Thu, 27 Dec 2007) $
098: */
099:
100: public class CssParameter implements Marshallable {
101:
102: private ParameterValueType pvt = null;
103:
104: private String name = null;
105:
106: /**
107: * constructor initializing the class with the <CssParameter>
108: */
109: CssParameter(String name, ParameterValueType pvt) {
110: this .name = name;
111: this .pvt = pvt;
112: }
113:
114: /**
115: * Returns the name attribute's value of the CssParameter.
116: * <p>
117: *
118: * @return the value of the name attribute of the CssParameter
119: */
120: String getName() {
121: return name;
122: }
123:
124: /**
125: * Sets the name attribute's value of the CssParameter.
126: * <p>
127: *
128: * @param name
129: * the value of the name attribute of the CssParameter
130: */
131: void setName(String name) {
132: this .name = name;
133: }
134:
135: /**
136: * Returns the value of the CssParameter as an <tt>ParameterValueType</tt>.
137: * <p>
138: *
139: * @return the mixed content of the element
140: */
141: public ParameterValueType getValue() {
142: return pvt;
143: }
144:
145: /**
146: * Sets the value of the CssParameter as an <tt>ParameterValueType</tt>.
147: * <p>
148: *
149: * @param value
150: * the mixed content of the element
151: */
152: void setValue(ParameterValueType value) {
153: this .pvt = value;
154: }
155:
156: /**
157: * Returns the (evaluated) value of the CssParameter as a simple <tt>String</tt>.
158: * <p>
159: *
160: * @param feature
161: * specifies the <tt>Feature</tt> to be used for evaluation of the underlying
162: * 'sld:ParameterValueType'
163: * @return the (evaluated) <tt>String</tt> value of the parameter
164: * @throws FilterEvaluationException
165: * if the evaluations fails
166: */
167: String getValue(Feature feature) throws FilterEvaluationException {
168: return pvt.evaluate(feature);
169: }
170:
171: /**
172: * Sets the value of the CssParameter as a simple <tt>String</tt>.
173: * <p>
174: *
175: * @param value
176: * CssParameter-Value to be set
177: */
178: void setValue(String value) {
179: ParameterValueType pvt = null;
180: pvt = StyleFactory.createParameterValueType("" + value);
181: this .pvt = pvt;
182: }
183:
184: /**
185: * exports the content of the CssParameter as XML formated String
186: *
187: * @return xml representation of the CssParameter
188: */
189: public String exportAsXML() {
190:
191: StringBuffer sb = new StringBuffer("<CssParameter name=");
192: sb.append("'" + name + "'>");
193: sb.append(((Marshallable) pvt).exportAsXML());
194: sb.append("</CssParameter>");
195:
196: return sb.toString();
197: }
198: }
|