Statistics
| Revision:

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

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

    
98
import java.util.ArrayList;
99
import java.util.Vector;
100

    
101
import org.gvsig.remoteClient.utils.BoundaryBox;
102

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

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

    
313
    /**
314
     * Sets the Latitude-Longitude box text to be shown in an user interface layer descriptor.
315
     * @param latLonBox
316
     */
317
    public void setLatLonBox(String _latLonBox) {
318
        latLonBox = _latLonBox;
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
     * Just a C-struct-like class.
330
     * @author jaume
331
     *
332
     */
333
    public class FMapWMSStyle {
334
        public String name;
335
        public String title;
336
        public String styleAbstract;
337
        public WMSLayerNode parent;
338
        
339
        /**
340
         * Creates a new instance of FMapWMSStyle
341
         * @param name
342
         * @param title
343
         * @param styleAbstract
344
         * @param parent
345
         */
346
        public FMapWMSStyle(String name, String title, String styleAbstract, WMSLayerNode parent){
347
            this.name = name;
348
            this.title = title;
349
            this.styleAbstract = styleAbstract;
350
            this.parent = parent;
351
        }
352
        
353
        public String toString(){
354
            return title;
355
        }
356
        
357
        public Object clone() {
358
            FMapWMSStyle clone = new FMapWMSStyle(this.name, this.title, this.styleAbstract, this.parent);
359
            return clone;
360
        }
361
    }
362
}