001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/graphics/sld/LineSymbolizer.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 "stroke" along a linear geometry. If a point geometry is used, it should be
042     * interpreted as a line of zero length and two end caps. If a polygon is used, then its closed
043     * outline is used as the line string (with no end caps). A missing Geometry element selects the
044     * default geometry. A missing Stroke element means that nothing will be plotted.
045     * <p>
046     * ----------------------------------------------------------------------
047     * </p>
048     *
049     * @author <a href="mailto:k.lupp@web.de">Katharina Lupp</a>
050     * @version $Revision: 18195 $ $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
051     */
052    
053    public class LineSymbolizer extends AbstractSymbolizer implements Marshallable {
054    
055        private Stroke stroke = null;
056    
057        /**
058         * Creates a new LineSymbolizer object.
059         */
060        public LineSymbolizer() {
061            super( null, "org.deegree.graphics.displayelements.LineStringDisplayElement" );
062    
063            Stroke stroke = new Stroke();
064            setStroke( stroke );
065        }
066    
067        /**
068         * constructor initializing the class with the LineSymbolizer
069         * @param stroke
070         * @param geometry
071         * @param min
072         * @param max
073         */
074        LineSymbolizer( Stroke stroke, Geometry geometry, double min, double max ) {
075            super( geometry, "org.deegree.graphics.displayelements.LineStringDisplayElement" );
076            setStroke( stroke );
077            setMinScaleDenominator( min );
078            setMaxScaleDenominator( max );
079        }
080    
081        /**
082         * constructor initializing the class with the LineSymbolizer
083         * @param stroke
084         * @param geometry
085         * @param responsibleClass
086         * @param min
087         * @param max
088         */
089        LineSymbolizer( Stroke stroke, Geometry geometry, String responsibleClass, double min, double max ) {
090            super( geometry, responsibleClass );
091            // super( geometry, "org.deegree.graphics.displayelements.LineStringDisplayElement" );
092            setStroke( stroke );
093            setMinScaleDenominator( min );
094            setMaxScaleDenominator( max );
095        }
096    
097        /**
098         * A Stroke allows a string of line segments (or any linear geometry) to be rendered. There are
099         * three basic types of strokes: solid Color, GraphicFill (stipple), and repeated GraphicStroke.
100         * A repeated graphic is plotted linearly and has its graphic symbol bended around the curves of
101         * the line string. The default is a solid black line (Color "#000000").
102         *
103         * @return the Stroke
104         */
105        public Stroke getStroke() {
106            return stroke;
107        }
108    
109        /**
110         * sets the <Stroke>
111         *
112         * @param stroke
113         *            the Stroke
114         *
115         */
116        public void setStroke( Stroke stroke ) {
117            this.stroke = stroke;
118        }
119    
120        /**
121         * exports the content of the LineSymbolizer as XML formated String
122         *
123         * @return xml representation of the LineSymbolizer
124         */
125        public String exportAsXML() {
126    
127            StringBuffer sb = new StringBuffer( 1000 );
128            sb.append( "<LineSymbolizer>" );
129            if ( geometry != null ) {
130                sb.append( ( (Marshallable) geometry ).exportAsXML() );
131            }
132            if ( stroke != null ) {
133                sb.append( ( (Marshallable) stroke ).exportAsXML() );
134            }
135            sb.append( "</LineSymbolizer>" );
136    
137            return sb.toString();
138        }
139    }