Statistics
| Revision:

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

History | View | Annotate | Download (10.7 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

    
55
        private String serviceType;
56
        
57
        private String newLayerName;
58
        /**
59
         * List of layer to be retrieved by the ArcIms
60
         */
61
        private Vector<String> layersQuery;
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 String serviceName;
79
        private Vector<Dimension> dimensions;
80
        private ServiceInformation serviceInfo;
81
        public boolean verbose;
82

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
278
                ArcImsStatus s = (ArcImsStatus) obj;
279

    
280
                // Compare layer names
281
                if (!(((s.getLayerIds() == null) && (this.getLayerIds() == null)) || s
282
                                .getLayerIds().equals(this.getLayerIds()))) {
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.getLayerIds();
348

    
349
                if (v != null) {
350
                        newObject.setLayerIds((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
         * Gets the Servcie Information
437
         */
438
        public ServiceInformation getServiceInfo() {
439
                return serviceInfo;
440
        }
441

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

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

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

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

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

    
480
                String lyrs = "";
481
                if (layersQuery.size() > 0) {
482
                        lyrs = layersQuery.get(0);
483
                        for (int i = 1; i < layersQuery.size(); i++) {
484
                                lyrs = lyrs+","+layersQuery.get(i);
485
                        }
486
                }
487
                return lyrs;
488
        }
489
        
490
        /**
491
         * 
492
         * @return
493
         */
494
        public void setLayerQueryString(String layers) {
495

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

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

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

    
520
}