svn-gvsig-desktop / trunk / extensions / extWMS / src / com / iver / cit / gvsig / fmap / layers / WMSLayerNode.java @ 9075
History | View | Annotate | Download (12.8 KB)
1 | 4503 | jaume | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | 3746 | jaume | *
|
3 | * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | 4503 | jaume | * Av. Blasco Ib??ez, 50
|
24 | 3746 | jaume | * 46010 VALENCIA
|
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | |||
42 | /* CVS MESSAGES:
|
||
43 | *
|
||
44 | * $Id$
|
||
45 | * $Log$
|
||
46 | 5452 | jaume | * Revision 1.10 2006-05-25 15:46:45 jaume
|
47 | 3749 | jaume | * *** empty log message ***
|
48 | 3746 | jaume | *
|
49 | 5449 | ldiaz | * Revision 1.8 2006/05/25 10:35:09 jaume
|
50 | * *** empty log message ***
|
||
51 | *
|
||
52 | 5442 | jaume | * Revision 1.7 2006/05/25 10:28:12 jaume
|
53 | * *** empty log message ***
|
||
54 | *
|
||
55 | 5430 | jaume | * Revision 1.6 2006/03/21 16:02:06 jaume
|
56 | * *** empty log message ***
|
||
57 | *
|
||
58 | 4503 | jaume | * Revision 1.5 2006/02/28 15:25:14 jaume
|
59 | * *** empty log message ***
|
||
60 | *
|
||
61 | 4222 | jaume | * Revision 1.3.2.9 2006/02/20 15:23:08 jaume
|
62 | * Se muestran algunas de las capas de aes
|
||
63 | *
|
||
64 | * Revision 1.3.2.8 2006/02/17 12:57:34 jaume
|
||
65 | * oculta/eXconde los nombres de las capas y adem?s corrige el error de selecci?n de varios styles si hay alguna capa seleccionada repetida
|
||
66 | *
|
||
67 | * Revision 1.3.2.7 2006/02/16 10:36:41 jaume
|
||
68 | * *** empty log message ***
|
||
69 | *
|
||
70 | * Revision 1.3.2.6 2006/02/15 11:50:08 jaume
|
||
71 | * *** empty log message ***
|
||
72 | *
|
||
73 | * Revision 1.3.2.5 2006/02/10 13:22:35 jaume
|
||
74 | * now analyzes dimensions on demand
|
||
75 | *
|
||
76 | * Revision 1.3.2.4 2006/02/02 12:12:54 jaume
|
||
77 | * se muestra el nombre de la capa (adem?s del t?tulo) en los di?logos
|
||
78 | *
|
||
79 | * Revision 1.3.2.3 2006/01/31 16:25:24 jaume
|
||
80 | * correcciones de bugs
|
||
81 | *
|
||
82 | * Revision 1.4 2006/01/26 16:07:14 jaume
|
||
83 | * *** empty log message ***
|
||
84 | *
|
||
85 | 3805 | jaume | * Revision 1.3.2.1 2006/01/26 12:59:32 jaume
|
86 | * 0.5
|
||
87 | *
|
||
88 | * Revision 1.3 2006/01/24 18:01:17 jaume
|
||
89 | * *** empty log message ***
|
||
90 | *
|
||
91 | 3746 | jaume | * Revision 1.1.2.11 2006/01/23 12:54:45 jaume
|
92 | * *** empty log message ***
|
||
93 | *
|
||
94 | * Revision 1.1.2.10 2006/01/20 15:22:46 jaume
|
||
95 | * *** empty log message ***
|
||
96 | *
|
||
97 | * Revision 1.1.2.9 2006/01/17 12:55:40 jaume
|
||
98 | * *** empty log message ***
|
||
99 | *
|
||
100 | * Revision 1.1.2.8 2006/01/05 23:15:53 jaume
|
||
101 | * *** empty log message ***
|
||
102 | *
|
||
103 | * Revision 1.1.2.7 2006/01/04 18:09:02 jaume
|
||
104 | * Time dimension
|
||
105 | *
|
||
106 | * Revision 1.1.2.6 2006/01/03 18:08:40 jaume
|
||
107 | * *** empty log message ***
|
||
108 | *
|
||
109 | * Revision 1.1.2.5 2006/01/02 18:08:01 jaume
|
||
110 | * Tree de estilos
|
||
111 | *
|
||
112 | * Revision 1.1.2.4 2005/12/30 08:56:19 jaume
|
||
113 | * *** empty log message ***
|
||
114 | *
|
||
115 | * Revision 1.1.2.3 2005/12/29 08:26:54 jaume
|
||
116 | * some gui issues where fixed
|
||
117 | *
|
||
118 | * Revision 1.1.2.2 2005/12/26 16:51:40 jaume
|
||
119 | 4222 | jaume | * Handles STYLES, layer saving does nothing ??
|
120 | 3746 | jaume | *
|
121 | * Revision 1.1.2.1 2005/12/21 15:59:04 jaume
|
||
122 | * Refatoring maintenance
|
||
123 | *
|
||
124 | *
|
||
125 | */
|
||
126 | /**
|
||
127 | *
|
||
128 | */
|
||
129 | package com.iver.cit.gvsig.fmap.layers; |
||
130 | |||
131 | 4222 | jaume | import java.awt.Dimension; |
132 | 3746 | jaume | import java.util.ArrayList; |
133 | import java.util.Vector; |
||
134 | |||
135 | /**
|
||
136 | * Class defining the node of the layer tree of a common WMS service.
|
||
137 | * @author jaume
|
||
138 | *
|
||
139 | */
|
||
140 | public class WMSLayerNode { |
||
141 | private String _name; |
||
142 | private String _title; |
||
143 | private Vector srs; |
||
144 | private boolean queryable; |
||
145 | private boolean transparency; |
||
146 | private String lAbstract; |
||
147 | private String latLonBox; |
||
148 | 4222 | jaume | private int selectedStyleIndex = 0; |
149 | private ArrayList styles = new ArrayList(); |
||
150 | 3746 | jaume | private ArrayList dimensions; |
151 | 5430 | jaume | private ArrayList keywords; |
152 | 3746 | jaume | |
153 | private ArrayList children = new ArrayList(); |
||
154 | private WMSLayerNode _parent;
|
||
155 | 4222 | jaume | private Dimension fixedSize; |
156 | |||
157 | 3746 | jaume | /**
|
158 | * @return Returns the name.
|
||
159 | */
|
||
160 | public String getName() { |
||
161 | return _name;
|
||
162 | } |
||
163 | 4222 | jaume | |
164 | 3746 | jaume | /**
|
165 | * @return
|
||
166 | */
|
||
167 | public ArrayList getChildren() { |
||
168 | return children;
|
||
169 | } |
||
170 | 4222 | jaume | |
171 | 3746 | jaume | /**
|
172 | * @param name The name to set.
|
||
173 | */
|
||
174 | public void setName(String name) { |
||
175 | this._name = name;
|
||
176 | } |
||
177 | 4222 | jaume | |
178 | 3746 | jaume | /**
|
179 | * @return Returns the namedStyles.
|
||
180 | */
|
||
181 | public ArrayList getStyles() { |
||
182 | return styles;
|
||
183 | } |
||
184 | |||
185 | 5449 | ldiaz | public ArrayList getKeywords(){ |
186 | return keywords;
|
||
187 | } |
||
188 | 3746 | jaume | /**
|
189 | * @return Returns the queryable.
|
||
190 | */
|
||
191 | public boolean isQueryable() { |
||
192 | return queryable;
|
||
193 | } |
||
194 | 4222 | jaume | |
195 | 3746 | jaume | /**
|
196 | * @param queryable The queryable to set.
|
||
197 | */
|
||
198 | public void setQueryable(boolean queryable) { |
||
199 | this.queryable = queryable;
|
||
200 | } |
||
201 | /**
|
||
202 | * @return Returns the srs.
|
||
203 | */
|
||
204 | public Vector getAllSrs() { |
||
205 | if ((srs.size() == 0) && _parent!=null) |
||
206 | return _parent.getAllSrs();
|
||
207 | return srs;
|
||
208 | } |
||
209 | 4222 | jaume | |
210 | 3746 | jaume | /**
|
211 | * @param srs The srs to set.
|
||
212 | */
|
||
213 | public void setSrs(Vector srs) { |
||
214 | this.srs = srs;
|
||
215 | } |
||
216 | 4222 | jaume | |
217 | 3746 | jaume | /**
|
218 | * @return Returns the title.
|
||
219 | */
|
||
220 | public String getTitle() { |
||
221 | return _title;
|
||
222 | } |
||
223 | 4222 | jaume | |
224 | 3746 | jaume | /**
|
225 | * @param title The title to set.
|
||
226 | */
|
||
227 | public void setTitle(String title) { |
||
228 | this._title = title.trim();
|
||
229 | } |
||
230 | 4222 | jaume | |
231 | 3746 | jaume | /**
|
232 | * @return Returns the transparency.
|
||
233 | */
|
||
234 | public boolean isTransparent() { |
||
235 | return transparency;
|
||
236 | } |
||
237 | 4222 | jaume | |
238 | 3746 | jaume | /**
|
239 | * @param transparency The transparency to set.
|
||
240 | */
|
||
241 | public void setTransparency(boolean transparency) { |
||
242 | this.transparency = transparency;
|
||
243 | } |
||
244 | |||
245 | 4222 | jaume | /**
|
246 | * Sets the list of sons of this layer.
|
||
247 | * @param children
|
||
248 | */
|
||
249 | 3746 | jaume | public void setChildren(ArrayList children) { |
250 | this.children = children;
|
||
251 | } |
||
252 | |||
253 | /**
|
||
254 | * returns the layer whose this is son of.
|
||
255 | * @return
|
||
256 | */
|
||
257 | public WMSLayerNode getParent(){
|
||
258 | return _parent;
|
||
259 | } |
||
260 | /**
|
||
261 | * @param parentNode
|
||
262 | */
|
||
263 | public void setParent(WMSLayerNode parentNode) { |
||
264 | this._parent = parentNode;
|
||
265 | } |
||
266 | |||
267 | public ArrayList getDimensions(){ |
||
268 | return dimensions;
|
||
269 | } |
||
270 | |||
271 | /**
|
||
272 | * Gets the layer abstract.
|
||
273 | *
|
||
274 | * @return Returns the abstract.
|
||
275 | */
|
||
276 | public String getAbstract() { |
||
277 | return lAbstract;
|
||
278 | } |
||
279 | 4222 | jaume | |
280 | 3746 | jaume | /**
|
281 | * Sets the layer abstract.
|
||
282 | *
|
||
283 | * @param abstract The abstract to set.
|
||
284 | */
|
||
285 | public void setAbstract(String _abstract) { |
||
286 | lAbstract = _abstract; |
||
287 | } |
||
288 | |||
289 | /**
|
||
290 | * @param name
|
||
291 | * @param units
|
||
292 | * @param unitSymbol
|
||
293 | * @param dimensionExpression
|
||
294 | */
|
||
295 | public void addDimension(String name, String units, String unitSymbol, String dimExpression) { |
||
296 | if (dimensions == null) |
||
297 | dimensions = new ArrayList(); |
||
298 | 4222 | jaume | if (name.equalsIgnoreCase("time")) { |
299 | try {
|
||
300 | dimensions.add(new TimeDimension(units, unitSymbol,
|
||
301 | dimExpression)); |
||
302 | } catch (IllegalArgumentException e) { |
||
303 | // The TIME class does not yet support this kind of time so it
|
||
304 | // will be treated as a DefaultDimension
|
||
305 | dimensions.add(new DefaultDimension(name.toUpperCase(),
|
||
306 | units, unitSymbol, dimExpression)); |
||
307 | } |
||
308 | } else if (name.equalsIgnoreCase("sequence")) { |
||
309 | // TODO Not yet implemented
|
||
310 | return;
|
||
311 | } else {
|
||
312 | dimensions.add(new DefaultDimension(name.toUpperCase(), units,
|
||
313 | unitSymbol, dimExpression)); |
||
314 | } |
||
315 | |||
316 | 3746 | jaume | } |
317 | |||
318 | /**
|
||
319 | * Sets the Latitude-Longitude box text to be shown in an user interface layer descriptor.
|
||
320 | * @param latLonBox
|
||
321 | */
|
||
322 | public void setLatLonBox(String _latLonBox) { |
||
323 | latLonBox = _latLonBox; |
||
324 | } |
||
325 | 4222 | jaume | |
326 | 3746 | jaume | /**
|
327 | * Returns the Latitude-Longitude box text to be shown in an user interface layer descriptor.
|
||
328 | * @return
|
||
329 | */
|
||
330 | public String getLatLonBox() { |
||
331 | return latLonBox;
|
||
332 | } |
||
333 | |||
334 | /**
|
||
335 | 4222 | jaume | * When a server cannot renderize images but just server them in constant size and
|
336 | * BBox, the layer must have this value set in order to correctly work.
|
||
337 | *
|
||
338 | * @param fixedWidth - the constant value for the image width
|
||
339 | * @param fixedHeight - the constant value for the image height
|
||
340 | */
|
||
341 | public void setFixedSize(int fixedWidth, int fixedHeight) { |
||
342 | fixedSize = new Dimension(fixedWidth, fixedHeight); |
||
343 | } |
||
344 | |||
345 | /**
|
||
346 | * Returns the size of this layer (which is constant-sized)
|
||
347 | * @return
|
||
348 | */
|
||
349 | public Dimension getFixedSize() { |
||
350 | return fixedSize;
|
||
351 | } |
||
352 | |||
353 | /**
|
||
354 | * Tells whether the layer is constant-sized or not.
|
||
355 | * @return boolean
|
||
356 | */
|
||
357 | public boolean isSizeFixed() { |
||
358 | return fixedSize != null && |
||
359 | fixedSize.getWidth() > 0 &&
|
||
360 | fixedSize.getHeight() > 0;
|
||
361 | } |
||
362 | |||
363 | /**
|
||
364 | *
|
||
365 | * @param _name
|
||
366 | * @param _title
|
||
367 | * @param _abstract
|
||
368 | */
|
||
369 | public void addStyle(String name, String title, String _abstract) { |
||
370 | if (name.equalsIgnoreCase("default")) |
||
371 | selectedStyleIndex = styles.size(); |
||
372 | if (styles==null) |
||
373 | styles = new ArrayList(); |
||
374 | styles.add(new FMapWMSStyle(name, title, _abstract, this)); |
||
375 | |||
376 | } |
||
377 | |||
378 | /**
|
||
379 | * Returns the style marked as selected or null if none.
|
||
380 | * @return FMapWMSStyle
|
||
381 | */
|
||
382 | public FMapWMSStyle getSelectedStyle() {
|
||
383 | if (styles == null || selectedStyleIndex > styles.size()-1 || selectedStyleIndex == -1) |
||
384 | return null; |
||
385 | return (FMapWMSStyle) styles.get(selectedStyleIndex);
|
||
386 | } |
||
387 | |||
388 | /**
|
||
389 | * Marks the style of this layer given by the index as selected
|
||
390 | * @param inex of the style
|
||
391 | */
|
||
392 | public void setSelectedStyleByIndex(int index) { |
||
393 | selectedStyleIndex = index; |
||
394 | } |
||
395 | |||
396 | /**
|
||
397 | * Marks the style of this layer given by its name as selected. If
|
||
398 | * this layer has no style with this name, then the layer is marked
|
||
399 | * as none selected.
|
||
400 | * @param style name
|
||
401 | */
|
||
402 | public void setSelectedStyleByName(String styName) { |
||
403 | if (styName == null || styName.equals("")) |
||
404 | setSelectedStyleByIndex(-1);
|
||
405 | for (int i = 0; i < styles.size(); i++) { |
||
406 | FMapWMSStyle sty = (FMapWMSStyle) styles.get(i); |
||
407 | if (sty.name.equals(styName)) {
|
||
408 | setSelectedStyleByIndex(i); |
||
409 | return;
|
||
410 | } |
||
411 | |||
412 | } |
||
413 | setSelectedStyleByIndex(-1);
|
||
414 | } |
||
415 | 5430 | jaume | |
416 | 5442 | jaume | public void addKeyword(String keyword) { |
417 | if (keywords == null) |
||
418 | keywords = new ArrayList(); |
||
419 | keywords.add(keyword); |
||
420 | 5430 | jaume | } |
421 | 4222 | jaume | |
422 | public String toString(){ |
||
423 | String str;
|
||
424 | if (getName()==null) |
||
425 | str = getTitle(); |
||
426 | else
|
||
427 | str = "["+getName()+"] "+getTitle(); |
||
428 | return str;
|
||
429 | } |
||
430 | |||
431 | /**
|
||
432 | * Creates a new instance of WMSLayerNode containing a copy of this,
|
||
433 | * but with no children and parent set.
|
||
434 | */
|
||
435 | public Object clone(){ |
||
436 | WMSLayerNode clone = new WMSLayerNode();
|
||
437 | clone._name = this._name;
|
||
438 | clone.queryable = this.queryable;
|
||
439 | clone.srs = this.srs;
|
||
440 | clone._title = this._title;
|
||
441 | clone.transparency = this.transparency;
|
||
442 | clone.styles = new ArrayList(); |
||
443 | clone.lAbstract = this.lAbstract;
|
||
444 | clone.latLonBox = this.latLonBox;
|
||
445 | clone.selectedStyleIndex = this.selectedStyleIndex;
|
||
446 | |||
447 | 5442 | jaume | if (keywords != null) { |
448 | clone.keywords = new ArrayList(keywords.size()); |
||
449 | for (int i = 0; i < keywords.size(); i++) { |
||
450 | clone.keywords.add((String) keywords.get(i));
|
||
451 | } |
||
452 | } |
||
453 | 4222 | jaume | if (styles!=null) |
454 | for (int i=0; i<styles.size(); i++){ |
||
455 | FMapWMSStyle sty = (FMapWMSStyle) ((FMapWMSStyle) this.styles.get(i)).clone();
|
||
456 | sty.parent = this;
|
||
457 | clone.styles.add(sty); |
||
458 | } |
||
459 | |||
460 | if (dimensions!=null) |
||
461 | for (int i = 0; i < dimensions.size(); i++) { |
||
462 | clone.dimensions = new ArrayList(); |
||
463 | clone.dimensions.add((IFMapWMSDimension) this.dimensions.get(i));
|
||
464 | } |
||
465 | |||
466 | return clone;
|
||
467 | } |
||
468 | |||
469 | |||
470 | /**
|
||
471 | 3746 | jaume | * Just a C-struct-like class.
|
472 | * @author jaume
|
||
473 | *
|
||
474 | */
|
||
475 | public class FMapWMSStyle { |
||
476 | public String name; |
||
477 | public String title; |
||
478 | public String styleAbstract; |
||
479 | public WMSLayerNode parent;
|
||
480 | |||
481 | /**
|
||
482 | * Creates a new instance of FMapWMSStyle
|
||
483 | * @param name
|
||
484 | * @param title
|
||
485 | * @param styleAbstract
|
||
486 | * @param parent
|
||
487 | */
|
||
488 | public FMapWMSStyle(String name, String title, String styleAbstract, WMSLayerNode parent){ |
||
489 | this.name = name;
|
||
490 | this.title = title;
|
||
491 | this.styleAbstract = styleAbstract;
|
||
492 | this.parent = parent;
|
||
493 | } |
||
494 | |||
495 | public String toString(){ |
||
496 | return title;
|
||
497 | } |
||
498 | |||
499 | public Object clone() { |
||
500 | FMapWMSStyle clone = new FMapWMSStyle(this.name, this.title, this.styleAbstract, this.parent); |
||
501 | return clone;
|
||
502 | } |
||
503 | } |
||
504 | 5430 | jaume | |
505 | 3746 | jaume | } |