    001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.4_testing/src/org/deegree/graphics/sld/PointSymbolizer.java $
    002    /*----------------------------------------------------------------------------
    003     This file is part of deegree, http://deegree.org/
    004     Copyright (C) 2001-2009 by:
    005       Department of Geography, University of Bonn
    006     and
    007       lat/lon GmbH
    008
    009     This library is free software; you can redistribute it and/or modify it under
    010     the terms of the GNU Lesser General Public License as published by the Free
    011     Software Foundation; either version 2.1 of the License, or (at your option)
    012     any later version.
    013     This library is distributed in the hope that it will be useful, but WITHOUT
    014     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    015     FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
    016     details.
    017     You should have received a copy of the GNU Lesser General Public License
    018     along with this library; if not, write to the Free Software Foundation, Inc.,
    019     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    020
    021     Contact information:
    022
    023     lat/lon GmbH
    024     Aennchenstr. 19, 53177 Bonn
    025     Germany
    026     http://lat-lon.de/
    027
    028     Department of Geography, University of Bonn
    029     Prof. Dr. Klaus Greve
    030     Postfach 1147, 53001 Bonn
    031     Germany
    032     http://www.geographie.uni-bonn.de/deegree/
    033
    034     e-mail: info@deegree.org
    035    ----------------------------------------------------------------------------*/
    036    package org.deegree.graphics.sld;
    037
    038    import org.deegree.framework.xml.Marshallable;
    039
    040    /**
    041     * Used to render a "graphic" at a point. If a line-string or polygon geometry is used with this
    042     * symbol, then the semantic is to use the centroid of the geometry, or any similar representative
    043     * point. The meaning of the contained elements are discussed with the element definitions below. If
    044     * the Geometry element is omitted, then the "default" geometry for the feature type is used. (Many
    045     * feature types will have only one geometry attribute.) If the Graphic element is omitted, then
    046     * nothing will be plotted.
    047     * <p>
    048     * ----------------------------------------------------------------------
    049     * </p>
    050     *
    051     * @author <a href="mailto:k.lupp@web.de">Katharina Lupp</a>
    052     * @version $Revision: 18195 $ $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
    053     */
    054
    055    public class PointSymbolizer extends AbstractSymbolizer implements Marshallable {
    056
    057        private Graphic graphic = null;
    058
    059        /**
    060         * Creates a new PointSymbolizer object.
    061         */
    062        public PointSymbolizer() {
    063            super( null, "org.deegree.graphics.displayelements.PointDisplayElement" );
    064            Stroke stroke = new Stroke();
    065            Fill fill = new Fill();
    066            Mark mark = new Mark( "square", stroke, fill );
    067            graphic = StyleFactory.createGraphic( null, mark, 1, 5, 0 );
    068        }
    069
    070        /**
    071         * constructor initializing the class with the <PointSymbolizer>
    072         * @param graphic
    073         * @param geometry
    074         * @param min
    075         * @param max
    076         */
    077        PointSymbolizer( Graphic graphic, Geometry geometry, double min, double max ) {
    078            super( geometry, "org.deegree.graphics.displayelements.PointDisplayElement" );
    079
    080            if ( graphic == null ) {
    081                graphic = new Graphic();
    082            }
    083
    084            setGraphic( graphic );
    085            setMinScaleDenominator( min );
    086            setMaxScaleDenominator( max );
    087        }
    088
    089        /**
    090         * constructor initializing the class with the <PointSymbolizer>
    091         * @param graphic
    092         * @param geometry
    093         * @param responsibleClass
    094         * @param min
    095         * @param max
    096         */
    097        PointSymbolizer( Graphic graphic, Geometry geometry, String responsibleClass, double min, double max ) {
    098            super( geometry, responsibleClass );
    099
    100            if ( graphic == null ) {
    101                graphic = new Graphic();
    102            }
    103
    104            setGraphic( graphic );
    105            setMinScaleDenominator( min );
    106            setMaxScaleDenominator( max );
    107        }
    108
    109        /**
    110         * A Graphic is a "graphic symbol" with an inherent shape, color, and size. Graphics can either
    111         * be referenced from an external URL in a common format (such as GIF or SVG) or may be derived
    112         * from a Mark. Multiple external URLs may be referenced with the semantic that they all provide
    113         * the same graphic in different formats. The "hot spot" to use for rendering at a point or the
    114         * start and finish handle points to use for rendering a graphic along a line must either be
    115         * inherent in the external format or are system- dependent. The default size of an image format
    116         * (such as GIF) is the inherent size of the image. The default size of a format without an
    117         * inherent size is 16 pixels in height and the corresponding aspect in width. If a size is
    118         * specified, the height of the graphic will be scaled to that size and the corresponding aspect
    119         * will be used for the width. The default if neither an ExternalURL nor a Mark is specified is
    120         * to use the default Mark with a size of 6 pixels. The size is in pixels and the rotation is in
    121         * degrees clockwise, with 0 (default) meaning no rotation. In the case that a Graphic is
    122         * derived from a font-glyph Mark, the Size specified here will be used for the final rendering.
    123         * Allowed CssParameters are "opacity", "size", and "rotation".
    124         *
    125         * @return the graphic of the point
    126         *
    127         */
    128        public Graphic getGraphic() {
    129            return graphic;
    130        }
    131
    132        /**
    133         * sets the <Graphic>
    134         *
    135         * @param graphic
    136         *            the graphic of the point
    137         *
    138         */
    139        public void setGraphic( Graphic graphic ) {
    140            this.graphic = graphic;
    141        }
    142
    143        /**
    144         * exports the content of the PointSymbolizer as XML formated String
    145         *
    146         * @return xml representation of the PointSymbolizer
    147         */
    148        public String exportAsXML() {
    149
    150            StringBuffer sb = new StringBuffer( 1000 );
    151            sb.append( "<PointSymbolizer>" );
    152            if ( geometry != null ) {
    153                sb.append( ( (Marshallable) geometry ).exportAsXML() );
    154            }
    155            if ( graphic != null ) {
    156                sb.append( ( (Marshallable) graphic ).exportAsXML() );
    157            }
    158            sb.append( "</PointSymbolizer>" );
    159
    160            return sb.toString();
    161        }
    162    }