Statistics
| Revision:

root / trunk / libraries / libRemoteServices / src / org / gvsig / remoteClient / wms / WMSStatus.java @ 37961

History | View | Annotate | Download (7.18 KB)

1

    
2
package org.gvsig.remoteClient.wms;
3

    
4
import java.awt.geom.Rectangle2D;
5
import java.util.Vector;
6

    
7
/**
8
 * Describes the status of a WMSclient, so it adds to the Remote client status
9
 * a list of layers, a list of layer styles, the extent of the map.
10
 * Provides the functionality to modify these lists.
11
 * 
12
 */
13
public class WMSStatus extends org.gvsig.remoteClient.RemoteClientStatus {
14

    
15

    
16
        // list of layer to be retrieved by the WMS
17
    private Vector layers;
18
    // List of layer styles
19
    private Vector styles;
20
    private Vector dimensions;
21
    // extent required by the WMS client
22
    private Rectangle2D extent;
23
    private boolean transparency;
24
        private String onlineResource;
25
        private String infoFormat;
26
        
27
    public String getInfoFormat() {
28
                return infoFormat;
29
        }
30

    
31
        public void setInfoFormat(String infoFormat) {
32
                this.infoFormat = infoFormat;
33
        }
34

    
35
        public WMSStatus()
36
    {
37
            layers = new Vector();
38
            styles = new Vector();                        
39
    }
40
    
41
    // sets the list of layers required by the WMS client
42
    public void setLayerNames(Vector _layers) {        
43
        layers = _layers;
44
    } 
45

    
46
/**
47
 * <p>Retrieves the layer list required by the WMS client</p>
48
 * 
49
 * 
50
 * @return Vector, the list of layers
51
 */
52
    public Vector getLayerNames() {        
53
        return layers;
54
    } 
55

    
56
/**
57
 * <p> Adds a layer to the list of layers required by the WMS client</p>
58
 * 
59
 * 
60
 * @param _layerName, name of the layer to be added. 
61
 */
62
    public void addLayerName(String _layerName) {        
63
        layers.add(_layerName);
64
    } 
65

    
66
/**
67
 * <p>removes a layer from the layer list</p>
68
 * 
69
 * 
70
 * @param _layerName 
71
 * @return true if the layer name has been deleted from the list
72
 */
73
    public boolean removeLayerName(String _layerName) {
74
            return layers.remove(_layerName);       
75
    } 
76

    
77
/**
78
 * <p>gets the styles list required by the WMS client</p>
79
 * 
80
 * 
81
 * @return Vector with the list of layer styles
82
 */
83
    public Vector getStyles() {        
84
        return styles;
85
    } 
86

    
87
/**
88
 * <p>sets the styles list required by the WMS client</p>
89
 * 
90
 * 
91
 * @param _styles, list to be set as the required styles.
92
 */
93
    public void setStyles(Vector _styles) {        
94
        styles = _styles;
95
    }
96
    
97
    /**
98
     * <p>sets the styles list required by the WMS client</p>
99
     * 
100
     * 
101
     * @param _styles, list to be set as the required styles.
102
     */
103
    public void setDimensions(Vector _dimensions) {        
104
        
105
        dimensions = _dimensions;
106
    } 
107

    
108
/**
109
 * <p>Adds a style name to the styles list required by the WMS client</p>
110
 * 
111
 * 
112
 * @param _name, style name to be added
113
 */
114
    public void addStyleName(String _name) {        
115
        styles.add( _name);
116
    } 
117

    
118
/**
119
 * <p>Removes a style from the list of styles required by the WMS client</p>
120
 * 
121
 * 
122
 * @param _name, style name to be removed
123
 */
124
    public boolean removeStyleName(String _name) {        
125
        return styles.remove(_name);
126
    } 
127
/**
128
 * <p>Gets the extent defined by the map</p>
129
 */
130
    public Rectangle2D getExtent() {        
131
        return extent;
132
    } 
133
/**
134
 * <p>Sets the extent defined by the map</p>
135
 */
136
    public void setExtent(Rectangle2D extent) {        
137
        this.extent = extent;
138
    } 
139
 
140
   
141

    
142
    /**
143
     * @return
144
     */
145
    public boolean getTransparency() {
146
        return transparency;
147
    }
148

    
149
    /**
150
     * @param wmsTransparency
151
     */
152
    public void setTransparency(boolean wmsTransparency) {
153
        transparency = wmsTransparency;
154
    }
155

    
156
    /**
157
     * @return
158
     */
159
    public Vector getDimensions() {
160
        return dimensions;
161
    }
162
    
163
    public boolean equals(Object obj){
164
        if (!(obj instanceof WMSStatus))
165
            return false;
166
        WMSStatus s = (WMSStatus) obj;
167
        
168
        // Compare layer names
169
        if (!(( s.getLayerNames()==null && this.getLayerNames()==null) ||
170
                s.getLayerNames().equals(this.getLayerNames())))
171
                return false;
172
        
173
        // Compare extent
174
        if (!(( s.getExtent()==null && this.getExtent()==null) ||
175
                s.getExtent().equals(this.getExtent())))
176
                return false;
177
        
178
        // Compare height
179
        if ( s.getHeight() != this.getHeight())
180
                return false;
181
                
182
        // Compare width
183
        if ( s.getWidth()  != this.getWidth())
184
                return false;
185
        
186
        // Compare styles
187
        if (!(( s.getStyles()==null && this.getStyles()==null) ||
188
                s.getStyles().equals(this.getStyles())))
189
                return false;
190
        
191
        // Compare dimensions
192
        if (!(( s.getDimensions()==null && this.getDimensions()==null) ||
193
                s.getDimensions().equals(this.getDimensions())))
194
                return false;
195
        
196
        // Compare transparencies
197
        if ( s.getTransparency() != this.getTransparency())
198
                return false;
199

    
200
                // Compare srs
201
        if (!(( s.getSrs()==null && this.getSrs()==null) || 
202
                        s.getSrs().equals(this.getSrs())))
203
                return false;
204
        
205
        // Compare exception formats
206
        if (!(( s.getExceptionFormat()==null && this.getExceptionFormat()==null) ||
207
                        s.getExceptionFormat().equals(this.getExceptionFormat())))
208
                return false;
209
        
210
        // Compare formats
211
        if (!(( s.getFormat()==null && this.getFormat()==null) ||
212
                        s.getFormat().equals(this.getFormat())))
213
                return false;
214
        
215
        // Compare online resources
216
        if (!(( s.getOnlineResource()==null && this.getOnlineResource()==null) ||
217
                        s.getOnlineResource().equals(this.getOnlineResource())))
218
                return false;
219
        
220
        return true;
221
    }
222
    
223
    public Object clone() {
224
            WMSStatus newObject = new WMSStatus();
225
            Vector v = this.getLayerNames();
226
            if (v != null)
227
                    newObject.setLayerNames((Vector)v.clone());
228
            Rectangle2D r = this.getExtent();
229
            if (r != null)
230
                    newObject.setExtent((Rectangle2D)r.clone());
231
        newObject.setHeight(this.getHeight());
232
        newObject.setWidth(this.getWidth());
233
        v = this.getStyles();
234
        if (v != null)
235
                newObject.setStyles((Vector)v.clone());
236
        v = this.getDimensions();
237
        if (v != null)
238
                newObject.setDimensions((Vector)v.clone());
239
        newObject.setTransparency(this.getTransparency());
240
        newObject.setSrs(this.getSrs());
241
        newObject.setExceptionFormat(this.getExceptionFormat());
242
        newObject.setFormat(this.getFormat());
243
        newObject.setOnlineResource(this.getOnlineResource());
244
        newObject.setInfoFormat(this.infoFormat);
245
            return newObject;
246
    }
247

    
248
    /**
249
     * Returns the URL that the server specified for a WMS request if any was described in
250
     * its capabilities document. 
251
     * @param operationName, a String containing the name of the operation (case-independent)
252
     * @return <b>String</b> containing the URL for this operationName or <B>null</B> if none was
253
     *                specified.
254
     */
255
        public String getOnlineResource() {
256
                return onlineResource;
257
        }
258
        
259
        /**
260
         * Sets the string literal containing the URL of an online resource for a specific
261
         * WMS request.
262
         * @param operationName, String telling to which request correspond the address
263
         * @param url, String containing the URL for the given WMS request
264
         */
265
        public void setOnlineResource(String url) {
266
                onlineResource = url;
267
        }
268
}