Statistics
| Revision:

svn-gvsig-desktop / branches / v05 / extensions / extWMS / src / com / iver / cit / gvsig / fmap / layers / WMSLayerNode.java @ 4054

History | View | Annotate | Download (9.11 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 4054 2006-02-10 13:22:35Z jaume $
45
* $Log$
46
* Revision 1.3.2.5  2006-02-10 13:22:35  jaume
47
* now analyzes dimensions on demand
48
*
49
* Revision 1.3.2.4  2006/02/02 12:12:54  jaume
50
* se muestra el nombre de la capa (adem?s del t?tulo) en los di?logos
51
*
52
* Revision 1.3.2.3  2006/01/31 16:25:24  jaume
53
* correcciones de bugs
54
*
55
* Revision 1.4  2006/01/26 16:07:14  jaume
56
* *** empty log message ***
57
*
58
* Revision 1.3.2.1  2006/01/26 12:59:32  jaume
59
* 0.5
60
*
61
* Revision 1.3  2006/01/24 18:01:17  jaume
62
* *** empty log message ***
63
*
64
* Revision 1.1.2.11  2006/01/23 12:54:45  jaume
65
* *** empty log message ***
66
*
67
* Revision 1.1.2.10  2006/01/20 15:22:46  jaume
68
* *** empty log message ***
69
*
70
* Revision 1.1.2.9  2006/01/17 12:55:40  jaume
71
* *** empty log message ***
72
*
73
* Revision 1.1.2.8  2006/01/05 23:15:53  jaume
74
* *** empty log message ***
75
*
76
* Revision 1.1.2.7  2006/01/04 18:09:02  jaume
77
* Time dimension
78
*
79
* Revision 1.1.2.6  2006/01/03 18:08:40  jaume
80
* *** empty log message ***
81
*
82
* Revision 1.1.2.5  2006/01/02 18:08:01  jaume
83
* Tree de estilos
84
*
85
* Revision 1.1.2.4  2005/12/30 08:56:19  jaume
86
* *** empty log message ***
87
*
88
* Revision 1.1.2.3  2005/12/29 08:26:54  jaume
89
* some gui issues where fixed
90
*
91
* Revision 1.1.2.2  2005/12/26 16:51:40  jaume
92
* Handles STYLES, layer saving does nothing ??
93
*
94
* Revision 1.1.2.1  2005/12/21 15:59:04  jaume
95
* Refatoring maintenance
96
*
97
*
98
*/
99
/**
100
 * 
101
 */
102
package com.iver.cit.gvsig.fmap.layers;
103

    
104
import java.util.ArrayList;
105
import java.util.Vector;
106

    
107
import org.gvsig.remoteClient.utils.BoundaryBox;
108

    
109
/**
110
 * Class defining the node of the layer tree of a common WMS service.
111
 * @author jaume
112
 *
113
 */
114
public class WMSLayerNode {
115
    private String _name;
116
    private String _title;
117
    private Vector srs;
118
    private boolean queryable;
119
    private boolean transparency;
120
    private String lAbstract;
121
    private String latLonBox;
122
    
123
    private ArrayList styles;
124
    private ArrayList dimensions;
125
    
126
    private ArrayList children = new ArrayList();
127
    private WMSLayerNode _parent;
128
    
129
    /**
130
     * @return Returns the name.
131
     */
132
    public String getName() {
133
        return _name;
134
    }
135
    /**
136
     * @return
137
     */
138
    public ArrayList getChildren() {
139
        return children;
140
    }
141
    /**
142
     * @param name The name to set.
143
     */
144
    public void setName(String name) {
145
        this._name = name;
146
    }
147
    /**
148
     * @return Returns the namedStyles.
149
     */
150
    public ArrayList getStyles() {
151
        return styles;
152
    }
153
    
154
    /**
155
     * @return Returns the queryable.
156
     */
157
    public boolean isQueryable() {
158
        return queryable;
159
    }
160
    /**
161
     * @param queryable The queryable to set.
162
     */
163
    public void setQueryable(boolean queryable) {
164
        this.queryable = queryable;
165
    }
166
    /**
167
     * @return Returns the srs.
168
     */
169
    public Vector getAllSrs() {
170
        if ((srs.size() == 0) && _parent!=null)
171
            return _parent.getAllSrs();
172
        return srs;
173
    }
174
    /**
175
     * @param srs The srs to set.
176
     */
177
    public void setSrs(Vector srs) {
178
        this.srs = srs;
179
    }
180
    /**
181
     * @return Returns the title.
182
     */
183
    public String getTitle() {
184
        return _title;
185
    }
186
    /**
187
     * @param title The title to set.
188
     */
189
    public void setTitle(String title) {
190
        this._title = title.trim();
191
    }
192
    /**
193
     * @return Returns the transparency.
194
     */
195
    public boolean isTransparent() {
196
        return transparency;
197
    }
198
    /**
199
     * @param transparency The transparency to set.
200
     */
201
    public void setTransparency(boolean transparency) {
202
        this.transparency = transparency;
203
    }
204
    
205
    public void setChildren(ArrayList children) {
206
        this.children = children;
207
    }
208
    
209
    /**
210
     * returns the layer whose this is son of. 
211
     * @return
212
     */
213
    public WMSLayerNode getParent(){
214
        return _parent;
215
    }
216
    /**
217
     * @param parentNode
218
     */
219
    public void setParent(WMSLayerNode parentNode) {
220
        this._parent = parentNode;
221
    }
222
    
223
    public ArrayList getDimensions(){
224
        return dimensions;
225
    }
226
    
227
    public String toString(){
228
            if (getName()==null)
229
                    return getTitle();
230
        return getName()+": "+getTitle();
231
    }
232
    /**
233
     * 
234
     * @param _name
235
     * @param _title
236
     * @param _abstract
237
     */
238
    public void addStyle(String name, String title, String _abstract) {
239
        if (styles==null)
240
            styles = new ArrayList();
241
        styles.add(new FMapWMSStyle(name, title, _abstract, this));
242
    }
243
    
244
    /**
245
     * Creates a new instance of WMSLayerNode containing a copy of this, 
246
     * but with no children and parent set.
247
     */
248
    public Object clone(){
249
        WMSLayerNode clone = new WMSLayerNode();
250
        clone._name        = this._name;
251
        clone.queryable    = this.queryable;
252
        clone.srs          = this.srs;
253
        clone._title       = this._title;
254
        clone.transparency = this.transparency;
255
        clone.styles       = new ArrayList();
256
        clone.lAbstract    = this.lAbstract;
257
        clone.latLonBox    = this.latLonBox;
258
        if (styles!=null)
259
                for (int i=0; i<styles.size(); i++){
260
                        clone.styles.add(((FMapWMSStyle) this.styles.get(i)).clone());
261
                }
262
        if (dimensions!=null)
263
                for (int i = 0; i < dimensions.size(); i++) {
264
                        clone.dimensions = new ArrayList();
265
                        clone.dimensions.add((IFMapWMSDimension) this.dimensions.get(i));
266
                }
267
        return clone;
268
    }
269
    
270
    /**
271
     * Gets the layer abstract.
272
     *  
273
     * @return Returns the abstract.
274
     */
275
    public String getAbstract() {
276
        return lAbstract;
277
    }
278
    /**
279
     * Sets the layer abstract.
280
     * 
281
     * @param abstract The abstract to set.
282
     */
283
    public void setAbstract(String _abstract) {
284
        lAbstract = _abstract;
285
    }
286

    
287
    /**
288
     * @param name
289
     * @param units
290
     * @param unitSymbol
291
     * @param dimensionExpression
292
     */
293
    public void addDimension(String name, String units, String unitSymbol, String dimExpression) {
294
            if (dimensions == null)
295
                    dimensions = new ArrayList();
296
            if (name.equalsIgnoreCase("time")) {
297
                    try {
298
                            dimensions.add(new TimeDimension(units, unitSymbol,
299
                                            dimExpression));
300
                    } catch (IllegalArgumentException e) {
301
                            // The TIME class does not yet support this kind of time so it
302
                            // will be treated as a DefaultDimension
303
                            dimensions.add(new DefaultDimension(name.toUpperCase(),
304
                                            units, unitSymbol, dimExpression));
305
                    }
306
            } else if (name.equalsIgnoreCase("sequence")) {
307
                    // Not yet implemented
308
                    return;
309
            } else {
310
                    dimensions.add(new DefaultDimension(name.toUpperCase(), units,
311
                                    unitSymbol, dimExpression));
312
            }
313
            
314
    }
315

    
316
    /**
317
     * Sets the Latitude-Longitude box text to be shown in an user interface layer descriptor.
318
     * @param latLonBox
319
     */
320
    public void setLatLonBox(String _latLonBox) {
321
        latLonBox = _latLonBox;
322
    }
323
    /**
324
     * Returns the Latitude-Longitude box text to be shown in an user interface layer descriptor.
325
     * @return
326
     */
327
    public String getLatLonBox() {
328
        return latLonBox;
329
    }
330

    
331
    /**
332
     * Just a C-struct-like class.
333
     * @author jaume
334
     *
335
     */
336
    public class FMapWMSStyle {
337
        public String name;
338
        public String title;
339
        public String styleAbstract;
340
        public WMSLayerNode parent;
341
        
342
        /**
343
         * Creates a new instance of FMapWMSStyle
344
         * @param name
345
         * @param title
346
         * @param styleAbstract
347
         * @param parent
348
         */
349
        public FMapWMSStyle(String name, String title, String styleAbstract, WMSLayerNode parent){
350
            this.name = name;
351
            this.title = title;
352
            this.styleAbstract = styleAbstract;
353
            this.parent = parent;
354
        }
355
        
356
        public String toString(){
357
            return title;
358
        }
359
        
360
        public Object clone() {
361
            FMapWMSStyle clone = new FMapWMSStyle(this.name, this.title, this.styleAbstract, this.parent);
362
            return clone;
363
        }
364
    }
365
}