001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/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: * this class encapsulates the style description as defined by the OGC Web
050: * Map Context specification
051: *
052: * @version $Revision: 9346 $
053: * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
054: */
055: public class Style {
056: private ImageURL legendURL = null;
057: private SLD sld = null;
058: private String abstract_ = null;
059: private String name = null;
060: private String title = null;
061: private boolean current = false;
062:
063: /**
064: * Creates a new Style object.
065: *
066: * @param name The name of the style
067: * @param title The human-readable title of the style
068: * @param abstract_ A narrative description of the current style
069: * @param legendURL location of an image of a map legend describing the
070: * current style
071: * @param current true the current style is selected.
072: *
073: * @throws ContextException
074: */
075: public Style(String name, String title, String abstract_,
076: ImageURL legendURL, boolean current)
077: 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 <Style> element may alternatively define the style(s) of the layer
140: * with a <SLD> 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(
165: "either name or sld must be different to null");
166: }
167:
168: this .name = name;
169: }
170:
171: /**
172: * @see org.deegree.clients.context.Style#getTitle()
173: *
174: * @param title
175: */
176: public void setTitle(String title) throws ContextException {
177: if ((title == null) && (sld == null)) {
178: throw new ContextException(
179: "either title or sld must be different to null");
180: }
181:
182: this .title = title;
183: }
184:
185: /**
186: * @see org.deegree.clients.context.Style#getAbstract()
187: *
188: * @param abstract_
189: */
190: public void setAbstract(String abstract_) {
191: this .abstract_ = abstract_;
192: }
193:
194: /**
195: * @see org.deegree.clients.context.Style#getLegendURL()
196: *
197: * @param legendURL
198: */
199: public void setLegendURL(ImageURL legendURL) {
200: this .legendURL = legendURL;
201: }
202:
203: /**
204: * @see org.deegree.clients.context.Style#getSld()
205: *
206: * @param sld
207: */
208: public void setSld(SLD sld) throws ContextException {
209: if ((sld == null) && (title == null || name == null)) {
210: throw new ContextException(
211: "either sld or name and tile must be different to null");
212: }
213:
214: this .sld = sld;
215: }
216:
217: /**
218: * @see org.deegree.clients.context.Style#isCurrent()
219: *
220: * @param current
221: */
222: public void setCurrent(boolean current) {
223: this.current = current;
224: }
225:
226: }
|