001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/portal/context/Style.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.portal.context;
045    
046    import org.deegree.ogcbase.ImageURL;
047    
048    
049    /**
050     * this class encapsulates the style description as defined by the OGC Web
051     * Map Context specification
052     *
053     * @version $Revision: 9346 $
054     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
055     */
056    public class Style  {
057        private ImageURL legendURL = null;
058        private SLD sld = null;
059        private String abstract_ = null;
060        private String name = null;
061        private String title = null;
062        private boolean current = false;
063    
064        /**
065         * Creates a new Style object. 
066         *
067         * @param name The name of the style
068         * @param title The human-readable title of the style
069         * @param abstract_ A narrative description of the current style
070         * @param legendURL location of an image of a map legend describing the 
071         *                  current style
072         * @param current true the current style is selected.
073         *
074         * @throws ContextException 
075         */
076        public Style( String name, String title, String abstract_, ImageURL legendURL, 
077                      boolean current ) throws ContextException {
078            setName( name );
079            setTitle( title );
080            setAbstract( abstract_ );
081            setLegendURL( legendURL );
082            setCurrent( current );
083        }
084        
085        /**
086         * Creates a new Style object. 
087         *
088         * @param sld define the style(s) of the layer with a <SLD> element.
089         * @param current true the current style is selected.
090         *
091         * @throws ContextException 
092         */
093        public Style( SLD sld, boolean current ) throws ContextException {
094            setSld( sld );
095            setCurrent( current );
096        }
097    
098        /**
099         * The name of the style (extracted from Capabilities by the Context document 
100         * creator).
101         *
102         * @return 
103         */
104        public String getName() {
105            return name;
106        }
107    
108        /**
109         * The human-readable title of the style (extracted from Capabilities by the 
110         * Context document creator).
111         *
112         * @return 
113         */
114        public String getTitle() {
115            return title;
116        }
117    
118        /**
119         * A narrative description of the current style (extracted from Capabilities 
120         * by the Context document creator).
121         *
122         * @return 
123         */
124        public String getAbstract() {
125            return abstract_;
126        }
127    
128        /**
129         * The location of an image of a map legend describing the current style 
130         * (extracted from Capabilities by the Context document creator).
131         *
132         * @return 
133         */
134        public ImageURL getLegendURL() {
135            return legendURL;
136        }
137    
138        /**
139         * Each &lt;Style&gt; element may alternatively define the style(s) of the layer 
140         * with a &lt;SLD&gt; element.
141         *
142         * @return 
143         */
144        public SLD getSld() {
145            return sld;
146        }
147    
148        /**
149         * returns true the current style is selected.
150         *
151         * @return 
152         */
153        public boolean isCurrent() {
154            return current;
155        }
156    
157        /**
158         * @see org.deegree.clients.context.Style#getName()
159         *
160         * @param name 
161         */
162        public void setName( String name ) throws ContextException {
163            if ( ( name == null ) && ( sld == null ) ) {
164                throw new ContextException( "either name or sld must be different to null" );
165            }
166    
167            this.name = name;
168        }
169    
170        /**
171         * @see org.deegree.clients.context.Style#getTitle()
172         *
173         * @param title 
174         */
175        public void setTitle( String title ) throws ContextException {
176            if ( ( title == null ) && ( sld == null ) ) {
177                throw new ContextException( "either title or sld must be different to null" );
178            }
179    
180            this.title = title;
181        }
182    
183        /**
184         * @see org.deegree.clients.context.Style#getAbstract()
185         *
186         * @param abstract_ 
187         */
188        public void setAbstract( String abstract_ ) {
189            this.abstract_ = abstract_;
190        }
191    
192        /**
193         * @see org.deegree.clients.context.Style#getLegendURL()
194         *
195         * @param  legendURL
196         */
197        public void setLegendURL( ImageURL legendURL ) {
198            this.legendURL = legendURL;
199        }
200    
201        /**
202         * @see org.deegree.clients.context.Style#getSld()
203         *
204         * @param sld 
205         */
206        public void setSld( SLD sld ) throws ContextException {
207            if ( ( sld == null ) && ( title == null || name == null ) ) {
208                throw new ContextException( "either sld or name and tile must be different to null" );
209            }
210    
211            this.sld = sld;
212        }
213    
214        /**
215         * @see org.deegree.clients.context.Style#isCurrent()
216         *
217         * @param current 
218         */
219        public void setCurrent( boolean current ) {
220            this.current = current;
221        }
222        
223       
224        
225    }