Revision 2765

View differences:

tags/Root_gvSIG_WCS04/extensions/extWCS/src4/com/iver/cit/gvsig/gui/WCSDataSourceAdapter.java
1
/*
2
 * Created on 09-sep-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package com.iver.cit.gvsig.gui;
48

  
49
import java.awt.geom.Rectangle2D;
50
import java.io.IOException;
51
import java.net.URL;
52
import java.util.ArrayList;
53
import java.util.Iterator;
54

  
55
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver;
56
import com.iver.cit.gvsig.gui.wcs.CoverageInfo;
57
import com.iver.cit.gvsig.gui.wcs.Parametro;
58
import com.iver.cit.gvsig.gui.wcs.WCSWizardData;
59
import com.iver.cit.gvsig.gui.wcs.WCSWizardDataSource;
60

  
61
import es.uji.lsi.wcs.XmlWcsParsing.CoverageOffering;
62
import es.uji.lsi.wcs.XmlWcsParsing.AxisDescription;
63

  
64

  
65
/**
66
 * Adapta las capa wms de Fmap a los datasource del WCSWizard
67
 * Es muy recomendable disponer de la documentaci?n WCS de OGC
68
 * para entender el juego de objetos utilizado.
69
 *
70
 * @author Jaume Dom?nguez Faus - jaume.dominguez@iver.es
71
 */
72
public class WCSDataSourceAdapter implements WCSWizardDataSource {
73
    private FMapWCSDriver client;
74
    WCSWizardData data = null;
75
    
76
	/* (non-Javadoc)
77
	 * @see com.iver.cit.gvsig.gui.wms.WizardDataSource#detalles(java.net.URL)
78
	 */
79
	public WCSWizardData detalles(URL host) {
80
		System.out.println("WCS>>> creant el client per al servidor '"+host.toString()+"'");
81
		client = new FMapWCSDriver();
82
		client.setHost(host.toString());
83
		
84
		try {
85
			client.connect();  // <-- GetCapabilities + DescribeCoverage
86
			System.out.println("WCS>>> connectat");
87
			
88
			
89
		} catch (IOException e) {
90
			// TODO Veure qu? es fa amb les excepcions
91
			System.err.println("Exception al intentar connectar WCS");
92
			e.printStackTrace();
93
		}
94
		
95
		
96
		
97
		data = new WCSWizardData();
98
		
99
		data.setCoverageNames(client.getCoverageNames());
100
		data.setTitle(client.getLabel());
101
		data.setDescription(client.getDescription());
102
		
103
		rellena();
104
		return data;
105
	}
106

  
107
	/**
108
	 * 
109
	 */
110
	private void rellena() {
111
		String[] coberturas = client.getCoverageNames();
112
		ArrayList listaCoberturas = new ArrayList();
113
		for (int i=0; i<client.getNumOfCoverages(); i++){
114
			CoverageInfo nueva_cobertura = new CoverageInfo();
115
			nueva_cobertura.name = coberturas[i];
116
			
117
			CoverageOffering co = client.getCoverageDetails(coberturas[i]);
118
			ArrayList SRSs;
119
			
120
			// Si el servidor da algun CRS en RequestResponse se usar? esta respuesta
121
			// en caso contrario, se usar? el de la cobertura en CoverageOfferingBrief
122
			if (!co.getSupportedCRSs().getRequestResponseCRSs().isEmpty())
123
				SRSs = co.getSupportedCRSs().getRequestResponseCRSs();
124
			else {
125
				SRSs = new ArrayList();
126
				SRSs.add(co.getCoverageOfferingBrief().getLonLatEnvelope().getSRS());
127
			}
128
			
129

  
130
			nueva_cobertura.label = co.getCoverageOfferingBrief().getLabel();
131
			nueva_cobertura.ll_envelope = co.getCoverageOfferingBrief().getLonLatEnvelope();
132
			nueva_cobertura.text = co.getCoverageOfferingBrief().getDescription();
133
			nueva_cobertura.setSRSList(SRSs);
134
			nueva_cobertura.setFormats(co.getSupportedFormats().getFormats());
135
			nueva_cobertura.setTiempos(co.getDomainSet().getTemporalDomain().getGMLTimePositionList());
136
			
137
			rellenaParametros(nueva_cobertura, co);			
138
			
139
			listaCoberturas.add(nueva_cobertura);
140
		}
141
		data.setCoveragesList(listaCoberturas);
142
	}
143

  
144
	/**
145
	 * @param nueva_cobertura
146
	 */
147
	private void rellenaParametros(CoverageInfo nueva_cobertura, CoverageOffering co) {
148
		ArrayList lista_descripciones = co.getRangeSet().getAxisDescriptionList();
149
		if (lista_descripciones!= null){
150
			Iterator it = lista_descripciones.iterator();
151
			while (it.hasNext()){
152
				AxisDescription ad = ((AxisDescription) it.next());
153
				Parametro p = new Parametro();
154
				p.setName(ad.getName());
155
				p.setType(ad.getValuesType());
156
				if (p.getType().equals("singleValue")){
157
						p.setLista_valores_simples(ad.getSingleValues());
158
				}
159
				nueva_cobertura.getParametros().add(p);
160
			}
161
		} else lista_descripciones = new ArrayList();
162
	}
163

  
164
	/* (non-Javadoc)
165
	 * @see com.iver.cit.gvsig.gui.wms.WizardDataSource#getBoundingBox(java.lang.String[], java.lang.String)
166
	 */
167
	public Rectangle2D getBoundingBox(String[] layerName, String srs) {
168
		// TODO Auto-generated method stub
169
		return null;
170
	}
171

  
172
}
0 173

  
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/com/iver/cit/gvsig/gui/wcs/FormatListModel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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 javax.swing.AbstractListModel;
44

  
45

  
46
/**
47
 * DOCUMENT ME!
48
 *
49
 * @author Fernando Gonz?lez Cort?s
50
 */
51
public class FormatListModel extends AbstractListModel {
52
    String[] formatos;
53

  
54
    /**
55
     * Creates a new FormatListModel object.
56
     *
57
     * @param f DOCUMENT ME!
58
     */
59
    public FormatListModel(String[] f) {
60
        formatos = f;
61
    }
62

  
63
    /**
64
     * @see javax.swing.ListModel#getSize()
65
     */
66
    public int getSize() {
67
        return formatos.length;
68
    }
69

  
70
    /**
71
     * @see javax.swing.ListModel#getElementAt(int)
72
     */
73
    public Object getElementAt(int index) {
74
        return formatos[index];
75
    }
76
}
0 77

  
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/com/iver/cit/gvsig/gui/wcs/WizardListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
/**
44
 * DOCUMENT ME!
45
 *
46
 * @author $author$
47
 */
48
public interface WizardListener {
49

  
50
	/**
51
	 * Invocado cuando el wizard puede ser finalizado porque se
52
	 * ha rellenado toda la informaci?n necesaria
53
	 */
54
	public void wizardStateChanged(boolean finishable);
55
	
56
	/**
57
	 * Si se produce alg?n error
58
	 *
59
	 * @param e Excepci?n que se ha producido
60
	 */
61
	public void error(Exception e);
62
}
0 63

  
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/com/iver/cit/gvsig/gui/wcs/CoverageInfo.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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.util.ArrayList;
44
import java.util.Iterator;
45

  
46
import com.iver.cit.gvsig.gui.wms.LayerInfo;
47

  
48
import es.uji.lsi.wcs.XmlWcsParsing.LonLatEnvelope;
49

  
50

  
51
/**
52
 * Clase que mantiene la informaci?n de la cobertura en el asistente WCS
53
 *  
54
 * @author jaume - jaume.dominguez@iver.es
55
 *  
56
 */
57
public class CoverageInfo extends LayerInfo {
58
    public String text;
59
    public String name;
60
    
61
    // <Jaume>
62
    public String metadataLink;
63
    public String label;
64
    public LonLatEnvelope ll_envelope;
65
    public String[] keywords;
66
    private ArrayList formats;
67
    private ArrayList srs = new ArrayList();
68
    private ArrayList tiempos;
69
    private ArrayList parametros = new ArrayList();;
70
    // </Jaume>
71
    public boolean queryable;
72
	private boolean hayParametros = false;
73
    /**
74
     * DOCUMENT ME!
75
     *
76
     * @param srs DOCUMENT ME!
77
     */
78
    public void addSRS(String srs) {
79
    	String[] srsArray = srs.split(" ");
80
    	for (int i = 0; i < srsArray.length; i++){
81
			this.srs.add(srsArray[i]);
82
    	}
83
    }
84
    
85
    public void setSRSList(ArrayList srs){
86
    	this.srs = srs;
87
    }
88

  
89
    /**
90
     * DOCUMENT ME!
91
     *
92
     * @return DOCUMENT ME!
93
     */
94
    public ArrayList getSRSs() {
95
		ArrayList ret = new ArrayList();
96
		ret.addAll(srs);
97

  
98
        if (padre != null) {
99
            ret.addAll(padre.getSRSs());
100
        }
101

  
102
        return ret;
103
    }
104

  
105
    /**
106
     * DOCUMENT ME!
107
     *
108
     * @return DOCUMENT ME!
109
     */
110
    public String toString() {
111
        return text;
112
    }
113

  
114
    /* (non-Javadoc)
115
     * @see java.lang.Object#equals(java.lang.Object)
116
     */
117
    public boolean equals(Object obj) {
118
    	try{
119
	        CoverageInfo objeto = (CoverageInfo) obj;
120
			return this.name.equals(objeto.name);
121
		}catch(ClassCastException e){
122
			e.printStackTrace();
123
			return false;
124
		}catch (NullPointerException e) {
125
			return false;
126
		}
127
    }
128

  
129
	/**
130
	 * Devuelve la lista de formatos de la cobertura
131
	 * @return
132
	 */
133
	public ArrayList getFormats() {
134
		return formats;
135
	}
136
	
137
	/**
138
	 * Establece la lista de formatos para la cobertura
139
	 * @param formats
140
	 */
141
	public void setFormats(ArrayList formats){
142
		this.formats = formats;	
143
	}
144

  
145
	/**
146
	 * Devuelve la lista de posiciones para el tiempo de la cobertura
147
	 * 
148
	 * @return ArrayList
149
	 */
150
	public ArrayList getTimes() {
151
		return tiempos;
152
	}
153
	
154
	/**
155
	 * Establece la lista de posiciones para el tiempo de la cobertura
156
	 * 
157
	 * @return 
158
	 */
159
	public void setTiempos(ArrayList tiempos){
160
		// Como la cobertura puede no tener posiciones para el tiempo
161
		// aseguramos que no tengamos errores de puntero nulo
162
		if (tiempos == null) this.tiempos = new ArrayList();
163
		else this.tiempos = tiempos;
164
	}
165

  
166
	/**
167
	 * Establece la lista de parametros (y sus posibles valores) de la cobertura
168
	 * @param parametros
169
	 */
170
	public void setParametros(ArrayList parametros){
171
		// Como la cobertura puede no tener par?metros nos aseguramos de que
172
		// no tengamos errores de puntero nulo creando un ArrayList vac?o
173
		if (parametros == null) {
174
			hayParametros = false;
175
			this.parametros = new ArrayList();
176
		}
177
		else{
178
			hayParametros = true;
179
			this.parametros = parametros;
180
		}
181
	}
182
	/**
183
	 * Devuelve la lista de par?metros (y sus posibles valores) de la cobertura
184
	 * @return
185
	 */
186
	public ArrayList getParametros() {
187
		return parametros;
188
	}
189
	
190
	public Parametro getParametro(String nombreParametro){
191
		Parametro p;
192
		Iterator it = parametros.iterator();
193
		while (it.hasNext()){
194
			p = (Parametro) it.next();
195
			if (p.getName().equals(nombreParametro)) 
196
				return p;
197
		}
198
		return null;
199
		
200
	}
201

  
202
	/**
203
	 * @return
204
	 */
205
	public boolean hasParameter() {
206
		return hayParametros;
207
	}
208
}
0 209

  
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/com/iver/cit/gvsig/gui/wcs/WCSWizardData.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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.util.ArrayList;
44
import java.util.Iterator;
45

  
46
import com.iver.cit.gvsig.gui.wms.WizardData;
47

  
48
/**
49
 * Contiene la informaci?n del asistente WCS
50
 * 
51
 * @author jaume - jaume.dominguez@iver.es
52
 *
53
 */
54

  
55
public class WCSWizardData extends WizardData{
56
    private String title;
57
    private String Abstract;
58
    private ArrayList coverages;
59
    private String[] coverageNames;
60

  
61
    /**
62
     * DOCUMENT ME!
63
     *
64
     * @return
65
     */
66
    public String getAbstract() {
67
        return Abstract;
68
    }
69
    
70
    /**
71
     * DOCUMENT ME!
72
     *
73
     * @return
74
     */
75
    public ArrayList getCoverageFormatos(String nomCobertura) {
76
        return getCoverageInfo(nomCobertura).getFormats();
77
    }
78

  
79
    /**
80
     * DOCUMENT ME!
81
     *
82
     * @return
83
     */
84
    public CoverageInfo getCoverageInfo(String name) {
85
    	Iterator i=coverages.iterator();
86
    	while (i.hasNext()){
87
    		CoverageInfo ci = (CoverageInfo) i.next();
88
    		if (ci.name.equals(name)) return ci;  
89
    	}
90
        return null;
91
    }
92
    
93
    /**
94
     * Devuelve una lista de SRSs soportados por la cobertura "name".
95
     * 
96
     * @param name
97
     * @return ArrayList
98
     */
99
    public ArrayList getCoverageSRSs(String name){
100
    	CoverageInfo ci = getCoverageInfo(name);
101
    	return ci.getSRSs();
102
    }
103
    /**
104
     * DOCUMENT ME!
105
     *
106
     * @return
107
     */
108
    public String getTitle() {
109
        return title;
110
    }
111

  
112
    /**
113
     * DOCUMENT ME!
114
     *
115
     * @param string
116
     */
117
    public void setAbstract(String string) {
118
        Abstract = string;
119
    }
120

  
121
    /**
122
     * DOCUMENT ME!
123
     *
124
     * @param strings
125
     */
126
//    public void setFormats(String[] strings) {
127
//        formats = strings;
128
//    }
129

  
130
    /**
131
     * DOCUMENT ME!
132
     *
133
     * @param info
134
     */
135
    public void setCoverage(CoverageInfo info) {
136
        coverages.add(info);
137
    }
138

  
139
    /**
140
     * DOCUMENT ME!
141
     *
142
     * @param string
143
     */
144
    public void setTitle(String string) {
145
        title = string;
146
    }
147
    
148
    public void setDescription(String s) {
149
    	setAbstract(s);
150
    }
151
    
152
    public String getDescription(){
153
    	return getAbstract();
154
    }
155

  
156
	/**
157
	 * @param coverageNames
158
	 */
159
	public void setCoverageNames(String[] coverageNames) {
160
		this.coverageNames = coverageNames;
161
	}
162
	
163
	/** Devuelve array de strings con los nombres de las coberturas
164
	 * 
165
	 * @return String
166
	 */
167
	public String[] getCoverageNames() {
168
		return this.coverageNames;
169
	}
170
	
171
	/** 
172
	 * Establece la lista de coberturas.
173
	 * 
174
	 * @param coverages
175
	 */
176
	public void setCoveragesList(ArrayList coverages){
177
		this.coverages = coverages;
178
	}
179

  
180
	/**
181
	 * @param string
182
	 * @return
183
	 */
184
	public ArrayList getCoverageTimes(String name) {
185
	   	CoverageInfo ci = getCoverageInfo(name);
186
    	return ci.getTimes();
187
 	}
188
	
189
	public ArrayList getCoverageParameters(String name){
190
		CoverageInfo ci = getCoverageInfo(name);
191
		return ci.getParametros();
192
	}
193
	
194
}
0 195

  
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/com/iver/cit/gvsig/gui/wcs/CoverageListModel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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.util.ArrayList;
44
import java.util.Collection;
45

  
46
import javax.swing.AbstractListModel;
47

  
48

  
49
/**
50
 * DOCUMENT ME!
51
 *
52
 * @author Jaume - jaume.dominguez@iver.es
53
 */
54
public class CoverageListModel extends AbstractListModel {
55
    private ArrayList nodos = new ArrayList();
56

  
57
    /**
58
     * DOCUMENT ME!
59
     *
60
     * @param elemento DOCUMENT ME!
61
     *
62
     * @return true si se ha insertado el elemento, false en caso contrario.
63
     */
64
    public boolean addElement(CoverageInfo elemento) {
65
        if (elemento == null) {
66
            return false;
67
        }
68

  
69
        for (int i = 0; i < nodos.size(); i++) {
70
            if (((CoverageInfo) nodos.get(i)).equals(elemento)) {
71
                return false;
72
            }
73
        }
74

  
75
        nodos.add(elemento);
76

  
77
        fireContentsChanged(this, nodos.size() - 1, nodos.size() - 1);
78

  
79
        return true;
80
    }
81

  
82
	public void clear(){
83
		nodos.clear();
84
		fireContentsChanged(this, 0, 0);
85
	}
86

  
87
    /**
88
     * DOCUMENT ME!
89
     *
90
     * @param index DOCUMENT ME!
91
     *
92
     * @return DOCUMENT ME!
93
     */
94
    public CoverageInfo delElement(int index) {
95
        CoverageInfo ret = (CoverageInfo) nodos.remove(index);
96
        this.fireContentsChanged(this, index, index);
97

  
98
        return ret;
99
    }
100

  
101
    /**
102
     * DOCUMENT ME!
103
     *
104
     * @param c DOCUMENT ME!
105
     */
106
    public void delElements(Collection c) {
107
        nodos.removeAll(c);
108
        this.fireContentsChanged(this, 0, nodos.size());
109
    }
110

  
111
    /**
112
     * @see javax.swing.ListModel#getSize()
113
     */
114
    public int getSize() {
115
        return nodos.size();
116
    }
117

  
118
    /**
119
     * @see javax.swing.ListModel#getElementAt(int)
120
     */
121
    public Object getElementAt(int index) {
122
        return ((CoverageInfo) nodos.get(index)).text;
123
    }
124

  
125
    /**
126
     * DOCUMENT ME!
127
     *
128
     * @return DOCUMENT ME!
129
     */
130
    public CoverageInfo[] getElements() {
131
        return (CoverageInfo[]) nodos.toArray(new CoverageInfo[0]);
132
    }
133

  
134
    /**
135
     * DOCUMENT ME!
136
     *
137
     * @param index DOCUMENT ME!
138
     *
139
     * @return DOCUMENT ME!
140
     */
141
    public CoverageInfo getLayerInfo(int index) {
142
        return (CoverageInfo) nodos.get(index);
143
    }
144
}
0 145

  
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/com/iver/cit/gvsig/gui/wcs/WCSWizardDataSource.java
1
/*
2
 * Created on 09-sep-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package com.iver.cit.gvsig.gui.wcs;
48

  
49
import java.awt.geom.Rectangle2D;
50
import java.io.IOException;
51
import java.net.URL;
52

  
53
import org.exolab.castor.xml.ValidationException;
54

  
55
import com.iver.wmsclient.UnsupportedVersionException;
56

  
57
/**
58
 * @author jaume - jaume.dominguez@iver.es
59
 *
60
 * Interface WCSWizardDataSource 
61
 */
62
public interface WCSWizardDataSource {
63
	public WCSWizardData detalles(URL host)throws IllegalStateException, ValidationException, 
64
	UnsupportedVersionException, IOException ;
65
	
66
	public Rectangle2D getBoundingBox(String[] layerName, String srs);
67

  
68
}
0 69

  
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/com/iver/cit/gvsig/gui/wcs/Parametro.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2004 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.util.ArrayList;
44
import java.util.Iterator;
45

  
46
import es.uji.lsi.wcs.XmlWcsParsing.SingleValue;
47

  
48
/**
49
 * @author jaume - jaume.dominguez@iver.es
50
 *
51
 */
52
public class Parametro {
53
	private String name;
54
	private ArrayList lista_valores_simples;
55
	private String type;
56
	// para valores cont?nuos?
57
	
58
	
59
	/**
60
	 * @return Returns the lista_valores_simples.
61
	 */
62
	public ArrayList getLista_valores_simples() {
63
		return this.lista_valores_simples;
64
	}
65
	/**
66
	 * @param lista_valores_simples The lista_valores_simples to set.
67
	 */
68
	public void setLista_valores_simples(ArrayList lista_valores_simples) {
69
		ArrayList valores = new ArrayList();
70
		Iterator it = lista_valores_simples.iterator();
71
		while (it.hasNext()){
72
			SingleValue sv = (SingleValue) it.next();
73
			valores.add(sv.getValue());
74
		}
75
		this.lista_valores_simples = valores;
76
	}
77
	/**
78
	 * @return Returns the name.
79
	 */
80
	public String getName() {
81
		return name;
82
	}
83
	/**
84
	 * @param name The name to set.
85
	 */
86
	public void setName(String name) {
87
		this.name = name;
88
	}
89
	/**
90
	 * @return Returns the type.
91
	 */
92
	public String getType() {
93
		return type;
94
	}
95
	/**
96
	 * @param type The type to set.
97
	 */
98
	public void setType(String type) {
99
		this.type = type;
100
	}
101
}
0 102

  
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/com/iver/cit/gvsig/gui/wcs/CoverageTreeModel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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 javax.swing.event.TreeModelListener;
44
import javax.swing.tree.TreeModel;
45
import javax.swing.tree.TreePath;
46

  
47

  
48

  
49

  
50
public class CoverageTreeModel implements TreeModel {
51

  
52
	CoverageInfo root;
53

  
54
	public CoverageTreeModel(CoverageInfo root){
55
		this.root = root;
56
	}
57

  
58
	/* (non-Javadoc)
59
	 * @see javax.swing.tree.TreeModel#getRoot()
60
	 */
61
	public Object getRoot() {
62
		return root;
63
	}
64

  
65
	/* (non-Javadoc)
66
	 * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
67
	 */
68
	public int getChildCount(Object parent) {
69
		return ((CoverageInfo)parent).hijos.size();
70
	}
71

  
72
	/* (non-Javadoc)
73
	 * @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
74
	 */
75
	public boolean isLeaf(Object node) {
76
		return ((CoverageInfo)node).hijos.size() == 0;
77
	}
78

  
79
	/* (non-Javadoc)
80
	 * @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener)
81
	 */
82
	public void addTreeModelListener(TreeModelListener l) {
83
	}
84

  
85
	/* (non-Javadoc)
86
	 * @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener)
87
	 */
88
	public void removeTreeModelListener(TreeModelListener l) {
89
	}
90

  
91
	/* (non-Javadoc)
92
	 * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
93
	 */
94
	public Object getChild(Object parent, int index) {
95
		return ((CoverageInfo)parent).hijos.get(index);
96
	}
97

  
98
	/* (non-Javadoc)
99
	 * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object, java.lang.Object)
100
	 */
101
	public int getIndexOfChild(Object parent, Object child) {
102
		CoverageInfo pare = (CoverageInfo) parent;
103
		for (int i = 0; i < pare.hijos.size(); i++)
104
			if (child == pare.hijos.get(i)) return i;
105
		return -1;
106
	}
107

  
108
	/* (non-Javadoc)
109
	 * @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath, java.lang.Object)
110
	 */
111
	public void valueForPathChanged(TreePath path, Object newValue) {
112
	}
113
}
0 114

  
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/com/iver/cit/gvsig/gui/wcs/WCSWizard.java
1
/*
2
 * Created on 23-abr-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package com.iver.cit.gvsig.gui.wcs;
48

  
49
import java.awt.geom.Rectangle2D;
50
import java.net.MalformedURLException;
51
import java.net.URL;
52
import java.util.ArrayList;
53
import java.util.HashSet;
54
import java.util.Hashtable;
55
import java.util.Iterator;
56
import java.util.TreeSet;
57

  
58
import javax.swing.DefaultComboBoxModel;
59
import javax.swing.DefaultListModel;
60
import javax.swing.JList;
61
import javax.swing.JOptionPane;
62

  
63
import org.apache.log4j.Logger;
64

  
65
import com.iver.andami.PluginServices;
66
import com.iver.cit.gvsig.fmap.layers.FLayer;
67
import com.iver.cit.gvsig.fmap.layers.FLyrWCS;
68
import com.iver.cit.gvsig.gui.WCSDataSourceAdapter;
69
import com.iver.cit.gvsig.gui.WizardPanel;
70
import com.iver.cit.gvsig.gui.Panels.WCSParamsPanel;
71
import com.iver.utiles.NotExistInXMLEntity;
72
import com.iver.utiles.XMLEntity;
73
import com.iver.utiles.swing.JComboBox;
74

  
75
/**
76
 * DOCUMENT ME!
77
 * 
78
 * @author Jaume Dom?nguez Faus
79
 */
80
public class WCSWizard extends WizardPanel {
81
	private static Logger logger = Logger.getLogger(WCSWizard.class.getName());
82
	private int page = 0;
83
	private boolean conectado = false;
84
	private javax.swing.JPanel jContentPane = null;
85
	private JComboBox cmbHost = null;
86
	private javax.swing.JButton btnDetalles = null;
87
	private javax.swing.JPanel jPanel = null;
88
	private javax.swing.JLabel jLabel1 = null;
89
	private javax.swing.JLabel lblTitle = null;
90
	private javax.swing.JScrollPane jScrollPane = null;
91
	private javax.swing.JTextArea txtAbstract = null;
92
	private javax.swing.JPanel panelPage1 = null;
93
	private javax.swing.JPanel panelPage2 = null;
94
	private CoverageListModel selectedLayersModel = new CoverageListModel();
95
	private javax.swing.JButton btnSiguiente = null;
96
	private javax.swing.JButton btnAnterior = null;
97
	private javax.swing.JPanel jPanel1 = null;
98
	private WizardListenerSupport listenerSupport = new WizardListenerSupport();
99
	private WCSWizardDataSource dataSource;
100
	private WCSParamsPanel wcsParamsTabbedPane = null;
101
	private WCSWizardData data = null;
102
	
103
	/**
104
	 * This is the default constructor
105
	 */
106
	public WCSWizard() {
107
		super();
108
		initialize();
109
	}
110

  
111
	/**
112
	 * This method initializes this
113
	 */
114
	private void initialize() {
115
		setTabName("WCS");
116
		this.setSize(510, 311);
117
		this.setLayout(null);
118
		this.setPreferredSize(new java.awt.Dimension(750, 320));
119
		this.setVisible(true);
120
		this.add(getPanelPage1(), null);
121
		this.add(getPanelPage2(), null);
122
		this.add(getBtnAnterior(), null);
123
		this.add(getBtnSiguiente(), null);
124
		activarVisualizarBotones();
125
	}
126

  
127
	/**
128
	 * DOCUMENT ME!
129
	 */
130
	private void actualizarSRSQueJoNoGaste() {
131
		CoverageInfo[] layers = ((CoverageListModel) wcsParamsTabbedPane
132
				.getLstSelectedCoverages().getModel()).getElements();
133

  
134
		if (layers.length == 0) {
135
			wcsParamsTabbedPane.getLstSelectedCoverages().setModel(
136
					new DefaultListModel());
137
		} else {
138
			TreeSet srsSet = new TreeSet();
139
			srsSet.addAll(layers[0].getSRSs());
140

  
141
			for (int i = 1; i < layers.length; i++) {
142
				HashSet nuevo = new HashSet(layers[i].getSRSs());
143
				Iterator it = srsSet.iterator();
144

  
145
				while (it.hasNext()) {
146
					String srs = (String) it.next();
147

  
148
					if (!nuevo.contains(srs)) {
149
						srsSet.remove(srs);
150
					}
151
				}
152
			}
153

  
154
			DefaultListModel model = new DefaultListModel();
155
			String[] array = (String[]) srsSet.toArray(new String[0]);
156

  
157
			for (int i = 0; i < array.length; i++) {
158
				model.addElement(array[i]);
159
			}
160

  
161
			wcsParamsTabbedPane.getLstCRSs().setModel(model);
162
		}
163
	}
164

  
165
	/**
166
	 *  
167
	 */
168
	protected void addCoverage() {
169
		ArrayList coberturas_anteriores, coverages = new ArrayList();
170
		
171
		
172
		boolean es_posible_cruzar_capas;
173
		for (int i = 0; i < wcsParamsTabbedPane.getLstSelectedCoverages()
174
				.getModel().getSize(); i++) {
175
			coverages.add(wcsParamsTabbedPane.getLstSelectedCoverages()
176
					.getModel().getElementAt(i));
177
		}
178
		// guardamos las coberturas anteriores a la adici?n de las nuevas para
179
		// deshacer los cambios en caso de que no puedan cruzarse.
180
		coberturas_anteriores = (ArrayList) coverages.clone();
181
		
182
		Object[] obj = wcsParamsTabbedPane.getLstCoverages()
183
				.getSelectedValues();
184
		for (int i = 0; i < obj.length; i++) {
185
			if (!coverages.contains(obj[i]))
186
				coverages.add(obj[i]);
187
		}
188
		wcsParamsTabbedPane.getLstCoverages().clearSelection();
189
		// coverages es un ArrayList que contiene las coberturas de la lista de
190
		// coberturas seleccionadas, es decir... las actualmente seleccionadas
191

  
192
		es_posible_cruzar_capas = actualizarSRSs(coverages.toArray());
193
		if (es_posible_cruzar_capas)
194
			es_posible_cruzar_capas = actualizarFormatos(coverages.toArray());
195
		if (es_posible_cruzar_capas)
196
			es_posible_cruzar_capas = actualizarTiempos(coverages.toArray());
197
		if (es_posible_cruzar_capas)
198
			es_posible_cruzar_capas = actualizarParametros(coverages.toArray());
199

  
200
		if (es_posible_cruzar_capas){
201
			// Actualizamos la lista de coberturas
202
			wcsParamsTabbedPane.getLstSelectedCoverages().setListData(coverages.toArray());
203
		} else {
204
			if (!Conjuntos.compara(coberturas_anteriores, coverages)){
205
				// Regresamos al estado anterior sin a?adir capa (con addCoverage() rellenamos
206
				// el wizard con valores anteriores.
207
				limpiaWizard();
208
				wcsParamsTabbedPane.getLstSelectedCoverages().setListData(coberturas_anteriores.toArray());
209
				addCoverage();
210
			}
211
		}
212
		
213
	}
214

  
215
	/**
216
	 * @param objects
217
	 * @return
218
	 */
219
	private boolean actualizarParametros(Object[] coverages) {
220
		// Solamente se permiten cruzar coberturas que no contengan parametros
221
		
222
		if (coverages.length == 1) {
223
			// Si solo hay una cobertura seleccionada, la a?adimos
224
			ArrayList listaParametros = data.getCoverageInfo(
225
					(String) coverages[0]).getParametros();
226
			Iterator it = listaParametros.iterator();
227
			while (it.hasNext()) {
228
				Parametro p = (Parametro) it.next();
229
				wcsParamsTabbedPane.getCmbParam().addItem(p.getName());
230
			}
231
			return true;
232
		}
233
		else {
234
			// Si no, si las que hay no requieren Parametros, tambi?n las a?adimos
235
			int i = 0;
236
			boolean hayParametros = false;
237
			while (i<coverages.length && !hayParametros) {
238
				hayParametros = data.getCoverageInfo((String) coverages[i]).hasParameter();
239
				i++;
240
			}
241
				
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff