Statistics
| Revision:

root / trunk / extensions / extWCS / src / com / iver / cit / gvsig / gui / wcs / WCSWizardData.java @ 4356

History | View | Annotate | Download (6.95 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. 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
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.gui.wcs;
42

    
43
import java.awt.Component;
44
import java.io.IOException;
45
import java.net.ConnectException;
46
import java.net.URL;
47
import java.util.ArrayList;
48
import java.util.Iterator;
49
import java.util.Vector;
50

    
51
import javax.swing.JOptionPane;
52

    
53
import com.iver.andami.PluginServices;
54
import com.iver.cit.gvsig.fmap.DriverException;
55
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver;
56
import com.iver.cit.gvsig.fmap.layers.WCSLayer;
57
import com.iver.cit.gvsig.gui.wizards.WizardData;
58

    
59

    
60

    
61
/**
62
 * This class holds the WCSWizard's info
63
 * 
64
 * Contiene la informaci?n del asistente WCS
65
 * 
66
 * @author jaume - jaume.dominguez@iver.es
67
 *
68
 */
69

    
70
public class WCSWizardData extends WizardData{
71
    private String title;
72
    private String Abstract;
73
    private FMapWCSDriver wcs;
74
        private String theAbstract;
75
        private WCSLayer[] coverageList;
76

    
77
    
78
    public void setHost(URL host) throws DriverException{
79
        wcs = new FMapWCSDriver();
80
              try {
81
                        wcs.createClient(host);
82
                
83
        // Send a getCapabilities request;
84
                wcs.connect();
85
        if (!wcs.isConnected())
86
            throw new DriverException(PluginServices.getText(this, "cant_connect") + host.toString());
87
        } catch (ConnectException e) {
88
                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this,"server_timeout"));
89
                        e.printStackTrace();
90
                        return;
91
                } catch (IOException e) {
92
                        JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "cant_connect"));
93
                        e.printStackTrace();
94
                        return;
95
                }
96
        if (wcs.getDescription()  != null)
97
            theAbstract = wcs.getDescription();
98
        
99
        coverageList = wcs.getLayerList();
100
    }
101
    
102
    /**
103
     * The server description.
104
     * 
105
     * La descripci?n del servidor
106
     * @return String
107
     */
108
    public String getAbstract() {
109
            if (Abstract == null) return "None";
110
        return Abstract;
111
    }
112
    
113
    /**
114
     * An ArrayList with the coverage formats.
115
     * 
116
     * Los formatos de la cobertura
117
     *
118
     * @return
119
     */ 
120
    public ArrayList getCoverageFormatos(String nomCobertura) {
121
        return getLayer(nomCobertura).getFormats();
122
    }
123

    
124
    /**
125
     * Finds the coverage within the coverage list
126
     * 
127
     * Busca la cobertura en la lista de coberturas
128
     *
129
     * @return CoverageInfo
130
     */
131
    public WCSLayer getLayer(String name) {
132
            for (int i = 0; i < coverageList.length; i++) {
133
                        if (coverageList[i].getName().equals(name))
134
                                return coverageList[i];
135
                }
136
            return null;
137
    }
138
    
139
    /**
140
     * Returns an ArrayList containing the supported SRS of the coverage specified 
141
     * by name.
142
     * 
143
     * Devuelve una lista de SRSs soportados por la cobertura "name".
144
     * 
145
     * @param name
146
     * @return ArrayList
147
     */
148
    public ArrayList getCoverageSRSs(String name){
149
            return getLayer(name).getSRSs();
150
    }
151
    /**
152
     * Server's title (not used in gvSIG)
153
     * 
154
     * T?tulo del servidor (no se usa en gvSIG)
155
     *
156
     * @return
157
     */
158
    public String getTitle() {
159
            if (title == null) return "None";
160
        return title;
161
    }
162

    
163
    /**
164
     * Equivalent to the setDescription method
165
     * 
166
     * Equivalente a setDescription
167
     *
168
     * @param string
169
     */
170
    public void setAbstract(String string) {
171
        Abstract = string;
172
    }
173

    
174

    
175
//    /**
176
//     * Adds a coverage to the coverages list
177
//     * 
178
//     * A?ande una cobertura a la lista de coberturas
179
//     *
180
//     * @param CoverageInfo
181
//     */
182
//    public void setCoverage(CoverageInfo info) {
183
//        coverages.add(info);
184
//    }
185

    
186
    /**
187
     * Sets the server's title (not used in gvSIG)
188
     * 
189
     * Establece el t?tulo del servidor (no se usa en gvSIG)
190
     *
191
     * @param string
192
     */
193
    public void setTitle(String string) {
194
        title = string;
195
    }
196
    
197
    /**
198
     * Sets the server's description.
199
     * 
200
     * Establece la descripci?n del servidor.
201
     * @param String
202
     */
203
    public void setDescription(String s) {
204
            setAbstract(s);
205
    }
206
    
207
    /**
208
     * Returns the server's descrition
209
     * 
210
     * Recupera la descripci?n del servidor
211
     * @return "None" if the server doesn't specify any description
212
     */
213
    public String getDescription(){
214
            if (getAbstract() == null) return "None";
215
            return getAbstract();
216
    }
217

    
218
        public WCSLayer[] getCoverageList() {
219
                return coverageList;
220
        }
221
        
222
        public FMapWCSDriver getDriver() {
223
                return wcs;
224
        }
225
        
226
//        /**
227
//         * Sets the coverage names
228
//         * 
229
//         * @param String[] coverageNames
230
//         */
231
//        public void setCoverageNames(String[] coverageNames) {
232
//                this.coverageNames = coverageNames;
233
//        }
234
//        
235
//        /** 
236
//         * Sets the coverages list from an ArrayList
237
//         * 
238
//         * @param coverages
239
//         */
240
//        public void setCoveragesList(ArrayList coverages){
241
//                this.coverages = coverages;
242
//        }
243
//
244
//        /**
245
//         * Returns an ArrayList containing the positions for the TIME
246
//         * 
247
//         * Devuelve las posiciones del tiempo
248
//         * @param string
249
//         * @return
250
//         */
251
//        public ArrayList getCoverageTimes(String name) {
252
//                   CoverageInfo ci = getCoverageInfo(name);
253
//                   if (ci.getTimes()== null) return new ArrayList();
254
//            return ci.getTimes();
255
//         }
256
//        
257
//        /**
258
//         * Returns an ArrayList containing a list of Parametro with the parameters list
259
//         * and its possible values of a coverage specified by its name.
260
//         * 
261
//         * Devuelve la lista de par?metros (y sus posibles valores) de la cobertura y sus
262
//         * posibles valores de una cobertura especificada por su nombre
263
//         * 
264
//         * @return ArrayList
265
//         */
266
//                
267
//        public ArrayList getCoverageParameters(String name){
268
//                CoverageInfo ci = getCoverageInfo(name);
269
//                return ci.getParametros();
270
//        }
271
//
272
//        /**
273
//         * Gets the coverage label.
274
//         */
275
//        public String getCoverageLabel(String name) {
276
//                CoverageInfo ci = getCoverageInfo(name);
277
//                return ci.getLabel();
278
//        }
279

    
280

    
281
}