Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wms / WMSStatus.java @ 38579

History | View | Annotate | Download (6.96 KB)

1 3323 ldiaz
2 29658 jpiera
package org.gvsig.remoteclient.wms;
3 3323 ldiaz
4 3345 ldiaz
import java.awt.geom.Rectangle2D;
5 3323 ldiaz
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 29658 jpiera
public class WMSStatus extends org.gvsig.remoteclient.RemoteClientStatus {
14 3838 ldiaz
        // list of layer to be retrieved by the WMS
15 3323 ldiaz
    private Vector layers;
16
    // List of layer styles
17
    private Vector styles;
18 3572 jaume
    private Vector dimensions;
19 3323 ldiaz
    // extent required by the WMS client
20 3345 ldiaz
    private Rectangle2D extent;
21 3520 jaume
    private boolean transparency;
22 4222 jaume
        private String onlineResource;
23 3351 ldiaz
    public WMSStatus()
24
    {
25
            layers = new Vector();
26
            styles = new Vector();
27
    }
28
29 3323 ldiaz
    // sets the list of layers required by the WMS client
30
    public void setLayerNames(Vector _layers) {
31
        layers = _layers;
32
    }
33
34
/**
35
 * <p>Retrieves the layer list required by the WMS client</p>
36
 *
37
 *
38
 * @return Vector, the list of layers
39
 */
40
    public Vector getLayerNames() {
41
        return layers;
42
    }
43
44
/**
45
 * <p> Adds a layer to the list of layers required by the WMS client</p>
46
 *
47
 *
48
 * @param _layerName, name of the layer to be added.
49
 */
50
    public void addLayerName(String _layerName) {
51
        layers.add(_layerName);
52
    }
53
54
/**
55
 * <p>removes a layer from the layer list</p>
56
 *
57
 *
58
 * @param _layerName
59
 * @return true if the layer name has been deleted from the list
60
 */
61
    public boolean removeLayerName(String _layerName) {
62
            return layers.remove(_layerName);
63
    }
64
65
/**
66
 * <p>gets the styles list required by the WMS client</p>
67
 *
68
 *
69
 * @return Vector with the list of layer styles
70
 */
71
    public Vector getStyles() {
72
        return styles;
73
    }
74
75
/**
76
 * <p>sets the styles list required by the WMS client</p>
77
 *
78
 *
79
 * @param _styles, list to be set as the required styles.
80
 */
81
    public void setStyles(Vector _styles) {
82
        styles = _styles;
83 3572 jaume
    }
84
85
    /**
86
     * <p>sets the styles list required by the WMS client</p>
87
     *
88
     *
89
     * @param _styles, list to be set as the required styles.
90
     */
91
    public void setDimensions(Vector _dimensions) {
92
93
        dimensions = _dimensions;
94 3323 ldiaz
    }
95
96
/**
97
 * <p>Adds a style name to the styles list required by the WMS client</p>
98
 *
99
 *
100
 * @param _name, style name to be added
101
 */
102
    public void addStyleName(String _name) {
103
        styles.add( _name);
104
    }
105
106
/**
107
 * <p>Removes a style from the list of styles required by the WMS client</p>
108
 *
109
 *
110
 * @param _name, style name to be removed
111
 */
112
    public boolean removeStyleName(String _name) {
113
        return styles.remove(_name);
114
    }
115 3345 ldiaz
/**
116
 * <p>Gets the extent defined by the map</p>
117
 */
118
    public Rectangle2D getExtent() {
119
        return extent;
120
    }
121
/**
122
 * <p>Sets the extent defined by the map</p>
123
 */
124
    public void setExtent(Rectangle2D extent) {
125
        this.extent = extent;
126
    }
127 3520 jaume
128 4222 jaume
129 3520 jaume
130
    /**
131
     * @return
132
     */
133 3592 jaume
    public boolean getTransparency() {
134 3520 jaume
        return transparency;
135
    }
136
137
    /**
138
     * @param wmsTransparency
139
     */
140
    public void setTransparency(boolean wmsTransparency) {
141
        transparency = wmsTransparency;
142
    }
143 3572 jaume
144
    /**
145
     * @return
146
     */
147
    public Vector getDimensions() {
148
        return dimensions;
149
    }
150 3520 jaume
151 4222 jaume
    public boolean equals(Object obj){
152
        if (!(obj instanceof WMSStatus))
153
            return false;
154
        WMSStatus s = (WMSStatus) obj;
155
156
        // Compare layer names
157
        if (!(( s.getLayerNames()==null && this.getLayerNames()==null) ||
158
                s.getLayerNames().equals(this.getLayerNames())))
159
                return false;
160
161
        // Compare extent
162
        if (!(( s.getExtent()==null && this.getExtent()==null) ||
163
                s.getExtent().equals(this.getExtent())))
164
                return false;
165
166
        // Compare height
167
        if ( s.getHeight() != this.getHeight())
168
                return false;
169
170
        // Compare width
171
        if ( s.getWidth()  != this.getWidth())
172
                return false;
173
174
        // Compare styles
175
        if (!(( s.getStyles()==null && this.getStyles()==null) ||
176
                s.getStyles().equals(this.getStyles())))
177
                return false;
178
179
        // Compare dimensions
180
        if (!(( s.getDimensions()==null && this.getDimensions()==null) ||
181
                s.getDimensions().equals(this.getDimensions())))
182
                return false;
183
184
        // Compare transparencies
185
        if ( s.getTransparency() != this.getTransparency())
186
                return false;
187
188
                // Compare srs
189
        if (!(( s.getSrs()==null && this.getSrs()==null) ||
190
                        s.getSrs().equals(this.getSrs())))
191
                return false;
192
193
        // Compare exception formats
194
        if (!(( s.getExceptionFormat()==null && this.getExceptionFormat()==null) ||
195
                        s.getExceptionFormat().equals(this.getExceptionFormat())))
196
                return false;
197
198
        // Compare formats
199
        if (!(( s.getFormat()==null && this.getFormat()==null) ||
200
                        s.getFormat().equals(this.getFormat())))
201
                return false;
202
203
        // Compare online resources
204
        if (!(( s.getOnlineResource()==null && this.getOnlineResource()==null) ||
205
                        s.getOnlineResource().equals(this.getOnlineResource())))
206
                return false;
207
208
        return true;
209
    }
210
211
    public Object clone() {
212
            WMSStatus newObject = new WMSStatus();
213
            Vector v = this.getLayerNames();
214
            if (v != null)
215
                    newObject.setLayerNames((Vector)v.clone());
216
            Rectangle2D r = this.getExtent();
217
            if (r != null)
218
                    newObject.setExtent((Rectangle2D)r.clone());
219
        newObject.setHeight(this.getHeight());
220
        newObject.setWidth(this.getWidth());
221
        v = this.getStyles();
222
        if (v != null)
223
                newObject.setStyles((Vector)v.clone());
224
        v = this.getDimensions();
225
        if (v != null)
226
                newObject.setDimensions((Vector)v.clone());
227
        newObject.setTransparency(this.getTransparency());
228
        newObject.setSrs(this.getSrs());
229
        newObject.setExceptionFormat(this.getExceptionFormat());
230
        newObject.setFormat(this.getFormat());
231
        newObject.setOnlineResource(this.getOnlineResource());
232
            return newObject;
233
    }
234
235
    /**
236
     * Returns the URL that the server specified for a WMS request if any was described in
237
     * its capabilities document.
238
     * @param operationName, a String containing the name of the operation (case-independent)
239
     * @return <b>String</b> containing the URL for this operationName or <B>null</B> if none was
240
     *                specified.
241
     */
242
        public String getOnlineResource() {
243
                return onlineResource;
244
        }
245
246
        /**
247
         * Sets the string literal containing the URL of an online resource for a specific
248
         * WMS request.
249
         * @param operationName, String telling to which request correspond the address
250
         * @param url, String containing the URL for the given WMS request
251
         */
252
        public void setOnlineResource(String url) {
253
                onlineResource = url;
254
        }
255 27881 jpiera
256 3520 jaume
}