Statistics
| Revision:

root / trunk / libraries / libArcIMS / src / org / gvsig / remoteClient / arcims / utils / ServiceInformation.java @ 8109

History | View | Annotate | Download (13.7 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Prodevelop and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *   +34 963862235
28
 *   gvsig@gva.es
29
 *   www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   Prodevelop Integraci?n de Tecnolog?as SL
34
 *   Conde Salvatierra de ?lava , 34-10
35
 *   46004 Valencia
36
 *   Spain
37
 *
38
 *   +34 963 510 612
39
 *   +34 963 510 968
40
 *   gis@prodevelop.es
41
 *   http://www.prodevelop.es
42
 */
43

    
44
/**
45
 *
46
 */
47
package org.gvsig.remoteClient.arcims.utils;
48

    
49
import org.gvsig.remoteClient.utils.BoundaryBox;
50

    
51
import java.awt.geom.Rectangle2D;
52

    
53
import java.util.Iterator;
54
import java.util.Vector;
55

    
56

    
57
/**
58
 * Class that stores the general and layers information of an ArcIMS Server to
59
 * be retrieved by different classes (ArcImsStatus, ArcImsProtocolHandler,...)
60
 *
61
 * @author jsanz
62
 *
63
 */
64
public class ServiceInformation implements Cloneable {
65
    private String type;
66
    private ServiceInformationLocale locale;
67
    private ServiceInformationUIFont uifont;
68
    private ServiceInformationSeparators separators;
69
    private int screen_dpi;
70
    private String imagelimit_pixelcount;
71
    private String featurecoordsys;
72
    private boolean srsAssumed;
73
    private boolean dpiAssumed;
74

    
75
    /**
76
     * Envelope with name equal to "Initial_Extent", it will be the default
77
     * Envelope.
78
     */
79
    private BoundaryBox envelope;
80

    
81
    /**
82
     * Envelope with name equal to "Extent_Limit", it stores the maximum zoomout
83
     * extension defined in the configuration file. However, this information is
84
     * ignored by the ArcIMS Spatial Server.
85
     */
86
    private BoundaryBox envelopeEL;
87

    
88
    /**
89
     * Units of the map (metes, decimal_degrees, etc.
90
     */
91
    private String mapunits;
92

    
93
    /**
94
     * Vector of layers,
95
     *
96
     * @see ServiceInformationLayer
97
     */
98
    private Vector layers;
99

    
100
    /**
101
     * Constructor.
102
     *
103
     */
104
    public ServiceInformation() {
105
        type = new String();
106
        locale = new ServiceInformationLocale();
107
        uifont = new ServiceInformationUIFont();
108
        separators = new ServiceInformationSeparators();
109
        screen_dpi = 96;
110
        imagelimit_pixelcount = new String();
111
        envelope = new BoundaryBox();
112
        mapunits = new String();
113
        featurecoordsys = new String();
114
        layers = new Vector();
115
    }
116

    
117
    public Object clone() {
118
        ServiceInformation si = new ServiceInformation();
119
        si.setType(this.type);
120

    
121
        ServiceInformationLocale locale = this.locale;
122

    
123
        if (locale != null) {
124
            si.setLocale((ServiceInformationLocale) this.locale.clone());
125
        }
126

    
127
        return si;
128
    }
129

    
130
    public boolean isQueryable() {
131
        // if (operations.keySet().contains( CapabilitiesTags.GETFEATUREINFO ))
132
        return true;
133

    
134
        // else
135
        // return false;
136
        // }
137
    }
138

    
139
    public BoundaryBox getEnvelope() {
140
        return envelope;
141
    }
142

    
143
    public void setEnvelope(BoundaryBox envelope) {
144
        this.envelope = envelope;
145
    }
146

    
147
    public BoundaryBox getEnvelopeEL() {
148
        return envelopeEL;
149
    }
150

    
151
    public void setEnvelopeEL(BoundaryBox envelope) {
152
        this.envelopeEL = envelope;
153
    }
154

    
155
    public Rectangle2D getEnvelopeR2D() {
156
        Rectangle2D.Double r = new Rectangle2D.Double();
157
        r.setFrameFromDiagonal(envelope.getXmin(), envelope.getYmin(),
158
            envelope.getXmax(), envelope.getYmax());
159

    
160
        return r;
161
    }
162

    
163
    /**
164
     * Add a layer to the ServiceInformation @see ServiceInformationLayer.
165
     *
166
     * @param sil
167
     */
168
    public void addLayer(ServiceInformationLayer sil) {
169
        if (!layers.contains(sil)) {
170
            layers.add(sil);
171
        }
172
    }
173

    
174
    /**
175
     * Get a layer of the ServiceInformation.
176
     *
177
     * @param i Index of the vector of layers
178
     * @return @see ServiceInformationLayer
179
     */
180
    public ServiceInformationLayer getLayer(int i) {
181
        ServiceInformationLayer sil = (ServiceInformationLayer) this.layers.get(i);
182

    
183
        return sil;
184
    }
185

    
186
    /**
187
     * Get a layer of the ServiceInformation.
188
     *
189
     * @param i Index of the vector of layers
190
     * @return @see ServiceInformationLayer
191
     */
192
    public ServiceInformationLayer getLayerById(String name) {
193
        Iterator it = layers.iterator();
194
        ServiceInformationLayer sil = null;
195

    
196
        while (it.hasNext()) {
197
            sil = (ServiceInformationLayer) it.next();
198

    
199
            if (sil.getId().equals(name)) {
200
                return sil;
201
            }
202
        }
203

    
204
        return null;
205
    }
206

    
207
    /**
208
     * Get the type.
209
     * @return Returns the type.
210
     */
211
    public String getType() {
212
        return type;
213
    }
214

    
215
    /**
216
     * Set the type.
217
     * @param type The type to set.
218
     */
219
    public void setType(String type) {
220
        this.type = type;
221
    }
222

    
223
    /**
224
     * @return Returns the imagelimit_pixelcount.
225
     */
226
    public String getImagelimit_pixelcount() {
227
        return imagelimit_pixelcount;
228
    }
229

    
230
    /**
231
     * @param imagelimit_pixelcount The imagelimit_pixelcount to set.
232
     */
233
    public void setImagelimit_pixelcount(String imagelimit_pixelcount) {
234
        this.imagelimit_pixelcount = imagelimit_pixelcount;
235
    }
236

    
237
    /**
238
     * @return Returns the layers.
239
     */
240
    public Vector getLayers() {
241
        return layers;
242
    }
243

    
244
    /**
245
     * @param layers The layers to set.
246
     */
247
    public void setLayers(Vector layers) {
248
        this.layers = layers;
249
    }
250

    
251
    /**
252
     * @return Returns the locale.
253
     */
254
    public ServiceInformationLocale getLocale() {
255
        return locale;
256
    }
257

    
258
    /**
259
     * @param locale The locale to set.
260
     */
261
    public void setLocale(ServiceInformationLocale locale) {
262
        this.locale = locale;
263
    }
264

    
265
    /**
266
     * @return Returns the mapunits.
267
     */
268
    public String getMapunits() {
269
        return mapunits;
270
    }
271

    
272
    /**
273
     * @param mapunits The mapunits to set.
274
     */
275
    public void setMapunits(String mapunits) {
276
        this.mapunits = mapunits;
277
    }
278

    
279
    /**
280
     * @return Returns the separators.
281
     */
282
    public ServiceInformationSeparators getSeparators() {
283
        return separators;
284
    }
285

    
286
    /**
287
     * @param separators The separators to set.
288
     */
289
    public void setSeparators(ServiceInformationSeparators separators) {
290
        this.separators = separators;
291
    }
292

    
293
    /**
294
     * @return Returns the uifont.
295
     */
296
    public ServiceInformationUIFont getUifont() {
297
        return uifont;
298
    }
299

    
300
    /**
301
     * @param uifont The uifont to set.
302
     */
303
    public void setUifont(ServiceInformationUIFont uifont) {
304
        this.uifont = uifont;
305
    }
306

    
307
    /**
308
     * @return Returns the screen_dpi.
309
     */
310
    public int getScreen_dpi() {
311
        return screen_dpi;
312
    }
313

    
314
    /**
315
     *
316
     * @param screen_dpi the screen_dpi to set
317
     */
318
    public void setScreen_dpi(int screen_dpi) {
319
        this.screen_dpi = screen_dpi;
320
    }
321

    
322
    /**
323
     * @return Returns the featurecoordsys.
324
     */
325
    public String getFeaturecoordsys() {
326
        return featurecoordsys;
327
    }
328

    
329
    /**
330
     * @param featurecoordsys The featurecoordsys to set.
331
     */
332
    public void setFeaturecoordsys(String featurecoordsys) {
333
        this.featurecoordsys = featurecoordsys;
334
    }
335

    
336
    /**
337
     * @return Returns the dpiAssumed.
338
     */
339
    public boolean isDpiAssumed() {
340
        return dpiAssumed;
341
    }
342

    
343
    /**
344
     * @return Returns the srsAssumed.
345
     */
346
    public boolean isSrsAssumed() {
347
        return srsAssumed;
348
    }
349

    
350
    /**
351
     * @param dpiAssumed The dpiAssumed to set.
352
     */
353
    public void setDpiAssumed(boolean dpiAssumed) {
354
        this.dpiAssumed = dpiAssumed;
355
    }
356

    
357
    /**
358
     * @param srsAssumed The srsAssumed to set.
359
     */
360
    public void setSrsAssumed(boolean srsAssumed) {
361
        this.srsAssumed = srsAssumed;
362
    }
363

    
364
    /**
365
     * Inner class that represents the description of the ArcIms metadata. The
366
     * first part of the capabilities will return the service information from
367
     * the ArcIms, this class will hold this information.
368
     *
369
     * @author jcarrasco
370
     */
371
    public class ServiceInformationLocale implements Cloneable {
372
        private String language;
373
        private String country;
374

    
375
        public ServiceInformationLocale() {
376
            language = new String();
377
            country = new String();
378
        }
379

    
380
        public Object clone() {
381
            ServiceInformationLocale loc = new ServiceInformationLocale();
382
            loc.setCountry(this.country);
383
            loc.setLanguage(this.language);
384

    
385
            return loc;
386
        }
387

    
388
        /**
389
         * @return Returns the country.
390
         */
391
        public String getCountry() {
392
            return country;
393
        }
394

    
395
        /**
396
         * @param country The country to set.
397
         */
398
        public void setCountry(String country) {
399
            this.country = country;
400
        }
401

    
402
        /**
403
         * @return Returns the language.
404
         */
405
        public String getLanguage() {
406
            return language;
407
        }
408

    
409
        /**
410
         * @param language The language to set.
411
         */
412
        public void setLanguage(String language) {
413
            this.language = language;
414
        }
415
    }
416

    
417
    /**
418
     * Inner class that stores the UIFont information of a ServicInfo request.
419
     *
420
     * @author jcarrasco
421
     *
422
     */
423
    public class ServiceInformationUIFont implements Cloneable {
424
        private String name;
425
        private String color;
426
        private String size;
427
        private String style;
428

    
429
        public ServiceInformationUIFont() {
430
            name = new String();
431
            color = new String();
432
            size = new String();
433
            style = new String();
434
        }
435

    
436
        public Object clone() {
437
            ServiceInformationUIFont siuf = new ServiceInformationUIFont();
438
            siuf.setColor(this.color);
439
            siuf.setName(this.name);
440
            siuf.setSize(this.size);
441
            siuf.setStyle(this.style);
442

    
443
            return siuf;
444
        }
445

    
446
        /**
447
         * @return Returns the color.
448
         */
449
        public String getColor() {
450
            return color;
451
        }
452

    
453
        /**
454
         * @param color The color to set.
455
         */
456
        public void setColor(String color) {
457
            this.color = color;
458
        }
459

    
460
        /**
461
         * @return Returns the name.
462
         */
463
        public String getName() {
464
            return name;
465
        }
466

    
467
        /**
468
         * @param name The name to set.
469
         */
470
        public void setName(String name) {
471
            this.name = name;
472
        }
473

    
474
        /**
475
         * @return Returns the size.
476
         */
477
        public String getSize() {
478
            return size;
479
        }
480

    
481
        /**
482
         * @param size The size to set.
483
         */
484
        public void setSize(String size) {
485
            this.size = size;
486
        }
487

    
488
        /**
489
         * @return Returns the style.
490
         */
491
        public String getStyle() {
492
            return style;
493
        }
494

    
495
        /**
496
         * @param style The style to set.
497
         */
498
        public void setStyle(String style) {
499
            this.style = style;
500
        }
501
    }
502

    
503
    /**
504
     * Inner class that stores the Separators information of a ServicInfo
505
     * request.
506
     *
507
     * @author jcarrasco
508
     *
509
     */
510
    public class ServiceInformationSeparators implements Cloneable {
511
        /**
512
         * Coordinate separator is used to separate an x-coordinate from a y-coordinate.
513
         */
514
        private String cs;
515

    
516
        /**
517
         * Tuple separator is used to separate coordinate pairs and string lists.
518
         */
519
        private String ts;
520

    
521
        /**
522
         * Decimal separator is used to separate integer part from the decimal part
523
         * of a float/double number. It will be determined from the language/country
524
         * information of the service. The default value is '.'.
525
         */
526
        private char ds;
527

    
528
        public ServiceInformationSeparators() {
529
            cs = new String();
530
            ts = new String();
531
            ds = 'c';
532
        }
533

    
534
        public Object clone() {
535
            ServiceInformationSeparators sis = new ServiceInformationSeparators();
536
            sis.setCs(this.getCs());
537
            sis.setDs(this.getDs());
538
            sis.setTs(this.getTs());
539

    
540
            return sis;
541
        }
542

    
543
        /**
544
         * @return Returns the Coordinate Separator.
545
         */
546
        public String getCs() {
547
            return cs;
548
        }
549

    
550
        /**
551
         * @param cs The cs to set.
552
         */
553
        public void setCs(String cs) {
554
            this.cs = cs;
555
        }
556

    
557
        /**
558
         * @return Returns the Decimal Separator.
559
         */
560
        public char getDs() {
561
            return ds;
562
        }
563

    
564
        /**
565
         * @param ds The ds to set.
566
         */
567
        public void setDs(char ds) {
568
            this.ds = ds;
569
        }
570

    
571
        /**
572
         * @return Returns the Tuple Separator.
573
         */
574
        public String getTs() {
575
            return ts;
576
        }
577

    
578
        /**
579
         * @param ts The ts to set.
580
         */
581
        public void setTs(String ts) {
582
            this.ts = ts;
583
        }
584
    }
585
}