001 //$HeadURL: http://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/portal/context/LayerExtension.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.portal.context;
037
038 import java.util.HashMap;
039 import java.util.Iterator;
040 import java.util.Map;
041
042 /**
043 * provides additional information about a layer described in a web map context document. Additional description is not
044 * requiered so an instance of <tt>org.deegree_impl.clients.context.Layer</tt> may doesn't provide an instance of this
045 * class.
046 *
047 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
048 * @author last edited by: $Author: apoth $
049 *
050 * @version $Revision: 30935 $, $Date: 2011-05-26 17:47:14 +0200 (Do, 26 Mai 2011) $
051 */
052 public class LayerExtension {
053
054 /**
055 * No authentication type
056 */
057 public static final int NONE = -1;
058
059 /**
060 * The session id authentication type
061 */
062 public static final int SESSIONID = 0;
063
064 /**
065 * The user password authentication type
066 */
067 public static final int USERPASSWORD = 1;
068
069 private DataService dataService = null;
070
071 private boolean masterLayer = false;
072
073 private double minScaleHint = 0;
074
075 private double maxScaleHint = 9E99;
076
077 private boolean selectedForQuery = false;
078
079 private int authentication = NONE;
080
081 private int parentNodeId = NONE;
082
083 private boolean showLegendGraphic = false;
084
085 private boolean tiled = false;
086
087 private String identifier;
088
089 private boolean valid = true;
090
091 private Map<String, String> vendorspecificParams = new HashMap<String, String>();
092
093 /**
094 * default constructor
095 *
096 */
097 public LayerExtension() {
098 // default constructor.
099 }
100
101 /**
102 * Creates a new LayerExtension object.
103 *
104 * @param dataService
105 * description of the service/server behind a WMS layer
106 * @param masterLayer
107 * true if a layer is one of the main layers of an application; false if it just provides background or
108 * additional informations.
109 * @param minScaleHint
110 * @param maxScaleHint
111 * @param selectedForQuery
112 * @param authentication
113 * @param parentNodeId
114 * @param showLegendGraphic
115 * @param identifier
116 */
117 public LayerExtension( DataService dataService, boolean masterLayer, double minScaleHint, double maxScaleHint,
118 boolean selectedForQuery, int authentication, int parentNodeId, boolean showLegendGraphic,
119 String identifier ) {
120 setDataService( dataService );
121 setMasterLayer( masterLayer );
122 setMinScaleHint( minScaleHint );
123 setMaxScaleHint( maxScaleHint );
124 setSelectedForQuery( selectedForQuery );
125 setAuthentication( authentication );
126 setParentNodeId( parentNodeId );
127 setShowLegendGraphic( showLegendGraphic );
128 setIdentifier( identifier );
129 }
130
131 /**
132 * Creates a new LayerExtension object.
133 *
134 * @param dataService
135 * description of the service/server behind a WMS layer
136 * @param masterLayer
137 * true if a layer is one of the main layers of an application; false if it just provides background or
138 * additional informations.
139 * @param minScaleHint
140 * @param maxScaleHint
141 * @param selectedForQuery
142 * @param authentication
143 * @param parentNodeId
144 * @param showLegendGraphic
145 * @param identifier
146 * @param tiled
147 * <code>true</code> if client should tile a layer if possible
148 */
149 public LayerExtension( DataService dataService, boolean masterLayer, double minScaleHint, double maxScaleHint,
150 boolean selectedForQuery, int authentication, int parentNodeId, boolean showLegendGraphic,
151 String identifier, boolean tiled ) {
152 this( dataService, masterLayer, minScaleHint, maxScaleHint, selectedForQuery, authentication, parentNodeId,
153 showLegendGraphic, identifier );
154 this.tiled = tiled;
155 }
156
157 /**
158 * @return the tiled
159 */
160 public boolean isTiled() {
161 return tiled;
162 }
163
164 /**
165 * @param tiled
166 * the tiled to set
167 */
168 public void setTiled( boolean tiled ) {
169 this.tiled = tiled;
170 }
171
172 /**
173 * @return the valid
174 */
175 public boolean isValid() {
176 return valid;
177 }
178
179 /**
180 * @param valid
181 * the valid to set
182 */
183 public void setValid( boolean valid ) {
184 this.valid = valid;
185 }
186
187 /**
188 * @return the identifier
189 */
190 public String getIdentifier() {
191 return identifier;
192 }
193
194 /**
195 * @param identifier
196 * the identifier to set
197 */
198 public void setIdentifier( String identifier ) {
199 this.identifier = identifier;
200 }
201
202 /**
203 * returns a description of the service/server behind a WMS layer. The returned value will be <tt>null</tt> if the
204 * WMS uses an internal mechanism to access a layers data.
205 *
206 * @return instance of <tt>DataService</tt>
207 */
208 public DataService getDataService() {
209 return this.dataService;
210 // return null;
211 }
212
213 /**
214 * sets a description of the service/server behind a WMS layer. The returned value will be <tt>null</tt> if the WMS
215 * uses an internal mechanism to access a layers data.
216 *
217 * @param dataService
218 */
219 public void setDataService( DataService dataService ) {
220 this.dataService = dataService;
221 }
222
223 /**
224 * @return true if a layer is one of the main layers of an application; returns false if it just provides background
225 * or additional informations.
226 *
227 */
228 public boolean isMasterLayer() {
229 return masterLayer;
230 }
231
232 /**
233 * set to true if a layer is one of the main layers of an application; set to false if it just provides background
234 * or additional informations.
235 *
236 * @param masterLayer
237 */
238 public void setMasterLayer( boolean masterLayer ) {
239 this.masterLayer = masterLayer;
240 }
241
242 /**
243 * returns the maximum sclae the layer is valid
244 *
245 * @return maximum scale hint
246 */
247 public double getMaxScaleHint() {
248 return maxScaleHint;
249 }
250
251 /**
252 * sets the maximum scale the layer is valid for
253 *
254 * @param maxScaleHint
255 */
256 public void setMaxScaleHint( double maxScaleHint ) {
257 this.maxScaleHint = maxScaleHint;
258 }
259
260 /**
261 * returns the minimum sclae the layer is valid
262 *
263 * @return minimum scale hint
264 */
265 public double getMinScaleHint() {
266 return minScaleHint;
267 }
268
269 /**
270 * sets the minimum scale the layer is valid for
271 *
272 * @param minScaleHint
273 */
274 public void setMinScaleHint( double minScaleHint ) {
275 this.minScaleHint = minScaleHint;
276 }
277
278 /**
279 * returns true if a layer is currently selected for being active for feature info requests
280 *
281 * @return <code>true</code> if a layer is currently selected for being active for feature info requests
282 */
283 public boolean isSelectedForQuery() {
284 return selectedForQuery;
285 }
286
287 /**
288 * sets a layer to active for feature info requests
289 *
290 * @param selectedForFI
291 */
292 public void setSelectedForQuery( boolean selectedForFI ) {
293 this.selectedForQuery = selectedForFI;
294 }
295
296 /**
297 * returns a code for authentication to be used for service requests
298 *
299 * @return a code for authentication to be used for service requests
300 */
301 public int getAuthentication() {
302 return authentication;
303 }
304
305 /**
306 * @see #getAuthentication()
307 * @param authentication
308 */
309 public void setAuthentication( int authentication ) {
310 this.authentication = authentication;
311 }
312
313 /**
314 * returns true if the legendGraphic of the layer should be drawn in the layerlistview
315 *
316 * @return <code>true</code> if the legendGraphic of the layer should be drawn in the layerlistview
317 */
318 public boolean getShowLegendGraphic() {
319 return showLegendGraphic;
320 }
321
322 /**
323 * returns true the id of the node to which the layer belongs in the layertree
324 *
325 * @return <code>true</code> the id of the node to which the layer belongs in the layertree
326 */
327 public int getParentNodeId() {
328 return parentNodeId;
329 }
330
331 /**
332 *
333 * @param showLegendGraphic
334 */
335 public void setShowLegendGraphic( boolean showLegendGraphic ) {
336 this.showLegendGraphic = showLegendGraphic;
337 }
338
339 /**
340 *
341 * @param parentNodeId
342 */
343 public void setParentNodeId( int parentNodeId ) {
344 this.parentNodeId = parentNodeId;
345 }
346
347 /**
348 *
349 * @param name
350 * @param value
351 */
352 public void addVendorspecificParameter( String name, String value ) {
353 vendorspecificParams.put( name, value );
354 }
355
356 /**
357 *
358 * @param name
359 * @return the vendorspecific parameter by given name or <code>null</code> if no such parameter exists.
360 */
361 public String getVendorspecificParameter( String name ) {
362 return vendorspecificParams.get( name );
363 }
364
365 /**
366 *
367 * @return an iterator over all vendor specific keys.
368 */
369 public Iterator<String> getVendorspecificParameterNames() {
370 return vendorspecificParams.keySet().iterator();
371 }
372
373 }