Revision 3377

View differences:

trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/utils/Utilities.java
45 45
import java.io.OutputStream;
46 46

  
47 47
import java.rmi.NoSuchObjectException;
48
import java.util.StringTokenizer;
48 49
import java.util.Vector;
49 50

  
50 51

  
......
255 256
      }
256 257
      return true;
257 258
    }   
259
	/**
260
	 * Parses the String containing different items [character] separated and
261
	 * creates a vector with them.
262
	 * @param str String contains item1[c]item2[c]item3...
263
	 * @param c is the string value for separating the items
264
	 * @return Vector containing all the items
265
	 */
266
	public static Vector createVector(String str, String c)
267
	{
268
		StringTokenizer tokens = new StringTokenizer(str, c);
269
		Vector v = new Vector();
270
		try
271
		{
272
			while (tokens.hasMoreTokens())
273
			{
274
				v.addElement(tokens.nextToken());
275
			}
276
			return v;
277
		}
278
		catch (Exception e)
279
		{
280
			return new Vector();
281
		}
282
	}
283
   
258 284
}
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/exceptions/WMSException.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 org.gvsig.remoteClient.exceptions;
42

  
43
/**
44
 * Excepci?n provocada por el WMS.
45
 *
46
 * @author Vicente Caballero Navarro
47
 */
48
public class WMSException extends Exception {
49
	/**
50
	 *
51
	 */
52
	public WMSException() {
53
		super();
54
	}
55

  
56
	/**
57
	 * Crea WMSException.
58
	 *
59
	 * @param message
60
	 */
61
	public WMSException(String message) {
62
		super(message);
63
	}
64

  
65
	/**
66
	 * Crea WMSException.
67
	 *
68
	 * @param message
69
	 * @param cause
70
	 */
71
	public WMSException(String message, Throwable cause) {
72
		super(message, cause);
73
	}
74

  
75
	/**
76
	  * Crea WMSException.
77
	 *
78
	 * @param cause
79
	 */
80
	public WMSException(Throwable cause) {
81
		super(cause);
82
	}
83
}
0 84

  
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/Tests/Test.java
12 12
	public static void main(String[] args)
13 13
	{
14 14
		WMSClient wmsclient = new WMSClient("http://orto.cth.gva.es:80/wmsconnector/com.esri.wms.Esrimap/wms_urbanismo_tematicos?");
15
		
15
		//http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_urbanismo_tematicos?REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&LAYERS=3&STYLES=&SRS=EPSG:4326&BBOX=-1.5597948439,37.8178641941,0.5286772976,40.8151000365&WIDTH=500&HEIGHT=500&FORMAT=image/jpeg&EXCEPTIONS=XML
16 16
		try
17 17
		{
18 18
			wmsclient.connect();			
......
25 25
//			status.addLayerName("europa_rivieren");
26 26
//			status.addStyleName("default");
27 27
//			status.addStyleName("default");			
28
			status.setSrs("EPSG:23030");
29
			Rectangle2D extent = new Rectangle2D.Double(600000,4189000,800000,4514000);
28
			status.setSrs("EPSG:4326");
29
			
30
			Rectangle2D extent = new Rectangle2D.Double(-1.5597948439,37.8178641941,-1.5597948439-0.5286772976,37.8178641941-40.8151000365);
31
			
30 32
			status.setExtent(extent);
31 33
			status.setFormat("image/jpeg");
32 34
			status.setHeight(500);
33 35
			status.setWidth(500);
34 36
			
35
			wmsclient.getMap(status);			
37
			//wmsclient.getMap(status);			
36 38
			
37
			wmsclient.getFeatureInfo(status,300,300);
39
			//wmsclient.getFeatureInfo(status,300,300);
38 40
			
39 41
			System.out.println();
40 42
		}
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/WMSLayer.java
1 1
package org.gvsig.remoteClient.wms;
2 2

  
3 3
import java.io.IOException;
4
import java.util.ArrayList;
4 5
import java.util.Hashtable;
5 6
import java.util.TreeMap;
6 7
import java.util.Vector;
7 8

  
8 9
import org.gvsig.remoteClient.utils.BoundaryBox;
10
import org.gvsig.remoteClient.wms.wms_1_1_1.WMSLayer1_1_1;
9 11
import org.kxml2.io.KXmlParser;
10 12
import org.xmlpull.v1.XmlPullParserException;
11 13

  
......
15 17
 */
16 18
public abstract class WMSLayer implements org.gvsig.remoteClient.ILayer {
17 19

  
20
	ArrayList children = new ArrayList();
21
	WMSLayer1_1_1 parent = new WMSLayer1_1_1();
22
	
18 23
/**
19 24
 * <p>Layer Abstract field in the capabilities document </p> 
20 25
 */
......
260 265
 */
261 266
    public void setAbstract(String _abstract) {        
262 267
        layerAbstract = _abstract;
263
    } 
268
    }
269

  
270

  
271
public ArrayList getChildren() {
272
	return children;
273
}
274

  
275

  
276
public void setChildren(ArrayList children) {
277
	this.children = children;
278
}
279

  
280

  
281
public WMSLayer1_1_1 getParent() {
282
	return parent;
283
}
284

  
285

  
286
public void setParent(WMSLayer1_1_1 parent) {
287
	this.parent = parent;
288
} 
264 289
 }
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/WMSClient.java
1 1

  
2 2
package org.gvsig.remoteClient.wms;
3 3

  
4
import java.awt.geom.Rectangle2D;
4 5
import java.util.TreeMap;
5 6
import java.util.Vector;
6 7

  
8
import org.gvsig.remoteClient.exceptions.WMSException;
9
import org.gvsig.remoteClient.utils.BoundaryBox;
7 10
import org.gvsig.remoteClient.wms.wms_1_1_1.WMSProtocolHandler1_1_1;
8 11

  
12

  
13

  
9 14
/**
10 15
 * <p>Represents the class the with the necessary logic to connect to a OGCWMS and interpretate the data </p>
11 16
 * 
......
15 20
    private org.gvsig.remoteClient.wms.WMSProtocolHandler handler;
16 21
    private TreeMap layers = new TreeMap();
17 22
 
18
    public WMSClient()
19
    {}
20 23
    
21 24
    /**
22 25
     * Constructor.
......
28 31
		setHost(host);
29 32
		try
30 33
		{
31
			//TODO: implement a correctly negotiate algorithm
34
			//TODO: implement a correct negotiation algorithm
32 35
			//handler = WMSProtocolHandlerFactory.negotiate(new URL(host));
33 36
			handler = new WMSProtocolHandler1_1_1();
34 37
			handler.setHost(host);
35 38
		}
36 39
		catch(Exception e)
37 40
		{
38
			//TODO: Implement logic to handle exceptions...
39
		}
40
		
41
			e.printStackTrace();
42
		}		
41 43
	}
42
    
44
   
45
	public String getVersion()
46
	{
47
		return handler.getVersion();
48
	}
43 49
/**
44 50
 * <p>One of the three interfaces that OGC WMS defines. Request a map.</p> 
45 51
 */
46
    public void getMap(WMSStatus status) {        
47
        handler.getMap(status);
52
    public byte[] getMap(WMSStatus status) throws WMSException{       
53
        return handler.getMap(status);
48 54
    } 
49 55

  
50 56
/**
......
60 66
 * <p>One of the three interfaces defined by the OGC WMS, it gets the information about a feature requested</p>
61 67
 * @return 
62 68
 */
63
    public String getFeatureInfo(WMSStatus status, int x, int y) {        
64
        return handler.getFeatureInfo(status, x, y);
69
    public String getFeatureInfo(WMSStatus status, int x, int y, int featureCount) throws WMSException{        
70
        return handler.getFeatureInfo(status, x, y, featureCount);
65 71
    } 
66 72

  
67 73
/**
......
157 163
    public void close() {        
158 164
        // your code here
159 165
    } 
166
    
167
    
168
/**
169
 * Returns the max extent that envolves the requested layers
170
 * */
171
public Rectangle2D getLayersExtent(String[]layerNames, String srs)
172
{
173
	try
174
	{
175
		BoundaryBox bbox;
176
		WMSLayer layer = getLayer(layerNames[0]);
177
		
178
		bbox = layer.getBbox(srs);
179
		double xmin = bbox.getXmin();
180
		double xmax = bbox.getXmax();
181
		double ymin = bbox.getYmin();
182
		double ymax = bbox.getYmax();
183
		
184
		for(int i=1; i<layerNames.length; i++)
185
		{
186
			layer = getLayer(layerNames[i]);
187
			bbox = layer.getBbox(srs);
188
			
189
			if (bbox.getXmin() < xmin)
190
			{
191
				xmin = bbox.getXmin();
192
			}
193
			if (bbox.getYmin() < ymin)
194
			{
195
				ymin = bbox.getYmin();
196
			}
197
			if (bbox.getXmax() > xmax)
198
			{
199
				xmax = bbox.getXmax();
200
			}
201
			if (bbox.getYmax() > ymax)
202
			{
203
				ymax = bbox.getYmax();
204
			}
205
		}	
206
		Rectangle2D extent = new Rectangle2D.Double(xmin,ymin,Math.abs(xmax-xmin),Math.abs(ymax-ymin));
207
		return extent;
208
	}
209
	catch(Exception e)
210
	{
211
		//TODO:
212
		//Implement logic to handle all the exceptions
213
		return null;
214
	}
215
}
160 216

  
217

  
161 218
/**
162
 * <p>Does ...</p>
219
 * Gets the Service information included in the Capabilities
220
 * */
221

  
222
public WMSProtocolHandler.ServiceInformation getServiceInformation()
223
{
224
	return handler.getServiceInformation();  
225
}
226
/**
227
 * <p>Checks the connection to de remote WMS and requests its capabilities.</p>
163 228
 * 
164 229
 */
165 230
    public boolean connect() 
166 231
	{
167 232
		try {
233
			getCapabilities();
168 234
			if (handler == null)
169 235
			{
170 236
				if (getHost().trim().length() > 0)
......
180 246
					return false;
181 247
				}
182 248
			}
183
			getCapabilities();
184 249
			return true;
185 250
			
186 251
		} catch (Exception e) {
187
			//TODO:
188
			//Implement the logic to handle all the exceptions....
252
			e.printStackTrace();
189 253
			return false;
190 254
		}
191 255
	}
192
 }
256

  
257
    //TODO Check this out: Always 1 layer at first level...
258
    public WMSLayer getLayersRoot() {
259
    	return (WMSLayer)layers.values().toArray()[0];
260
    }
261
}
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/WMSProtocolHandler.java
5 5
import java.io.DataOutputStream;
6 6
import java.io.File;
7 7
import java.io.FileOutputStream;
8
import java.io.IOException;
8 9
import java.io.InputStream;
9 10
import java.io.OutputStream;
11
import java.net.ConnectException;
10 12
import java.net.URL;
13
import java.net.UnknownHostException;
11 14
import java.util.TreeMap;
12 15
import java.util.Vector;
13 16
import org.gvsig.remoteClient.utils.Utilities;
14 17

  
18
import com.devx.io.TempFileManager;
19

  
20

  
15 21
/**
16 22
 * <p> Abstract class that represents handlers to comunicate via WMS protocol.
17 23
 * </p>
......
88 94
			//TODO:
89 95
			//pass this buildXXXRequest to the WMSProtocolHandlerXXX: The request can depend on the WMS version.
90 96
			request = new URL(buildMapRequest(status));
97
	    	byte[] buffer = new byte[1024*256];
98
	    	byte[] imageBytes = null;
99
	    	InputStream is = request.openStream();
100
	    	int readed = 0;
101
	    	
102
	    	for (int i = is.read(buffer); i>0; i = is.read(buffer)){
103
	    		byte[] buffered = new byte[readed+i];
104
	    		for (int j = 0; j < buffered.length; j++) {
105
	    			if (j<readed){
106
	    				buffered[j] = imageBytes[j];
107
	    			}
108
	    			else {
109
	    				buffered[j] = buffer[j-readed];
110
	    			}
111
				}
112
	    		imageBytes = (byte[]) buffered.clone();
113
	    		readed += i;
114
	    		
115
	    	}
116
			
117
			return imageBytes;
118
	    	
91 119
		}
92 120
		catch(Exception e)
93 121
		{
94 122
			// TODO something about the exceptionsssss....!!!
95 123
		}
96 124
		
97
    	try
98
    	{
99
	    
100
    		System.out.println(request.toString());
101
    		File f = new File("map.jpeg");
102
    	  DataOutputStream dos = new DataOutputStream(new FileOutputStream(f));
103
	  	  
104
		  OutputStream bos = null;
105

  
106
	    	byte[] buffer = new byte[1024*256];
107
	    	InputStream is = request.openStream();
108
	    	//long readed = 0;
109
	    	for (int i = is.read(buffer); i>0; i = is.read(buffer)){
110
	    		dos.write(buffer, 0, i);
111
	    		//readed += i;
112
	    	}
113
	    	dos.close();
114
	    	
115
	    return null;
116
    	}
117
    	catch(Exception e)
118
    	{
119
    		//TODO
120
    		//Implement the correct logic to handle all the exceptions.
121
    		return null;
122
    	}
125
		return null;
123 126
    } 
124 127

  
125 128
	/**
......
136 139
		}
137 140
		catch(Exception e)
138 141
		{
139
			// TODO something about the exceptionsssss....!!!
142
			e.printStackTrace();
140 143
		}
141 144
		
142
	   	File f = null;
143
	   	f = new File("tochangethis.txt");
144
	    
145
	    if (!f.exists())
146
	    {
147
	    	try
148
	    	{
149
		    	DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(f)));
150
		    	byte[] buffer = new byte[1024*256];
151
		    	InputStream is = request.openStream();
152
		    	long readed = 0;
153
		    	for (int i = is.read(buffer); i>0; i = is.read(buffer)){
154
		    		dos.write(buffer, 0, i);
155
		    		readed += i;
156
		    	}
157
		    	dos.close();
158
	    	}
159
	    	catch(Exception e)
160
	    	{}
161
	    }
145
//	   	File f = null;
146
//	   	f = new File("tochangethis.txt");
147
//	    
148
//	    if (!f.exists())
149
//	    {
150
//	    	try
151
//	    	{
152
//		    	DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(f)));
153
//		    	byte[] buffer = new byte[1024*256];
154
//		    	InputStream is = request.openStream();
155
//		    	long readed = 0;
156
//		    	for (int i = is.read(buffer); i>0; i = is.read(buffer)){
157
//		    		dos.write(buffer, 0, i);
158
//		    		readed += i;
159
//		    	}
160
//		    	dos.close();
161
//	    	}
162
//	    	catch(Exception e)
163
//	    	{}
164
//	    }
165
		try
166
		{
167
		File f = downloadFile(request,"wms_capabilities.xml");
162 168
	    parse(f);
163
	    //return parse(f);
169
		}
170
		catch(Exception e)
171
		{
172
			//TODO
173
			e.printStackTrace();
174
		}
164 175
    }
165 176

  
166 177
/**
167 178
 * <p>It will send a GetFeatureInfo request to the WMS
168 179
 * Parsing the response and redirecting the info to the WMS client</p>
169 180
 */
170
    public String getFeatureInfo(WMSStatus status, int x, int y)
181
    public String getFeatureInfo(WMSStatus status, int x, int y, int featureCount)
171 182
    {
172 183
    	URL request = null;
173 184
		try
......
214 225
    private String buildCapabilitiesRequest()
215 226
    {
216 227
		String req = new String();
217
		
218
		req = req + getHost() + "REQUEST=GetCapabilities&SERVICE=WMS&";
228
		String host = getHost();
229
		if (!host.endsWith("?"))
230
			req = req + getHost() + "?REQUEST=GetCapabilities&SERVICE=WMS&";
231
		else
232
			req = req + getHost() + "REQUEST=GetCapabilities&SERVICE=WMS&";
219 233
		req = req + "VERSION=" + getVersion();
220 234
		req += ("&EXCEPTIONS=XML");
221 235
		return req;
......
227 241
    private String buildGetFeatureInfoRequest(WMSStatus status, int x, int y)
228 242
    {
229 243
		String req = new String();
230
		
231
		req = req + getHost() + "REQUEST=GetFeatureInfo&SERVICE=WMS&";
244
		if (!host.endsWith("?"))
245
			req = req + getHost() + "?REQUEST=GetFeatureInfo&SERVICE=WMS&";
246
		else
247
			req = req + getHost() + "REQUEST=GetFeatureInfo&SERVICE=WMS&";
232 248
		req = req + "QUERY_LAYERS="+Utilities.Vector2CS(status.getLayerNames()); 
233 249
		req = req + "&VERSION=" + getVersion() + "&";
234 250
		req = req + getPartialQuery(status);
......
247 263
    private String buildMapRequest(WMSStatus status)
248 264
    {
249 265
		String req = new String();
250
		
251
		req = req + getHost() + "REQUEST=GetMap&SERVICE=WMS&";
266
		if (!host.endsWith("?"))
267
			req = req + getHost() + "?REQUEST=GetMap&SERVICE=WMS&";
268
		else
269
			req = req + getHost() + "REQUEST=GetMap&SERVICE=WMS&";
252 270
		req = req + "VERSION=" + getVersion() + "&";
253 271
		req = req + getPartialQuery(status);
254 272
       if (status.getExceptionFormat() != null) {
......
355 373
            email = new String();
356 374
            formats = new Vector();       	
357 375
        }
358
     }    
376
     }   
377
    
378
    /**
379
     * Downloads an URL into a temporary file that is removed the next time the 
380
     * tempFileManager class is called, which means the next time gvSIG is launched.
381
     * 
382
     * @param url
383
     * @param name
384
     * @return
385
     * @throws IOException
386
     * @throws ServerErrorResponseException
387
     * @throws ConnectException
388
     * @throws UnknownHostException
389
     */
390
    private File downloadFile(URL url, String name) throws IOException,ConnectException, UnknownHostException{
391
    	File f = null;
392

  
393
	    try{
394
	    	f = TempFileManager.createTempFile(name, "tmp");
395
	    	System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\ndownloading '"+url.toString()+"' to: "+f.getAbsolutePath());
396
			 
397
	    	f.deleteOnExit();
398
		    
399
	    } catch (IOException io) {
400
	    	io.printStackTrace();
401
	    }
402
	    DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(f)));
403
	    byte[] buffer = new byte[1024*256];
404
	    InputStream is = url.openStream();
405
	    long readed = 0;
406
	    for (int i = is.read(buffer); i>0; i = is.read(buffer)){
407
	    	dos.write(buffer, 0, i);
408
	    	readed += i;
409
	    }
410
	    dos.close();
411
	    /*if (!isNotAnException(f))
412
	    	// SI que es una excepci?n
413
	    	throw new ServerErrorResponseException();*/
414
	    return f;
415
	}
416

  
359 417
 }
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/wms_1_1_1/WMSLayer1_1_1.java
2 2
package org.gvsig.remoteClient.wms.wms_1_1_1;
3 3

  
4 4
import java.io.IOException;
5
import java.util.ArrayList;
5 6

  
6 7
import org.gvsig.remoteClient.utils.BoundaryBox;
7 8
import org.gvsig.remoteClient.utils.CapabilitiesTags;
......
17 18
 */
18 19
public class WMSLayer1_1_1 extends org.gvsig.remoteClient.wms.WMSLayer {
19 20

  
21
	
20 22
/**
21 23
 * <p>Parses the contents of the parser(WMSCapabilities)
22 24
 * to extract the information about an WMSLayer</p>
......
47 49
			 switch(currentTag)
48 50
			 {
49 51
				case KXmlParser.START_TAG:
50
					
51
					if (parser.getName().compareTo(CapabilitiesTags.NAME)==0)
52
					/*if (parser.getName().compareTo(CapabilitiesTags.LAYER)==0)
53
					{	
54
						WMSLayer1_1_1 lyr = new WMSLayer1_1_1();						
55
						parser.next(); 
56
						lyr.parse(parser);
57
						lyr.setParent(this);
58
						getChildren().add(lyr);
59
					}											
60
					else */if (parser.getName().compareTo(CapabilitiesTags.NAME)==0)
52 61
					{		
53 62
						value = parser.nextText();
54 63
						if (value != null) setName(value);						
......
132 141
				case KXmlParser.TEXT:					
133 142
					break;
134 143
			 }
135
			 if (!end)
136
			 {
144
			 //if (!end)
145
			 //{
137 146
				 currentTag = parser.next();
138
			 }
147
			 //}
139 148
    	}
140
    	parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.LAYER);
149
    	//parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.LAYER);
141 150
    }      
142 151
 }
trunk/libraries/libRemoteServices/build.xml
6 6
  <property name="src" location="src"/>
7 7
  <property name="build" location="bin"/>
8 8
  <property name="dist"  location="dist"/>
9
  <property name="lib"  location="lib"/>
9 10
  <property name="jar" value="CqRemoteClient"/>
10 11
  <!--property name="fmapdir" value="../FMAP"/-->
11 12
  <property name="targetDir" location="."/>
12

  
13
  <property name="targetDir2" location="../FMap 03/lib"/>
14
	
13 15
  <target name="init">
14 16
    <!-- Create the time stamp -->
15 17
    <tstamp/>
......
32 34
    <jar jarfile="${dist}/${jar}.jar" basedir="${build}"/>
33 35
    <jar jarfile="${dist}/${jar}.jar" basedir="." includes = "images/*.gif" update="true" />
34 36

  
35
    <move todir="${targetDir}/">
37
    <move todir="${targetDir2}/">
36 38
    	<fileset dir="${dist}" includes="**/**"/>
37 39
    </move>
40
  	<copy todir="${targetDir2}/">
41
  	    	<fileset dir="${lib}" includes="*.jar"/>
42
  	</copy>
43
 <!--   <move todir="${targetDir}/">
44
     	<fileset dir="${dist}" includes="**/**"/>
45
     </move>-->
38 46
  </target>
39 47

  
40 48
  <target name="clean"
trunk/libraries/libRemoteServices/.classpath
7 7
	<classpathentry kind="lib" path="/Andami/lib/log4j-1.2.8.jar"/>
8 8
	<classpathentry sourcepath="ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.1.0/src/org.junit_3.8.1/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
9 9
	<classpathentry kind="lib" path="C:/projects/gvsig/workspace/Cq RemoteClient/lib/kxml2.jar"/>
10
	<classpathentry kind="lib" path="/Andami/lib/tempFileManager.jar"/>
10 11
	<classpathentry kind="output" path="bin"/>
11 12
</classpath>
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/fmap/drivers/WMSDriver.java
45 45
import java.net.ProtocolException;
46 46
import java.net.URL;
47 47

  
48
import org.gvsig.remoteClient.wms.WMSStatus;
48 49

  
50

  
49 51
/**
50 52
 * Interfaz Driver para WMS.
51 53
 *
......
75 77
	 * @throws IOException 
76 78
	 * @throws ProtocolException 
77 79
	 */
78
	Image getMap(com.iver.wmsclient.MapQuery mapQuery)
80
	//Image getMap(com.iver.wmsclient.MapQuery mapQuery)
81
	Image getMap(WMSStatus mapQuery)
79 82
		throws WMSException, IOException, ProtocolException;
80 83

  
81 84
	//    String getFeatureInfo(InfoQuery infoQuery) throws WMSException, IOException, ProtocolException;
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/fmap/drivers/wms/FMapWMSDriver.java
49 49

  
50 50
import javax.imageio.ImageIO;
51 51

  
52
import org.exolab.castor.xml.ValidationException;
52
import org.gvsig.remoteClient.wms.WMSClient;
53
import org.gvsig.remoteClient.wms.WMSStatus;
53 54

  
54 55
import com.iver.cit.gvsig.fmap.drivers.WMSDriver;
55 56
import com.iver.cit.gvsig.fmap.drivers.WMSException;
56
import com.iver.wmsclient.Capabilities;
57
import com.iver.wmsclient.FeatureInfoQuery;
58
import com.iver.wmsclient.MapQuery;
59
import com.iver.wmsclient.UnsupportedVersionException;
60
import com.iver.wmsclient.WMSClient;
61
import com.iver.wmsclient.WMSClientFactory;
57
//import com.iver.wmsclient.Capabilities;
58
//import com.iver.wmsclient.FeatureInfoQuery;
59
//import com.iver.wmsclient.MapQuery;
60
//import com.iver.wmsclient.UnsupportedVersionException;
61
//import com.iver.wmsclient.WMSClient;
62
//import com.iver.wmsclient.WMSClientFactory;
62 63

  
63 64

  
64 65
/**
......
67 68
 * @author Vicente Caballero Navarro
68 69
 */
69 70
public class FMapWMSDriver implements WMSDriver {
70
	private MapQuery lastMapQuery;
71
	//private MapQuery lastMapQuery;
72
	//private WMSClient client;
73

  
74
	private WMSStatus wmsStatus;
71 75
	private WMSClient client;
72

  
73 76
	/**
74 77
	 * @see com.iver.cit.gvsig.fmap.drivers.WMSDriver#getCapabilities(java.net.URL)
75 78
	 */
76 79
	public void getCapabilities(URL servidor)
77 80
		throws WMSException, IOException, ProtocolException {
78 81
		try {
79
			Capabilities c = getClient(servidor).getCapabilities(servidor);
80
		} catch (UnsupportedVersionException e) {
82
			//Capabilities c = getClient(servidor).getCapabilities(servidor);
83
			getClient(servidor).connect();
84
		//} catch (UnsupportedVersionException e) {
85
		} catch (Exception e) {			
81 86
			throw new WMSException(e);
82 87
		}
83 88
	}
......
85 90
	/**
86 91
	 * @see com.iver.cit.gvsig.fmap.drivers.WMSDriver#getMap(com.iver.cit.gvsig.fmap.drivers.wms.MapQuery)
87 92
	 */
88
	public Image getMap(MapQuery mapQuery)
93
	public Image getMap(WMSStatus wmsstatus)
89 94
		throws WMSException, IOException, ProtocolException {
90
		BufferedImage image = new BufferedImage(mapQuery.getWidth(),
91
				mapQuery.getHeight(), BufferedImage.TYPE_INT_ARGB);
95
		BufferedImage image = new BufferedImage(wmsstatus.getWidth(),
96
				wmsstatus.getHeight(), BufferedImage.TYPE_INT_ARGB);
92 97

  
93 98
		try {
94
			byte[] res = client.doMapQuery(mapQuery);
99
			byte[] res = client.getMap(wmsstatus);			
95 100
			ByteArrayInputStream inbytes = new ByteArrayInputStream(res);
96 101
			image = ImageIO.read(inbytes);
97 102

  
98 103
			return image;
99
		} catch (ValidationException e) {
100
			throw new ProtocolException();
101
		} catch (com.iver.wmsclient.WMSException e) {
104
//		} catch (ValidationException e) {
105
//			throw new ProtocolException();
106
		} catch (org.gvsig.remoteClient.exceptions.WMSException e) {
102 107
			throw new WMSException(e);
103
		} catch (NoSuchFieldException e) {
104
			throw new RuntimeException(
105
				"No se incluyeron todos los campos necesarios de la petici?n");
108
//		} catch (NoSuchFieldException e) {
109
//			throw new RuntimeException(
110
//				"No se incluyeron todos los campos necesarios de la petici?n");
106 111
		}
107 112
	}
108 113

  
109 114
	/**
110 115
	 * @see com.iver.cit.gvsig.fmap.drivers.WMSDriver#getFeatureInfo(com.iver.cit.gvsig.fmap.drivers.wms.InfoQuery)
111 116
	 */
112
	public String getFeatureInfo(FeatureInfoQuery infoQuery)
117
	//public String getFeatureInfo(FeatureInfoQuery infoQuery)
118
	public String getFeatureInfo(WMSStatus wmsStatus)
113 119
		throws WMSException, IOException, ProtocolException {
114 120
		return null;
115 121
	}
......
125 131
	 * @throws IOException
126 132
	 */
127 133
	private WMSClient getClient(URL url)
128
		throws UnsupportedVersionException, IOException {
134
		throws IOException {
129 135
		if (client == null) {
130
			client = WMSClientFactory.getClient(url);
136
			//client = WMSClientFactory.getClient(url);
137
			client = new WMSClient(url.toString());
131 138
		}
132 139

  
133 140
		return client;
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/fmap/layers/FLyrWMS.java
69 69
import org.cresques.px.Extent;
70 70
import org.cresques.px.PxRaster;
71 71
import org.exolab.castor.xml.ValidationException;
72
import org.gvsig.remoteClient.exceptions.WMSException;
73
import org.gvsig.remoteClient.utils.Utilities;
74
import org.gvsig.remoteClient.wms.WMSClient;
75
import org.gvsig.remoteClient.wms.WMSStatus;
72 76

  
73 77
import com.devx.io.TempFileManager;
74 78
import com.iver.cit.gvsig.fmap.DriverException;
75 79
import com.iver.cit.gvsig.fmap.ViewPort;
76 80
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
77
import com.iver.cit.gvsig.fmap.drivers.WMSException;
81
import com.iver.cit.gvsig.fmap.drivers.UnsupportedVersionException;
78 82
import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint;
79 83
import com.iver.cit.gvsig.fmap.operations.Cancellable;
80 84
import com.iver.utiles.StringUtilities;
81 85
import com.iver.utiles.XMLEntity;
82
import com.iver.wmsclient.FeatureInfoQuery;
83
import com.iver.wmsclient.MapQuery;
84
import com.iver.wmsclient.UnsupportedVersionException;
85
import com.iver.wmsclient.WMSClient;
86
import com.iver.wmsclient.WMSClientFactory;
87 86

  
88 87

  
89 88
/**
......
107 106
	private String infoLayerQuery;
108 107
	public URL host;
109 108
	private WMSClient wmsClient;
110
	private MapQuery lastMapQuery;
109
	//private MapQuery lastMapQuery;
110
	private WMSStatus wmsStatus;
111 111
	private Rectangle2D fullExtent;
112 112

  
113 113
	private StatusRasterInterface		status = null;
......
137 137
		throws WMSException, IllegalStateException, ValidationException, 
138 138
			UnsupportedVersionException, IOException {
139 139
		String[] formats;
140
		formats = getWmsClient().getInfoFormats();
140
		formats = (String[]) getWmsClient().getFormats().toArray(new String[0]); //.getInfoFormats();
141 141

  
142 142
		for (int i = 0; i < formats.length; i++) {
143 143
			if (formats[i].equals("GML.1")) {
......
279 279
	 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#queryByPoint(com.iver.cit.gvsig.fmap.operations.QueriedPoint)
280 280
	 */
281 281
	public String queryByPoint(Point p) throws DriverException {
282
		FeatureInfoQuery query = new FeatureInfoQuery(lastMapQuery);
283
		query.setFeatureCount(Integer.MAX_VALUE);
284
		query.setX((int) p.getX());
285
		query.setY((int) p.getY());
286
		query.setInfoQuery(infoLayerQuery);
282
//		FeatureInfoQuery query = new FeatureInfoQuery(lastMapQuery);
283
//		query.setFeatureCount(Integer.MAX_VALUE);
284
//		query.setX((int) p.getX());
285
//		query.setY((int) p.getY());
286
//		query.setInfoQuery(infoLayerQuery);
287 287
		
288 288
		try {
289
			query.setInfoFormat(selectFormat());
290

  
291
			return new String(getWmsClient().doFeatureInfo(query));
292
		} catch (WMSException e) {
289
//			query.setInfoFormat(selectFormat());
290
//			return new String(getWmsClient().doFeatureInfo(query));
291
			return new String(getWmsClient()
292
					.getFeatureInfo(wmsStatus,(int)p.getX(),(int)p.getY(),Integer.MAX_VALUE));
293
		} catch (WMSException  e) {
293 294
			return "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><exception>" +
294 295
			e.getMessage() + "</exception>";
295 296
		} catch (ValidationException e) {
......
303 304
			throw new DriverException("Conflicto de versiones", e);
304 305
		} catch (IOException e) {
305 306
			throw new DriverException("Error en la conexi?n", e);
306
		} catch (com.iver.wmsclient.WMSException e) {
307
			throw new DriverException(e.getMessage(), e);
308
		} catch (NoSuchFieldException e) {
309
			throw new RuntimeException(
310
				"No se rellenaron todos los campos de la petici?n");
311 307
		}
308
//		} catch (com.iver.wmsclient.WMSException e) {
309
//			throw new DriverException(e.getMessage(), e);
310
		//}
311
//		catch (NoSuchFieldException e) {
312
//			throw new RuntimeException(
313
//				"No se rellenaron todos los campos de la petici?n");
314
//		}
312 315
	}
313 316

  
314 317
	/**
......
324 327
	 * 		com.iver.cit.gvsig.fmap.operations.Cancellable)
325 328
	 */
326 329
	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
327
		Cancellable cancel,double scale) throws DriverException {
330
			Cancellable cancel,double scale) throws DriverException {
328 331
		if (isWithinScale(scale)){	
329
		try {
330
			MapQuery mapQuery = getWmsClient().createQuery();
331
			mapQuery.setBBOX(viewPort.getAdjustedExtent());
332
			mapQuery.setFormat(m_Format);
333
			mapQuery.setHeight(viewPort.getImageHeight());
334

  
335
			// System.err.println("m_Mapa.getHeight() = " + m_Mapa.getHeight());
336
			mapQuery.setLayers(layerQuery);
337
			mapQuery.setSRS(m_SRS);
338
			mapQuery.setStyles("");
339
			mapQuery.setWidth(viewPort.getImageWidth());
340
			mapQuery.setExceptions("application/vnd.ogc.se_xml");
341

  
342
			byte[] bytes;
343
			lastMapQuery = mapQuery;
344
			bytes = getWmsClient().doMapQuery(lastMapQuery);
345

  
346
			ByteArrayInputStream inbytes = new ByteArrayInputStream(bytes);
347
			//BufferedImage tempImg = ImageIO.read(inbytes);
348
			// LWS Cambio de estrategia en el posicionado para la impresi?n.
349
			Point2D p2=new Point2D.Double(viewPort.getAdjustedExtent().getX(), viewPort.getAdjustedExtent().getMaxY()); //viewPort.getOffset();
350
			viewPort.getAffineTransform().transform(p2, p2);
351
			
352
			rasterProcess(g, viewPort, createTemp(inbytes, "wms_Query", viewPort));
353
			if(status!=null && firstLoad){
354
				status.applyStatus(this);
355
				firstLoad = false;
332
			try {
333
				
334
//				MapQuery mapQuery = getWmsClient().createQuery();
335
//				mapQuery.setBBOX(viewPort.getAdjustedExtent());
336
//				mapQuery.setFormat(m_Format);
337
//				mapQuery.setHeight(viewPort.getImageHeight());
338
//				mapQuery.setLayers(layerQuery);
339
//				mapQuery.setSRS(m_SRS);
340
//				mapQuery.setStyles("");
341
//				mapQuery.setWidth(viewPort.getImageWidth());
342
//				mapQuery.setExceptions("application/vnd.ogc.se_xml");
343
				
344
				if (wmsStatus == null)
345
				{
346
					wmsStatus = new WMSStatus();
347
				}
348
				wmsStatus.setExtent(viewPort.getAdjustedExtent());
349
				wmsStatus.setFormat(m_Format);
350
				wmsStatus.setHeight( viewPort.getImageHeight());
351
				wmsStatus.setLayerNames(Utilities.createVector(layerQuery,","));
352
				wmsStatus.setSrs(m_SRS);
353
				
354
				
355
				byte[] bytes;
356
//				lastMapQuery = mapQuery;
357
//				bytes = getWmsClient().doMapQuery(lastMapQuery);
358
				bytes = getWmsClient().getMap(wmsStatus);
359
				
360
				ByteArrayInputStream inbytes = new ByteArrayInputStream(bytes);
361
				//BufferedImage tempImg = ImageIO.read(inbytes);
362
				// LWS Cambio de estrategia en el posicionado para la impresi?n.
363
				Point2D p2=new Point2D.Double(viewPort.getAdjustedExtent().getX(), viewPort.getAdjustedExtent().getMaxY()); //viewPort.getOffset();
364
				viewPort.getAffineTransform().transform(p2, p2);
365
				
366
				rasterProcess(g, viewPort, createTemp(inbytes, "wms_Query", viewPort));
367
				if(status!=null && firstLoad){
368
					status.applyStatus(this);
369
					firstLoad = false;
370
				}
371
				
372
				//g.drawImage(tempImg,(int)p2.getX(),(int)p2.getY(), null);
373
			} catch (ValidationException e) {
374
				throw new DriverException("No se reconoce el formato de la respuesta",
375
						e);
376
			} catch (UnsupportedVersionException e) {
377
				throw new DriverException("Conflicto de versiones", e);
378
			} catch (IOException e) {
379
				throw new DriverException("Error en la conexi?n", e);
380
			} catch (WMSException e) {
381
				throw new DriverException(e.getMessage(), e);
382
//				} catch (NoSuchFieldException e) {
383
//				throw new RuntimeException(
384
//				"No se rellenaron todos los campos de la petici?n");
385
//				}
356 386
			}
357

  
358
			//g.drawImage(tempImg,(int)p2.getX(),(int)p2.getY(), null);
359
		} catch (ValidationException e) {
360
			throw new DriverException("No se reconoce el formato de la respuesta",
361
				e);
362
		} catch (UnsupportedVersionException e) {
363
			throw new DriverException("Conflicto de versiones", e);
364
		} catch (IOException e) {
365
			throw new DriverException("Error en la conexi?n", e);
366
		} catch (com.iver.wmsclient.WMSException e) {
367
			throw new DriverException(e.getMessage(), e);
368
		} catch (NoSuchFieldException e) {
369
			throw new RuntimeException(
370
				"No se rellenaron todos los campos de la petici?n");
371 387
		}
372
		}
373 388
	}
374 389
	
375 390
	/**
......
523 538
		throws IllegalStateException, ValidationException, 
524 539
			UnsupportedVersionException, IOException {
525 540
		if (wmsClient == null) {
526
			wmsClient = WMSClientFactory.getClient(host);
541
			//wmsClient = WMSClientFactory.getClient(host);
542
			wmsClient = new WMSClient(host.toString());
527 543
		}
528 544

  
529 545
		return wmsClient;
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/wizard/WizardData.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.wizard;
42

  
43
import org.gvsig.remoteClient.wms.WMSLayer;
44

  
45

  
46
/**
47
 * DOCUMENT ME!
48
 *
49
 * @author Fernando Gonz?lez Cort?s
50
 */
51
public class WizardData {
52
    private String title;
53
    private String Abstract;
54
    private WMSLayer layer;
55
    private String[] formats;
56

  
57
    /**
58
     * DOCUMENT ME!
59
     *
60
     * @return
61
     */
62
    public String getAbstract() {
63
        return Abstract;
64
    }
65

  
66
    /**
67
     * DOCUMENT ME!
68
     *
69
     * @return
70
     */
71
    public String[] getFormats() {
72
        return formats;
73
    }
74

  
75
    /**
76
     * DOCUMENT ME!
77
     *
78
     * @return
79
     */
80
    public WMSLayer getLayer() {
81
        return layer;
82
    }
83

  
84
    /**
85
     * DOCUMENT ME!
86
     *
87
     * @return
88
     */
89
    public String getTitle() {
90
        return title;
91
    }
92

  
93
    /**
94
     * DOCUMENT ME!
95
     *
96
     * @param string
97
     */
98
    public void setAbstract(String string) {
99
        Abstract = string;
100
    }
101

  
102
    /**
103
     * DOCUMENT ME!
104
     *
105
     * @param strings
106
     */
107
    public void setFormats(String[] strings) {
108
        formats = strings;
109
    }
110

  
111
    /**
112
     * DOCUMENT ME!
113
     *
114
     * @param info
115
     */
116
    public void setLayer(WMSLayer info) {
117
        layer = info;
118
    }
119

  
120
    /**
121
     * DOCUMENT ME!
122
     *
123
     * @param string
124
     */
125
    public void setTitle(String string) {
126
        title = string;
127
    }
128
}
0 129

  
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/wizard/WizardDataSource.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.wizard;
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.cit.gvsig.fmap.drivers.UnsupportedVersionException;
56

  
57
/**
58
 * @author fernando
59
 *
60
 * To change the template for this generated type comment go to
61
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
62
 */
63
public interface WizardDataSource {
64
	public WizardData detalles(URL host)throws IllegalStateException, ValidationException, 
65
	UnsupportedVersionException, IOException ;
66
	
67
	public Rectangle2D getBoundingBox(String[] layerName, String srs);
68

  
69
}
0 70

  
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/wizard/LayerTreeModel.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.wizard;
42

  
43
import javax.swing.event.TreeModelListener;
44
import javax.swing.tree.TreeModel;
45
import javax.swing.tree.TreePath;
46

  
47
import org.gvsig.remoteClient.wms.WMSLayer;
48

  
49

  
50

  
51

  
52

  
53
public class LayerTreeModel implements TreeModel {
54

  
55
	WMSLayer root;
56

  
57
	public LayerTreeModel(WMSLayer root){
58
		this.root = root;
59
	}
60

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

  
68
	/* (non-Javadoc)
69
	 * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
70
	 */
71
	public int getChildCount(Object parent) {
72
		return ((WMSLayer)parent).getChildren().size();
73
	}
74

  
75
	/* (non-Javadoc)
76
	 * @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
77
	 */
78
	public boolean isLeaf(Object node) {
79
		return ((WMSLayer)node).getChildren().size() == 0;
80
	}
81

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

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

  
94
	/* (non-Javadoc)
95
	 * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
96
	 */
97
	public Object getChild(Object parent, int index) {
98
		return ((WMSLayer)parent).getChildren().get(index);
99
	}
100

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

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

  
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/wizard/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.wizard;
42

  
43
import javax.swing.AbstractListModel;
44

  
45

  
46
/**
47
 * DOCUMENT ME!
48
 *
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff