001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/graphics/sld/PolygonSymbolizer.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:
048: /**
049: * Used to render an interior "fill" and an outlining "stroke" for a polygon or other 2D-area
050: * geometry. If a point or line are used, the fill is ignored and the stroke is used as described in
051: * the LineSymbol. A missing Geometry element selects the default geometry. A missing Fill or Stroke
052: * element means that there will be no fill or stroke plotted, respectively. The contained elements
053: * are in the conceptual order of their being used and plotted using the "painters model", where the
054: * Fill will be rendered first, and then the Stroke will be rendered on top of the Fill.
055: * <p>
056: * ----------------------------------------------------------------------
057: * </p>
058: *
059: * @author <a href="mailto:k.lupp@web.de">Katharina Lupp</a>
060: * @version $Revision: 9340 $ $Date: 2007-12-27 04:32:12 -0800 (Thu, 27 Dec 2007) $
061: */
062:
063: public class PolygonSymbolizer extends AbstractSymbolizer implements
064: Marshallable {
065:
066: private Fill fill = null;
067:
068: private Stroke stroke = null;
069:
070: /**
071: * Creates a new PolygonSymbolizer object.
072: */
073: public PolygonSymbolizer() {
074: super (null,
075: "org.deegree.graphics.displayelements.PolygonDisplayElement");
076: setFill(new Fill());
077:
078: Stroke stroke = new Stroke();
079: setStroke(stroke);
080: }
081:
082: /**
083: * constructor initializing the class with the <PolygonSymbolizer>
084: */
085: PolygonSymbolizer(Fill fill, Stroke stroke, Geometry geometry,
086: double min, double max) {
087: super (geometry,
088: "org.deegree.graphics.displayelements.PolygonDisplayElement");
089: setFill(fill);
090: setStroke(stroke);
091: setMinScaleDenominator(min);
092: setMaxScaleDenominator(max);
093: }
094:
095: /**
096: * constructor initializing the class with the <PolygonSymbolizer>
097: */
098: PolygonSymbolizer(Fill fill, Stroke stroke, Geometry geometry,
099: String responsibleClass, double min, double max) {
100: super (geometry, responsibleClass);
101: setFill(fill);
102: setStroke(stroke);
103: setMinScaleDenominator(min);
104: setMaxScaleDenominator(max);
105: }
106:
107: /**
108: * A Fill allows area geometries to be filled. There are two types of fills: solid-color and
109: * repeated GraphicFill. In general, if a Fill element is omitted in its containing element, no
110: * fill will be rendered. The default is a solid 50%-gray (color "#808080") opaque fill.
111: *
112: * @return the fill of the polygon
113: */
114: public Fill getFill() {
115: return fill;
116: }
117:
118: /**
119: * sets the <Fill>
120: *
121: * @param fill
122: * the fill of the polygon
123: */
124: public void setFill(Fill fill) {
125: this .fill = fill;
126: }
127:
128: /**
129: * A Stroke allows a string of line segments (or any linear geometry) to be rendered. There are
130: * three basic types of strokes: solid Color, GraphicFill (stipple), and repeated GraphicStroke.
131: * A repeated graphic is plotted linearly and has its graphic symbol bended around the curves of
132: * the line string. The default is a solid black line (Color "#000000").
133: *
134: * @return the stroke of the polygon
135: */
136: public Stroke getStroke() {
137: return stroke;
138: }
139:
140: /**
141: * sets the <Stroke>
142: *
143: * @param stroke
144: * the stroke of the polygon
145: */
146: public void setStroke(Stroke stroke) {
147: this .stroke = stroke;
148: }
149:
150: /**
151: * Produces a textual representation of this object.
152: *
153: * @return the textual representation
154: */
155: public String toString() {
156: StringBuffer sb = new StringBuffer();
157: sb.append("scale constraint: >=" + minDenominator + " AND <"
158: + maxDenominator + "\n");
159: sb.append("<PolygonSymbolizer>\n");
160:
161: if (getGeometry() != null) {
162: sb.append(getGeometry()).append("\n");
163: }
164:
165: if (getFill() != null) {
166: sb.append(getFill()).append("\n");
167: }
168:
169: if (getStroke() != null) {
170: sb.append(getStroke()).append("\n");
171: }
172:
173: sb.append("</PolygonSymbolizer>\n");
174:
175: return sb.toString();
176: }
177:
178: /**
179: * exports the content of the PolygonSymbolizer as XML formated String
180: *
181: * @return xml representation of the PolygonSymbolizer
182: */
183: public String exportAsXML() {
184:
185: StringBuffer sb = new StringBuffer(1000);
186: sb.append("<PolygonSymbolizer>");
187: if (geometry != null) {
188: sb.append(((Marshallable) geometry).exportAsXML());
189: }
190: if (fill != null) {
191: sb.append(((Marshallable) fill).exportAsXML());
192: }
193: if (stroke != null) {
194: sb.append(((Marshallable) stroke).exportAsXML());
195: }
196: sb.append("</PolygonSymbolizer>");
197:
198: return sb.toString();
199: }
200: }
|