Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / org.gvsig.arcims / src / org / gvsig / remoteclient / arcims / ArcImsStatus.java @ 32538

History | View | Annotate | Download (11.2 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 Prodevelop S.L. main development
26
 * http://www.prodevelop.es
27
 */
28

    
29
package org.gvsig.remoteclient.arcims;
30

    
31
import java.awt.Dimension;
32
import java.awt.geom.Rectangle2D;
33
import java.util.Vector;
34

    
35
import org.gvsig.fmap.geom.primitive.Point;
36
import org.gvsig.fmap.geom.primitive.impl.Envelope2D;
37
import org.gvsig.remoteclient.RemoteClientStatus;
38
import org.gvsig.remoteclient.arcims.utils.ServiceInformation;
39

    
40
/**
41
 * Describes the status of a ArcImsclient, so it adds to the Remote client
42
 * status a list of layers, a list of layer styles, the extent of the map.
43
 * Provides the functionality to modify these lists.
44
 * 
45
 * @see org.gvsig.remoteClient.RemoteClientStatus
46
 * @author jcarrasco
47
 * @author jsanz
48
 * @author vsanjaime version 2.0
49
 * 
50
 */
51
public class ArcImsStatus extends RemoteClientStatus implements Cloneable {
52

    
53
        private String serverURL;
54
        private String serviceType;
55
        private String serviceName;
56
        private String serverVersion;
57
        private String newLayerName;
58
        /**
59
         * List of layer to be retrieved by the ArcIms
60
         */
61
        private Vector<String> layersIdsSelected;
62

    
63
        /**
64
         * List of layer styles
65
         */
66
        private Vector<String> styles;
67

    
68
        /**
69
         * Extent required by the ArcIms client
70
         */
71
        private Envelope2D envelope;
72

    
73
        /**
74
         * The ArcIMS Service delivers images with transparency
75
         */
76
        private boolean transparency;
77
        private String onlineResource;
78
        private Vector<Dimension> dimensions;
79
        private ServiceInformation serviceInfo;
80
        public boolean verbose;
81

    
82
        /**
83
         * Constructor
84
         * 
85
         */
86
        public ArcImsStatus() {
87
                layersIdsSelected = new Vector<String>();
88
                styles = new Vector<String>();
89
                verbose = false;
90
        }
91

    
92
        /**
93
         * Retrieves a vector of Dimensions
94
         * 
95
         * @return Vector, the list of dimensions
96
         */
97
        public Vector<Dimension> getDimensions() {
98
                return dimensions;
99
        }
100

    
101
        /**
102
         * Sets the dimensions of the client
103
         * 
104
         * @param dimensions
105
         *            A vector of dimensions
106
         */
107
        public void setDimensions(Vector<Dimension> dimensions) {
108
                this.dimensions = dimensions;
109
        }
110

    
111
        /**
112
         * <p>
113
         * Retrieves the layer list required by the ArcIms client
114
         * </p>
115
         * 
116
         * @return Vector, the list of layers
117
         */
118
        public Vector<String> getLayersIdsSelected() {
119
                return layersIdsSelected;
120
        }
121

    
122
        /**
123
         * Sets the list of layers required by the ArcIms client
124
         * 
125
         * @param _layers
126
         *            Vector, the list of layers to set
127
         */
128
        public void setLayersIdsSelected(Vector<String> _layers) {
129
                layersIdsSelected = _layers;
130
        }
131

    
132
        /**
133
         * <p>
134
         * Adds a layer to the list of layers required by the ArcIms client
135
         * </p>
136
         * 
137
         * @param alayerName
138
         *            name of the layer to be added.
139
         */
140
        public void addLayerIdSelected(String alayerName) {
141
                layersIdsSelected.add(alayerName);
142
        }
143

    
144
        /**
145
         * <p>
146
         * Removes a layer from the layer list
147
         * </p>
148
         * 
149
         * @param alayerName
150
         * @return true if the layer name has been deleted from the list
151
         */
152
        public boolean removeLayerIdSelected(String alayerName) {
153
                return layersIdsSelected.remove(alayerName);
154
        }
155

    
156
        /**
157
         * <p>
158
         * Gets the styles list required by the ArcIms client
159
         * </p>
160
         * 
161
         * @return Vector with the list of layer styles
162
         */
163
        public Vector<String> getStyles() {
164
                return styles;
165
        }
166

    
167
        /**
168
         * <p>
169
         * sets the styles list required by the ArcIms client
170
         * </p>
171
         * 
172
         * 
173
         * @param astyles
174
         *            list to be set as the required styles.
175
         */
176
        public void setStyles(Vector<String> astyles) {
177
                styles = astyles;
178
        }
179

    
180
        /**
181
         * <p>
182
         * Adds a style name to the styles list required by the ArcIms client
183
         * </p>
184
         * 
185
         * 
186
         * @param aname
187
         *            style name to be added
188
         */
189
        public void addStyleName(String aname) {
190
                styles.add(aname);
191
        }
192

    
193
        /**
194
         * <p>
195
         * Removes a style from the list of styles required by the ArcIms client
196
         * </p>
197
         * 
198
         * 
199
         * @param aname
200
         *            style name to be removed
201
         */
202
        public boolean removeStyleName(String aname) {
203
                return styles.remove(aname);
204
        }
205

    
206
        /**
207
         * <p>
208
         * Gets the extent defined by the map
209
         * </p>
210
         */
211
        public Envelope2D getEnvelope() {
212
                return this.envelope;
213
        }
214

    
215
        /**
216
         * <p>
217
         * Gets the extent defined by the map
218
         * </p>
219
         */
220
        public Rectangle2D getEnvelopeRect() {
221
                double xmin = this.envelope.getMinimum(0);
222
                double ymin = this.envelope.getMinimum(1);
223
                double w = this.envelope.getMaximum(0) - xmin;
224
                double h = this.envelope.getMaximum(1) - ymin;
225
                Rectangle2D bBox = new Rectangle2D.Double(xmin, ymin, w, h);
226
                return bBox;
227
        }
228

    
229
        /**
230
         * <p>
231
         * Sets the extent defined by the map
232
         * </p>
233
         */
234
        public void setEnvelope(Envelope2D envelope) {
235
                this.envelope = envelope;
236
        }
237

    
238
        /**
239
         * <p>
240
         * Sets the extent defined by the map
241
         * </p>
242
         */
243
        public void setEnvelope(Rectangle2D b) {
244
                Envelope2D enve = new Envelope2D(b.getMinX(), b.getMinY(), b.getMaxX(),
245
                                b.getMaxY());
246
                this.envelope = enve;
247
        }
248

    
249
        /**
250
         * Gets transparency
251
         * 
252
         * @return boolean
253
         */
254
        public boolean getTransparency() {
255
                return transparency;
256
        }
257

    
258
        /**
259
         * Sets transparency
260
         * 
261
         * @param arcimsTransparency
262
         */
263
        public void setTransparency(boolean arcimsTransparency) {
264
                transparency = arcimsTransparency;
265
        }
266

    
267
        /*
268
         * (non-Javadoc)
269
         * 
270
         * @see java.lang.Object#equals(java.lang.Object)
271
         */
272
        public boolean equals(Object obj) {
273
                if (!(obj instanceof ArcImsStatus)) {
274
                        return false;
275
                }
276

    
277
                ArcImsStatus s = (ArcImsStatus) obj;
278

    
279
                // Compare layer names
280
                if (!(((s.getLayersIdsSelected() == null) && (this
281
                                .getLayersIdsSelected() == null)) || s.getLayersIdsSelected()
282
                                .equals(this.getLayersIdsSelected()))) {
283
                        return false;
284
                }
285

    
286
                // Compare extent
287
                if (!(((s.getEnvelope() == null) && (this.getEnvelope() == null)) || s
288
                                .getEnvelope().equals(this.getEnvelope()))) {
289
                        return false;
290
                }
291

    
292
                // Compare height
293
                if (s.getHeight() != this.getHeight()) {
294
                        return false;
295
                }
296

    
297
                // Compare width
298
                if (s.getWidth() != this.getWidth()) {
299
                        return false;
300
                }
301

    
302
                // Compare styles
303
                if (!(((s.getStyles() == null) && (this.getStyles() == null)) || s
304
                                .getStyles().equals(this.getStyles()))) {
305
                        return false;
306
                }
307

    
308
                // Compare transparencies
309
                if (s.getTransparency() != this.getTransparency()) {
310
                        return false;
311
                }
312

    
313
                // Compare srs
314
                if (!(((s.getSrs() == null) && (this.getSrs() == null)) || s.getSrs()
315
                                .equals(this.getSrs()))) {
316
                        return false;
317
                }
318

    
319
                // Compare exception formats
320
                if (!(((s.getExceptionFormat() == null) && (this.getExceptionFormat() == null)) || s
321
                                .getExceptionFormat().equals(this.getExceptionFormat()))) {
322
                        return false;
323
                }
324

    
325
                // Compare formats
326
                if (!(((s.getFormat() == null) && (this.getFormat() == null)) || s
327
                                .getFormat().equals(this.getFormat()))) {
328
                        return false;
329
                }
330

    
331
                // Compare online resources
332
                if (!(((s.getOnlineResource() == null) && (this.getOnlineResource() == null)) || s
333
                                .getOnlineResource().equals(this.getOnlineResource()))) {
334
                        return false;
335
                }
336

    
337
                return true;
338
        }
339

    
340
        /*
341
         * (non-Javadoc)
342
         * 
343
         * @see java.lang.Object#clone()
344
         */
345
        public Object clone() {
346
                ArcImsStatus newObject = new ArcImsStatus();
347
                Vector<String> v = this.getLayersIdsSelected();
348

    
349
                if (v != null) {
350
                        newObject.setLayersIdsSelected((Vector) v.clone());
351
                }
352

    
353
                Envelope2D enve = this.getEnvelope();
354
                Point pmin = enve.getLowerCorner();
355
                Point pmax = enve.getUpperCorner();
356
                double w = pmax.getX() - pmin.getX();
357
                double h = pmax.getY() - pmin.getY();
358
                Rectangle2D r = new Rectangle2D.Double(pmin.getX(), pmin.getY(), w, h);
359

    
360
                if (r != null) {
361
                        newObject.setEnvelope((Rectangle2D) r.clone());
362
                }
363

    
364
                newObject.setHeight(this.getHeight());
365
                newObject.setWidth(this.getWidth());
366
                v = this.getStyles();
367

    
368
                if (v != null) {
369
                        newObject.setStyles((Vector) v.clone());
370
                }
371

    
372
                newObject.setTransparency(this.getTransparency());
373
                newObject.setSrs(this.getSrs());
374
                newObject.setFormat(this.getFormat());
375
                newObject.setOnlineResource(this.getOnlineResource());
376

    
377
                ServiceInformation si = this.getServiceInfo();
378

    
379
                if (si != null) {
380
                        newObject.setServiceInformation((ServiceInformation) si.clone());
381
                }
382

    
383
                return newObject;
384
        }
385

    
386
        /**
387
         * Returns the URL that the server specified for a ArcIms request if any was
388
         * described in its capabilities document.
389
         * 
390
         * @return <b>String</b> containing the URL for this operationName or
391
         *         <B>null</B> if none was specified.
392
         */
393
        public String getOnlineResource() {
394
                return onlineResource;
395
        }
396

    
397
        /**
398
         * Sets the string literal containing the URL of an online resource for a
399
         * specific ArcIms request.
400
         * 
401
         * @param url
402
         *            String containing the URL for the given ArcIms request
403
         */
404
        public void setOnlineResource(String url) {
405
                onlineResource = url;
406
        }
407

    
408
        /**
409
         * Gets service
410
         * 
411
         * @return service
412
         */
413
        public String getServiceName() {
414
                return serviceName;
415
        }
416

    
417
        /**
418
         * Sets service
419
         * 
420
         * @param service
421
         */
422
        public void setServiceName(String service) {
423
                this.serviceName = service;
424
        }
425

    
426
        /**
427
         * Sets the Service Information object of the status
428
         * 
429
         * @param si
430
         */
431
        public void setServiceInformation(ServiceInformation si) {
432
                this.serviceInfo = si;
433

    
434
        }
435

    
436
        /**
437
         * Gets the Servcie Information
438
         */
439
        public ServiceInformation getServiceInfo() {
440
                return serviceInfo;
441
        }
442

    
443
        /**
444
         * Gets server
445
         */
446
        public String getServerURL() {
447
                return serverURL;
448
        }
449

    
450
        /**
451
         * Sets server
452
         * 
453
         * @param server
454
         */
455
        public void setServerURL(String server) {
456
                this.serverURL = server;
457
        }
458

    
459
        /**
460
         * 
461
         * @return
462
         */
463
        public String getServiceType() {
464
                return serviceType;
465
        }
466

    
467
        /**
468
         * 
469
         * @param serviceType
470
         */
471
        public void setServiceType(String serviceType) {
472
                this.serviceType = serviceType;
473
        }
474

    
475
        /**
476
         * 
477
         * @return
478
         */
479
        public String getLayerQueryString() {
480

    
481
                String lyrs = "";
482
                if (layersIdsSelected.size() > 0) {
483
                        lyrs = layersIdsSelected.get(0);
484
                        for (int i = 1; i < layersIdsSelected.size(); i++) {
485
                                lyrs = lyrs + "," + layersIdsSelected.get(i);
486
                        }
487
                }
488
                return lyrs;
489
        }
490

    
491
        /**
492
         * 
493
         * @return
494
         */
495
        public void setLayerQueryString(String layers) {
496

    
497
                layersIdsSelected.clear();
498
                String[] lyrs = layers.split(",");
499
                if (lyrs.length > 0) {
500
                        for (int i = 0; i < lyrs.length; i++) {
501
                                layersIdsSelected.add(lyrs[i]);
502
                        }
503
                }
504
        }
505

    
506
        /**
507
         * 
508
         * @return
509
         */
510
        public String getNewLayerName() {
511
                return newLayerName;
512
        }
513

    
514
        /**
515
         * 
516
         * @param newLayerName
517
         */
518
        public void setNewLayerName(String newLayerName) {
519
                this.newLayerName = newLayerName;
520
        }
521

    
522
        /**
523
         * 
524
         * @return
525
         */
526
        public String getServerVersion() {
527
                return serverVersion;
528
        }
529

    
530
        /**
531
         * 
532
         * @param serverVersion
533
         */
534
        public void setServerVersion(String serverVersion) {
535
                this.serverVersion = serverVersion;
536
        }
537

    
538

    
539

    
540
}