Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wms / WMSStatus.java @ 40559

History | View | Annotate | Download (8.17 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

    
25
package org.gvsig.remoteclient.wms;
26

    
27
import java.awt.geom.Rectangle2D;
28
import java.util.Vector;
29

    
30
/**
31
 * Describes the status of a WMSclient, so it adds to the Remote client status
32
 * a list of layers, a list of layer styles, the extent of the map.
33
 * Provides the functionality to modify these lists.
34
 * 
35
 */
36
public class WMSStatus extends org.gvsig.remoteclient.RemoteClientStatus {
37
        // list of layer to be retrieved by the WMS
38
    private Vector      layers;
39
    // List of layer styles
40
    private Vector      styles;
41
    private Vector      dimensions;
42
    // extent required by the WMS client
43
    private Rectangle2D extent;
44
    private boolean     transparency;
45
        private String      onlineResource;
46
        private boolean     projectedCoordinates = false;
47
        
48
    public WMSStatus() {
49
            layers = new Vector();
50
            styles = new Vector();                        
51
    }
52
    
53
    // sets the list of layers required by the WMS client
54
    public void setLayerNames(Vector _layers) {        
55
        layers = _layers;
56
    } 
57

    
58
/**
59
 * <p>Retrieves the layer list required by the WMS client</p>
60
 * 
61
 * 
62
 * @return Vector, the list of layers
63
 */
64
    public Vector getLayerNames() {        
65
        return layers;
66
    } 
67

    
68
/**
69
 * <p> Adds a layer to the list of layers required by the WMS client</p>
70
 * 
71
 * 
72
 * @param _layerName, name of the layer to be added. 
73
 */
74
    public void addLayerName(String _layerName) {        
75
        layers.add(_layerName);
76
    } 
77

    
78
/**
79
 * <p>removes a layer from the layer list</p>
80
 * 
81
 * 
82
 * @param _layerName 
83
 * @return true if the layer name has been deleted from the list
84
 */
85
    public boolean removeLayerName(String _layerName) {
86
            return layers.remove(_layerName);       
87
    } 
88

    
89
/**
90
 * <p>gets the styles list required by the WMS client</p>
91
 * 
92
 * 
93
 * @return Vector with the list of layer styles
94
 */
95
    public Vector getStyles() {        
96
        return styles;
97
    } 
98

    
99
/**
100
 * <p>sets the styles list required by the WMS client</p>
101
 * 
102
 * 
103
 * @param _styles, list to be set as the required styles.
104
 */
105
    public void setStyles(Vector _styles) {        
106
        styles = _styles;
107
    }
108
    
109
    /**
110
     * <p>sets the styles list required by the WMS client</p>
111
     * 
112
     * 
113
     * @param _styles, list to be set as the required styles.
114
     */
115
    public void setDimensions(Vector _dimensions) {        
116
        
117
        dimensions = _dimensions;
118
    } 
119

    
120
/**
121
 * <p>Adds a style name to the styles list required by the WMS client</p>
122
 * 
123
 * 
124
 * @param _name, style name to be added
125
 */
126
    public void addStyleName(String _name) {        
127
        styles.add( _name);
128
    } 
129

    
130
/**
131
 * <p>Removes a style from the list of styles required by the WMS client</p>
132
 * 
133
 * 
134
 * @param _name, style name to be removed
135
 */
136
    public boolean removeStyleName(String _name) {        
137
        return styles.remove(_name);
138
    } 
139
/**
140
 * <p>Gets the extent defined by the map</p>
141
 */
142
    public Rectangle2D getExtent() {        
143
        return extent;
144
    } 
145
/**
146
 * <p>Sets the extent defined by the map</p>
147
 */
148
    public void setExtent(Rectangle2D extent) {        
149
        this.extent = extent;
150
    } 
151
 
152
   
153

    
154
    /**
155
     * @return
156
     */
157
    public boolean getTransparency() {
158
        return transparency;
159
    }
160

    
161
    /**
162
     * @param wmsTransparency
163
     */
164
    public void setTransparency(boolean wmsTransparency) {
165
        transparency = wmsTransparency;
166
    }
167

    
168
    /**
169
     * @return
170
     */
171
    public Vector getDimensions() {
172
        return dimensions;
173
    }
174
    
175
    public boolean equals(Object obj){
176
        if (!(obj instanceof WMSStatus))
177
            return false;
178
        WMSStatus s = (WMSStatus) obj;
179
        
180
        // Compare layer names
181
        if (!(( s.getLayerNames()==null && this.getLayerNames()==null) ||
182
                s.getLayerNames().equals(this.getLayerNames())))
183
                return false;
184
        
185
        // Compare extent
186
        if (!(( s.getExtent()==null && this.getExtent()==null) ||
187
                s.getExtent().equals(this.getExtent())))
188
                return false;
189
        
190
        // Compare height
191
        if ( s.getHeight() != this.getHeight())
192
                return false;
193
                
194
        // Compare width
195
        if ( s.getWidth()  != this.getWidth())
196
                return false;
197
        
198
        // Compare styles
199
        if (!(( s.getStyles()==null && this.getStyles()==null) ||
200
                s.getStyles().equals(this.getStyles())))
201
                return false;
202
        
203
        // Compare dimensions
204
        if (!(( s.getDimensions()==null && this.getDimensions()==null) ||
205
                s.getDimensions().equals(this.getDimensions())))
206
                return false;
207
        
208
        // Compare transparencies
209
        if ( s.getTransparency() != this.getTransparency())
210
                return false;
211

    
212
                // Compare srs
213
        if (!(( s.getSrs()==null && this.getSrs()==null) || 
214
                        s.getSrs().equals(this.getSrs())))
215
                return false;
216
        
217
        // Compare exception formats
218
        if (!(( s.getExceptionFormat()==null && this.getExceptionFormat()==null) ||
219
                        s.getExceptionFormat().equals(this.getExceptionFormat())))
220
                return false;
221
        
222
        // Compare formats
223
        if (!(( s.getFormat()==null && this.getFormat()==null) ||
224
                        s.getFormat().equals(this.getFormat())))
225
                return false;
226
        
227
        // Compare online resources
228
        if (!(( s.getOnlineResource()==null && this.getOnlineResource()==null) ||
229
                        s.getOnlineResource().equals(this.getOnlineResource())))
230
                return false;
231
        
232
        return true;
233
    }
234
    
235
    public Object clone() {
236
            WMSStatus newObject = new WMSStatus();
237
            Vector v = this.getLayerNames();
238
            if (v != null)
239
                    newObject.setLayerNames((Vector)v.clone());
240
            Rectangle2D r = this.getExtent();
241
            if (r != null)
242
                    newObject.setExtent((Rectangle2D)r.clone());
243
        newObject.setHeight(this.getHeight());
244
        newObject.setWidth(this.getWidth());
245
        v = this.getStyles();
246
        if (v != null)
247
                newObject.setStyles((Vector)v.clone());
248
        v = this.getDimensions();
249
        if (v != null)
250
                newObject.setDimensions((Vector)v.clone());
251
        newObject.setTransparency(this.getTransparency());
252
        newObject.setSrs(this.getSrs());
253
        newObject.setExceptionFormat(this.getExceptionFormat());
254
        newObject.setFormat(this.getFormat());
255
        newObject.setOnlineResource(this.getOnlineResource());
256
        newObject.setProjected(isProjected());
257
            return newObject;
258
    }
259

    
260
    /**
261
     * Returns the URL that the server specified for a WMS request if any was described in
262
     * its capabilities document. 
263
     * @param operationName, a String containing the name of the operation (case-independent)
264
     * @return <b>String</b> containing the URL for this operationName or <B>null</B> if none was
265
     *                specified.
266
     */
267
        public String getOnlineResource() {
268
                return onlineResource;
269
        }
270
        
271
        /**
272
         * Sets the string literal containing the URL of an online resource for a specific
273
         * WMS request.
274
         * @param operationName, String telling to which request correspond the address
275
         * @param url, String containing the URL for the given WMS request
276
         */
277
        public void setOnlineResource(String url) {
278
                onlineResource = url;
279
        }
280
        
281
        public boolean isProjected() {
282
                return projectedCoordinates;
283
        }
284
        
285
        public void setProjected(boolean projected) {
286
                this.projectedCoordinates = projected;
287
        }
288

    
289
}