Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_908 / libraries / libRemoteServices / src / org / gvsig / remoteClient / wms / WMSStatus.java @ 11054

History | View | Annotate | Download (6.96 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
    public WMSStatus()
26
    {
27
            layers = new Vector();
28
            styles = new Vector();                        
29
    }
30
    
31
    // sets the list of layers required by the WMS client
32
    public void setLayerNames(Vector _layers) {        
33
        layers = _layers;
34
    } 
35

    
36
/**
37
 * <p>Retrieves the layer list required by the WMS client</p>
38
 * 
39
 * 
40
 * @return Vector, the list of layers
41
 */
42
    public Vector getLayerNames() {        
43
        return layers;
44
    } 
45

    
46
/**
47
 * <p> Adds a layer to the list of layers required by the WMS client</p>
48
 * 
49
 * 
50
 * @param _layerName, name of the layer to be added. 
51
 */
52
    public void addLayerName(String _layerName) {        
53
        layers.add(_layerName);
54
    } 
55

    
56
/**
57
 * <p>removes a layer from the layer list</p>
58
 * 
59
 * 
60
 * @param _layerName 
61
 * @return true if the layer name has been deleted from the list
62
 */
63
    public boolean removeLayerName(String _layerName) {
64
            return layers.remove(_layerName);       
65
    } 
66

    
67
/**
68
 * <p>gets the styles list required by the WMS client</p>
69
 * 
70
 * 
71
 * @return Vector with the list of layer styles
72
 */
73
    public Vector getStyles() {        
74
        return styles;
75
    } 
76

    
77
/**
78
 * <p>sets the styles list required by the WMS client</p>
79
 * 
80
 * 
81
 * @param _styles, list to be set as the required styles.
82
 */
83
    public void setStyles(Vector _styles) {        
84
        styles = _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 setDimensions(Vector _dimensions) {        
94
        
95
        dimensions = _dimensions;
96
    } 
97

    
98
/**
99
 * <p>Adds a style name to the styles list required by the WMS client</p>
100
 * 
101
 * 
102
 * @param _name, style name to be added
103
 */
104
    public void addStyleName(String _name) {        
105
        styles.add( _name);
106
    } 
107

    
108
/**
109
 * <p>Removes a style from the list of styles required by the WMS client</p>
110
 * 
111
 * 
112
 * @param _name, style name to be removed
113
 */
114
    public boolean removeStyleName(String _name) {        
115
        return styles.remove(_name);
116
    } 
117
/**
118
 * <p>Gets the extent defined by the map</p>
119
 */
120
    public Rectangle2D getExtent() {        
121
        return extent;
122
    } 
123
/**
124
 * <p>Sets the extent defined by the map</p>
125
 */
126
    public void setExtent(Rectangle2D extent) {        
127
        this.extent = extent;
128
    } 
129
 
130
   
131

    
132
    /**
133
     * @return
134
     */
135
    public boolean getTransparency() {
136
        return transparency;
137
    }
138

    
139
    /**
140
     * @param wmsTransparency
141
     */
142
    public void setTransparency(boolean wmsTransparency) {
143
        transparency = wmsTransparency;
144
    }
145

    
146
    /**
147
     * @return
148
     */
149
    public Vector getDimensions() {
150
        return dimensions;
151
    }
152
    
153
    public boolean equals(Object obj){
154
        if (!(obj instanceof WMSStatus))
155
            return false;
156
        WMSStatus s = (WMSStatus) obj;
157
        
158
        // Compare layer names
159
        if (!(( s.getLayerNames()==null && this.getLayerNames()==null) ||
160
                s.getLayerNames().equals(this.getLayerNames())))
161
                return false;
162
        
163
        // Compare extent
164
        if (!(( s.getExtent()==null && this.getExtent()==null) ||
165
                s.getExtent().equals(this.getExtent())))
166
                return false;
167
        
168
        // Compare height
169
        if ( s.getHeight() != this.getHeight())
170
                return false;
171
                
172
        // Compare width
173
        if ( s.getWidth()  != this.getWidth())
174
                return false;
175
        
176
        // Compare styles
177
        if (!(( s.getStyles()==null && this.getStyles()==null) ||
178
                s.getStyles().equals(this.getStyles())))
179
                return false;
180
        
181
        // Compare dimensions
182
        if (!(( s.getDimensions()==null && this.getDimensions()==null) ||
183
                s.getDimensions().equals(this.getDimensions())))
184
                return false;
185
        
186
        // Compare transparencies
187
        if ( s.getTransparency() != this.getTransparency())
188
                return false;
189

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

    
237
    /**
238
     * Returns the URL that the server specified for a WMS request if any was described in
239
     * its capabilities document. 
240
     * @param operationName, a String containing the name of the operation (case-independent)
241
     * @return <b>String</b> containing the URL for this operationName or <B>null</B> if none was
242
     *                specified.
243
     */
244
        public String getOnlineResource() {
245
                return onlineResource;
246
        }
247
        
248
        /**
249
         * Sets the string literal containing the URL of an online resource for a specific
250
         * WMS request.
251
         * @param operationName, String telling to which request correspond the address
252
         * @param url, String containing the URL for the given WMS request
253
         */
254
        public void setOnlineResource(String url) {
255
                onlineResource = url;
256
        }
257
}