001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/graphics/sld/PointSymbolizer.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 a "graphic" at a point. If a line-string or polygon geometry is used with this
050 * symbol, then the semantic is to use the centroid of the geometry, or any similar representative
051 * point. The meaning of the contained elements are discussed with the element definitions below. If
052 * the Geometry element is omitted, then the "default" geometry for the feature type is used. (Many
053 * feature types will have only one geometry attribute.) If the Graphic element is omitted, then
054 * nothing will be plotted.
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 13:32:12 +0100 (Do, 27 Dez 2007) $
061 */
062
063 public class PointSymbolizer extends AbstractSymbolizer implements Marshallable {
064
065 private Graphic graphic = null;
066
067 /**
068 * Creates a new PointSymbolizer object.
069 */
070 public PointSymbolizer() {
071 super( null, "org.deegree.graphics.displayelements.PointDisplayElement" );
072 Stroke stroke = new Stroke();
073 Fill fill = new Fill();
074 Mark mark = new Mark( "square", stroke, fill );
075 graphic = StyleFactory.createGraphic( null, mark, 1, 5, 0 );
076 }
077
078 /**
079 * constructor initializing the class with the <PointSymbolizer>
080 */
081 PointSymbolizer( Graphic graphic, Geometry geometry, double min, double max ) {
082 super( geometry, "org.deegree.graphics.displayelements.PointDisplayElement" );
083
084 if ( graphic == null ) {
085 graphic = new Graphic();
086 }
087
088 setGraphic( graphic );
089 setMinScaleDenominator( min );
090 setMaxScaleDenominator( max );
091 }
092
093 /**
094 * constructor initializing the class with the <PointSymbolizer>
095 */
096 PointSymbolizer( Graphic graphic, Geometry geometry, String responsibleClass, double min, double max ) {
097 super( geometry, responsibleClass );
098
099 if ( graphic == null ) {
100 graphic = new Graphic();
101 }
102
103 setGraphic( graphic );
104 setMinScaleDenominator( min );
105 setMaxScaleDenominator( max );
106 }
107
108 /**
109 * A Graphic is a "graphic symbol" with an inherent shape, color, and size. Graphics can either
110 * be referenced from an external URL in a common format (such as GIF or SVG) or may be derived
111 * from a Mark. Multiple external URLs may be referenced with the semantic that they all provide
112 * the same graphic in different formats. The "hot spot" to use for rendering at a point or the
113 * start and finish handle points to use for rendering a graphic along a line must either be
114 * inherent in the external format or are system- dependent. The default size of an image format
115 * (such as GIF) is the inherent size of the image. The default size of a format without an
116 * inherent size is 16 pixels in height and the corresponding aspect in width. If a size is
117 * specified, the height of the graphic will be scaled to that size and the corresponding aspect
118 * will be used for the width. The default if neither an ExternalURL nor a Mark is specified is
119 * to use the default Mark with a size of 6 pixels. The size is in pixels and the rotation is in
120 * degrees clockwise, with 0 (default) meaning no rotation. In the case that a Graphic is
121 * derived from a font-glyph Mark, the Size specified here will be used for the final rendering.
122 * Allowed CssParameters are "opacity", "size", and "rotation".
123 *
124 * @return the graphic of the point
125 *
126 */
127 public Graphic getGraphic() {
128 return graphic;
129 }
130
131 /**
132 * sets the <Graphic>
133 *
134 * @param graphic
135 * the graphic of the point
136 *
137 */
138 public void setGraphic( Graphic graphic ) {
139 this.graphic = graphic;
140 }
141
142 /**
143 * exports the content of the PointSymbolizer as XML formated String
144 *
145 * @return xml representation of the PointSymbolizer
146 */
147 public String exportAsXML() {
148
149 StringBuffer sb = new StringBuffer( 1000 );
150 sb.append( "<PointSymbolizer>" );
151 if ( geometry != null ) {
152 sb.append( ( (Marshallable) geometry ).exportAsXML() );
153 }
154 if ( graphic != null ) {
155 sb.append( ( (Marshallable) graphic ).exportAsXML() );
156 }
157 sb.append( "</PointSymbolizer>" );
158
159 return sb.toString();
160 }
161 }