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