Revision 15450

View differences:

import/ext3D/branches/ext3D_v1.1/lib3DMap/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>lib3DMap</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>de.loskutov.FileSync.FSBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
	</buildSpec>
19
	<natures>
20
		<nature>org.eclipse.jdt.core.javanature</nature>
21
	</natures>
22
</projectDescription>
import/ext3D/branches/ext3D_v1.1/lib3DMap/config/about.htm
1
<html>
2
  <head>
3
    <title>Extension 3D del programa GvSIG </title>
4
    <meta content="">
5
    <style></style>
6
  </head>
7
  <body>
8
<table width="60%" border="0">
9
  <tr>
10
    <td width="64%"><img src="images/logo_horiz_bicolor_gva.png" width="329" height="50"></td>
11
    <td width="36%"><div align="right"><img src="images/logoIver.png" width="87" height="50"></div></td>
12
  </tr>
13
  <tr>
14
    <td colspan="2"><font face="Arial, Helvetica, sans-serif">&copy; Copyright
15
      Generalitat Valenciana, IVER T.I and other contributors 2005.</font></td>
16
  </tr>
17
</table>
18
  <h3>Extesi&oacute;n de la Aplicaci&oacute;n para el tratamiento de top&oacute;nimos del Instituto Geogr&aacute;fico Nacional</h3>
19
  <p><br><br><b> Build Number: #build.number#</b></p>
20
  </body>
21
</html>
import/ext3D/branches/ext3D_v1.1/lib3DMap/build.number
1
#Build Number for ANT. Do not edit!
2
#Mon Jul 16 14:09:59 CEST 2007
3
build.number=12
import/ext3D/branches/ext3D_v1.1/lib3DMap/src/com/iver/ai2/gvsig3d/listener/canvasListener.java
1
package com.iver.ai2.gvsig3d.listener;
2

  
3
import java.awt.event.KeyEvent;
4
import java.awt.event.KeyListener;
5

  
6
import es.upv.ai2.libjosg.Vec3;
7
import es.upv.ai2.libjosg.planets.Planet;
8
import es.upv.ai2.libjosg.planets.PlanetViewer;
9
import es.upv.ai2.libjosg.viewer.Camera;
10
import es.upv.ai2.libjosg.viewer.IViewerContainer;
11
import es.upv.ai2.libjosg.viewer.OSGViewer;
12

  
13
public class canvasListener implements KeyListener {
14
	private static boolean active = false;
15

  
16
	private IViewerContainer m_canvas3d = null;
17

  
18
	private Planet planet;
19

  
20
	private RotatePlanet updateViewThread;
21

  
22
	private int frameRate = 24;
23

  
24
	private PlanetViewer m_planetViewer;
25

  
26
	private static boolean activeRot;
27

  
28
	public void setCanvas(IViewerContainer m_canvas3d) {
29
		this.m_canvas3d = m_canvas3d;
30
		this.m_planetViewer = (PlanetViewer) m_canvas3d.getOSGViewer();
31
	}
32

  
33
	public void keyPressed(KeyEvent kev) {
34
		// TODO Auto-generated method stub
35
		int codigo = kev.getKeyCode();
36
		switch (kev.getKeyChar()) {
37
		case 'w':
38
		case 'W':
39
			active = !active;
40
			if (active) {
41
				m_planetViewer.setPolygonMode(
42
						OSGViewer.PolygonModeType.GL_LINE);
43
			} else {
44
				m_planetViewer.setPolygonMode(
45
						OSGViewer.PolygonModeType.GL_FILL);
46
			}
47
			break;
48
		case 'a':
49
		case 'A':
50
			Thread thread;
51
			activeRot = !activeRot;
52
			if (activeRot) {
53

  
54
				updateViewThread = new RotatePlanet(1000/frameRate);
55

  
56
				// Create the thread supplying it with the runnable object
57
				thread = new Thread(updateViewThread);
58

  
59
				// Start the thread
60
				thread.start();
61
			} else {
62
				updateViewThread.end();
63
			}
64
			break;
65
			
66
		case 'e':
67
		case 'E':
68
			updateViewThread.setTime(1000/frameRate++);
69
			break;
70
		case 'd':
71
		case 'D':
72
			updateViewThread.setTime(1000/frameRate--);
73
			break;
74
		}
75

  
76
	}
77

  
78
	public void keyReleased(KeyEvent kev) {
79
		// TODO Auto-generated method stub
80

  
81
	}
82

  
83
	public void keyTyped(KeyEvent kev) {
84
		// TODO Auto-generated method stub
85

  
86
	}
87

  
88
	/**
89
	 * Class to rotate the planet. This class implements runnable and contructor
90
	 * with time parameter.
91
	 * 
92
	 * @author julio
93
	 * 
94
	 */
95
	public class RotatePlanet implements Runnable {
96

  
97
		private boolean finish = false;
98

  
99
		private long time;
100

  
101
		public RotatePlanet(long time) {
102
			this.time = time;
103
		}
104

  
105
		double lat = 0.0;
106

  
107
		double longi = 0.0;
108

  
109
		// This method is called when the thread runs
110
		public void run() {
111
			while (true) {
112
				try {
113
					Thread.sleep(time);
114
					synchronized (this) {
115
						if (finish) {
116
							break;
117
						}
118
					}
119
				} catch (InterruptedException e) {
120

  
121
					e.printStackTrace();
122
				}
123
				// Rotate planet
124
				longi += 1.0;
125
				longi = longi > 360 ? 0 : longi;
126
				Camera cam = m_planetViewer.getCamera();
127
				Vec3 camPos = planet.convertLatLongHeightToXYZ(new Vec3(lat,
128
						longi, cam.getEye().z()));
129

  
130
				cam.setViewByLookAt(camPos.x(), camPos.y(), 500000 * 16.6,
131
						0, 0, 0, 0, 0, 1);
132
				m_planetViewer.setCamera(cam);
133

  
134
				// Repainting canvas
135
				m_canvas3d.repaint();
136
			}
137
		}
138

  
139
		public synchronized void end() {
140
			finish = true;
141
		}
142

  
143
		public long getTime() {
144
			return time;
145
		}
146

  
147
		public void setTime(long time) {
148
			this.time = time;
149
		}
150

  
151
	}
152

  
153
	public Planet getPlanet() {
154
		return planet;
155
	}
156

  
157
	public void setPlanet(Planet planet) {
158
		this.planet = planet;
159
	}
160

  
161
}
import/ext3D/branches/ext3D_v1.1/lib3DMap/src/com/iver/ai2/gvsig3d/cacheservices/FLayerCacheService.java
1
package com.iver.ai2.gvsig3d.cacheservices;
2

  
3
import java.awt.Color;
4
import java.awt.Dimension;
5
import java.awt.Graphics2D;
6
import java.awt.Image;
7
import java.awt.geom.AffineTransform;
8
import java.awt.geom.Rectangle2D;
9
import java.awt.image.BufferedImage;
10
import java.io.File;
11
import java.io.IOException;
12
import java.net.URL;
13
import java.util.HashMap;
14
import java.util.Hashtable;
15
import java.util.Vector;
16

  
17
import org.cresques.cts.IProjection;
18
import org.cresques.px.Extent;
19
import org.gvsig.cacheservice.CacheService;
20
import org.gvsig.cacheservice.CacheServiceException;
21
import org.gvsig.cacheservice.RasterCacheService;
22
import org.gvsig.cacheservice.TileNum;
23
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
24
import org.gvsig.raster.buffer.BufferFactory;
25
import org.gvsig.raster.buffer.RasterBuffer;
26
import org.gvsig.raster.buffer.cache.WriterBufferServer;
27
import org.gvsig.raster.dataset.GeoRasterWriter;
28
import org.gvsig.raster.dataset.NotSupportedExtensionException;
29
import org.gvsig.raster.dataset.Params;
30
import org.gvsig.raster.dataset.RasterDriverException;
31
import org.gvsig.remoteClient.utils.Utilities;
32
import org.gvsig.remoteClient.wcs.WCSStatus;
33
import org.gvsig.remoteClient.wms.ICancellable;
34
import org.gvsig.remoteClient.wms.WMSStatus;
35

  
36
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
37
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps;
38
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
39
import com.iver.cit.gvsig.fmap.ViewPort;
40
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver;
41
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriverFactory;
42
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver;
43
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriverFactory;
44
import com.iver.cit.gvsig.fmap.layers.FLayer;
45
import com.iver.cit.gvsig.fmap.layers.FLyrWCS;
46
import com.iver.cit.gvsig.fmap.layers.FLyrWMS;
47
import com.iver.utiles.FileUtils;
48
import com.iver.utiles.swing.threads.Cancellable;
49

  
50
import es.upv.ai2.libjosg.planets.Planet;
51
import es.upv.ai2.libjosg.planets.Planet.PlanetType;
52

  
53
public class FLayerCacheService extends RasterCacheService {
54
	private boolean     _loadFailed = true;
55
	private Extent      _extent;
56
	private Rectangle2D _lyrExtentRect;
57
	private FLayer      _layer;
58
	private IProjection _viewProj;
59
	private int         _dataType;
60

  
61
	// WMS terrain
62
	// TODO Un toggle this comment to use WMS and WCS extensions.
63
	FMapWMSDriver _wmsDriver = null;
64
	FMapWCSDriver _wcsDriver = null;
65
	
66
	WMSStatus     _wmsStatus = null;
67
	WCSStatus     _wcsStatus = null;
68

  
69
	public FLayerCacheService(Planet planet, String name, FLayer layer, IProjection viewProj) {
70
		super(planet.getPlanetName(), name);
71

  
72
		_layer = layer;
73
		_viewProj = viewProj;
74
		_loadFailed = true;
75

  
76
		int cacheType = CacheService.GLOBAL;
77
		if (planet.getType()==PlanetType.SPHERICAL_MODE)
78
		    cacheType += SPHERIC;
79
		else
80
 		    cacheType += PLANE;
81
		setCacheType(cacheType);
82

  
83
		try {
84
			_lyrExtentRect = _layer.getFullExtent();
85
		} catch (ExpansionFileReadException e) {
86
			e.printStackTrace();
87
		} catch (ReadDriverException e) {
88
			e.printStackTrace();
89
		}
90

  
91
		_extent = new Extent(_lyrExtentRect);
92

  
93
		Layer3DProps props3D = Layer3DProps.getLayer3DProps(layer);
94
		_dataType = props3D.getType();
95
		if (_dataType==Layer3DProps.layer3DImage)
96
			setFileExtension(".png");
97
		else
98
			setFileExtension(".tif");
99

  
100
		_loadFailed = false;
101

  
102
	}
103

  
104
    protected class MyCancel implements Cancellable, ICancellable {
105

  
106
		public boolean isCanceled() {
107
			return false;
108
		}
109

  
110
		public void setCanceled(boolean canceled) {
111

  
112
		}
113

  
114
		public Object getID() {
115
			return null;
116
		}
117

  
118
    }
119

  
120
	private Image getTileFromLayer(String fName, Rectangle2D tileExtent)
121
	{
122
		BufferedImage image;
123

  
124
		if (_dataType==Layer3DProps.layer3DImage) {
125
			int size = getTileSize();
126
			image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
127

  
128
			ViewPort vp = new ViewPort(_viewProj);
129
			vp.setExtent(tileExtent); // the real extent of the tile
130
			vp.setAdjustable(false);
131
	        vp.setImageSize(new Dimension(size, size));
132

  
133
	        Graphics2D graphics = image.createGraphics();
134
	        Color backgColor = new Color(255, 255, 255, 0); // transparent background
135
	        graphics.setColor(backgColor);
136
	        graphics.fillRect(0, 0, size, size);
137

  
138
	//        CancelDraw canceldraw = new MapControl.CancelDraw();
139
	//        canceldraw.setCanceled(false);
140

  
141
	        // For now we'll use a trick to make sure the layer is drawn
142
	        // even if it has scale dependency
143
	        // In the future, a scale corresponding to the tile should be passed
144
	        double scale = 0.5*(_layer.getMaxScale()+_layer.getMinScale());
145
	        try {
146
				_layer.draw(image, graphics, vp, new MyCancel(), scale);
147
			} catch (ReadDriverException e) {
148
				e.printStackTrace();
149
			}
150

  
151
	        try {
152
				File file = new File(fName);
153
				String format = getFileExtension().substring(1);
154
				saveCachedFile(image, format, file);
155
			} catch (IOException e1) {
156
				e1.printStackTrace();
157
				return null;
158
			}
159
			return image;
160
		}
161
		else { // Elevation data
162
			// RASTER_GRID
163
            if (_layer instanceof FLyrRasterSE) {
164
            	//Grid grid = null;
165
			    FLyrRasterSE rasterLayer = (FLyrRasterSE)_layer;
166
			    	    
167
			    
168
			    //grid = rasterLayer.getSource().getGrid();
169
            	//if (grid == null)
170
            		//return null;
171
				
172
			    /*BufferFactory bufferFactory = rasterLayer.getDatasource();
173
			    
174
				int bands[] = {0};
175
				bufferFactory.setDrawableBands(bands);
176
				bufferFactory.setNoDataValue(0.0);
177

  
178
				bufferFactory.setAreaOfInterest(tileExtent.getMinX(),
179
						tileExtent.getMinY(), tileExtent.getMaxX(), tileExtent
180
								.getMaxY(), 32, 32);
181

  
182
				RasterBuffer raster = (RasterBuffer) bufferFactory
183
						.getRasterBuf();
184
				try {
185
					// raster.save(fName, new Extent(tileExtent));
186
					WriterBufferServer bufferServer = new WriterBufferServer(
187
							raster);
188
					Params p = GeoRasterWriter.getWriter(fName).getParams();
189
					AffineTransform at = new AffineTransform(tileExtent
190
							.getWidth() / 32, 0, 0,
191
							-(tileExtent.getHeight() / 32), tileExtent
192
									.getMinX(), tileExtent.getMaxY());
193

  
194
					GeoRasterWriter grw = GeoRasterWriter.getWriter(
195
							bufferServer, fName, 1, at, raster.getWidth(),
196
							raster.getHeight(), raster.getDataType(), p, null);
197
					// grw.setWkt(d.getWktProjection());
198
					grw.dataWrite();
199
					grw.writeClose();
200
				} catch (NotSupportedExtensionException e) {
201
					e.printStackTrace();
202
				} catch (RasterDriverException e) {
203
					e.printStackTrace();
204
				} catch (IOException e) {
205
					e.printStackTrace();
206
				}
207
*/
208
				
209
			}
210
			// TODO  Un toggle this comment to use WCS and WMS extensions.
211
			else
212
			if (_layer instanceof FLyrWMS) { // WMS Elevation
213
				try {  
214
					FLyrWMS wmsLayer = (FLyrWMS)_layer;
215
					if (_wmsDriver == null) {
216
	
217
					    URL host = wmsLayer.getHost();
218
	  			        _wmsDriver = FMapWMSDriverFactory.getFMapDriverForURL(host);
219
					}
220
					if (_wmsStatus == null) {
221
		  			    _wmsStatus = new WMSStatus();
222
		  			    _wmsStatus.setFormat(wmsLayer.getFormat());
223
		  			    _wmsStatus.setHeight(32);
224
		  			    _wmsStatus.setWidth(32);
225
		  			    _wmsStatus.setLayerNames(Utilities.createVector(wmsLayer.getLayerQuery(),","));
226
		  			    _wmsStatus.setSrs(wmsLayer.getSRS());
227
	
228
		  			    HashMap props = wmsLayer.getProperties();
229
		  			    Vector styles;
230
		  			    Vector dimensions;
231
		  			    styles = (Vector)(props.get("styles"));
232
		  			    dimensions = (Vector)(props.get("dimensions"));
233
		  			    _wmsStatus.setStyles(styles);
234
		  			    _wmsStatus.setDimensions(dimensions);
235
		  			    _wmsStatus.setTransparency(false);
236
		  			    String getMapStr = wmsLayer.getOnlineResource("GetMap");
237
		  			    _wmsStatus.setOnlineResource(getMapStr);
238
					}
239
					_wmsStatus.setExtent(tileExtent);
240
	
241
	  			    File f = _wmsDriver.getMap(_wmsStatus, new MyCancel());
242
		  			if (f == null)
243
		  				return null;
244
		  			FileUtils.copy(f, new File(fName));
245
	
246
		  			String fileName = f.getPath();
247
//		  			System.out.println(fileName);
248
	
249
				} catch (Exception e) {
250
					return null;
251
				}
252
			}
253
			else
254
				if (_layer instanceof FLyrWCS) { // WCS Elevation
255
					try { 
256
						FLyrWCS wcsLayer = (FLyrWCS)_layer;
257
						if (_wcsDriver == null) {
258
		
259
						    URL host = wcsLayer.getHost();
260
		  			        _wcsDriver = FMapWCSDriverFactory.getFMapDriverForURL(host);
261
						}
262
						if (_wcsStatus == null) {
263
			  			    _wcsStatus = new WCSStatus();
264
			  			    
265
			  			    Hashtable props = wcsLayer.getProperties();
266

  
267
			  			    _wcsStatus.setCoveraName((String)props.get("name"));
268
			  			    _wcsStatus.setFormat((String)props.get("format"));
269
			  			    _wcsStatus.setHeight(32);
270
			  			    _wcsStatus.setWidth(32);
271
			  			    _wcsStatus.setSrs((String)props.get("crs"));
272
			  			    _wcsStatus.setParameters((String)props.get("parameter"));
273
			  			    String time = (String)props.get("time");
274
			  			    if (time.length()>0)
275
			  			        _wcsStatus.setTime(time);
276
//			  			    _wcsStatus.setOnlineResource(wcsLayer.getOnlineResource("GetCoverage"));
277
						}
278
						_wcsStatus.setExtent(tileExtent);
279

  
280
			  			File f = _wcsDriver.getCoverage(_wcsStatus, new MyCancel());
281
			  			if (f == null)
282
			  				return null;
283
		
284
			  			FileUtils.copy(f, new File(fName));
285
		
286
			  			String fileName = f.getPath();
287
//			  			System.out.println(fileName);
288
		
289
					} catch (Exception e) {
290
						return null;
291
					}
292
				}/**/
293
			return null; // no image
294
		}
295

  
296
	}
297

  
298
	public String getTileAsFName(TileNum t) throws CacheServiceException {
299
		if(_loadFailed) { throw new CacheServiceException(new Exception()); }
300
		String tileId = t.numToOpTileId();
301
		String fName = getTileFileName(t);
302
//		System.out.println("CMTexture2D: requestTexture: "+tileId);
303
		if (!new File(fName).exists()) {
304
			Rectangle2D tileExtent = computeBBox(t);
305
			getTileFromLayer(fName, tileExtent);
306
		}
307
		return fName;
308
	}
309

  
310
	public Image getTileAsImage(TileNum tileNum) throws CacheServiceException {
311
		if(_loadFailed) { throw new CacheServiceException(new Exception()); }
312
		String tileId = tileNum.numToOpTileId();
313
		String fName = getTileFileName(tileNum);
314
//		System.out.println("CMTexture2D: requestTexture: "+tileId);
315
		Rectangle2D tileExtent = computeBBox(tileNum);
316
		return getTileFromLayer(fName, tileExtent);
317
	}
318

  
319
	public boolean intersectsLayer(TileNum tileNum) {
320
		Rectangle2D tileExtent = computeBBox(tileNum);
321
		// TODO: use a reprojected layer extent !!!
322
		/*System.err.println("TILE: ("+tileExtent.getMinX()+","+tileExtent.getMinY()+"),("+
323
				tileExtent.getMaxX()+","+tileExtent.getMaxY()+")");
324
		System.err.println("CAPA: ("+_lyrExtentRect.getMinX()+","+_lyrExtentRect.getMinY()+"),("+
325
				_lyrExtentRect.getMaxX()+","+_lyrExtentRect.getMaxY()+")");
326
		System.err.println("INTERSECTA LA CAPAAAAAA??????????:"+_lyrExtentRect.intersects(tileExtent));
327
		return (_lyrExtentRect.intersects(tileExtent));*/
328
		return Math.max(_lyrExtentRect.getMinX(),tileExtent.getMinX()) <= Math.min(_lyrExtentRect.getMaxX(),tileExtent.getMaxX()) &&
329
		Math.max(Math.min(_lyrExtentRect.getMinY(),_lyrExtentRect.getMaxY()),tileExtent.getMinY()) <= Math.min(Math.max(_lyrExtentRect.getMinY(),_lyrExtentRect.getMaxY()),tileExtent.getMaxY());
330
	}
331

  
332
}
import/ext3D/branches/ext3D_v1.1/lib3DMap/src/com/iver/ai2/gvsig3d/cacheservices/VectorCacheService.java
1
package com.iver.ai2.gvsig3d.cacheservices;
2

  
3
import java.awt.Color;
4
import java.awt.Graphics2D;
5
import java.awt.geom.PathIterator;
6
import java.awt.geom.Rectangle2D;
7
import java.awt.image.BufferedImage;
8
import java.util.ArrayList;
9
import java.util.HashMap;
10
import java.util.List;
11
import java.util.Map;
12

  
13
import org.cresques.cts.ICoordTrans;
14
import org.cresques.cts.IProjection;
15
import org.cresques.px.Extent;
16
import org.gvsig.cacheservice.CacheService;
17

  
18
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
19
import com.hardcode.gdbms.engine.data.driver.DriverException;
20
import com.iver.ai2.gvsig3d.gui.FeatureFactory;
21
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps;
22
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
23
import com.iver.cit.gvsig.fmap.ViewPort;
24
import com.iver.cit.gvsig.fmap.core.FGeometry;
25
import com.iver.cit.gvsig.fmap.core.FShape;
26
import com.iver.cit.gvsig.fmap.core.IFeature;
27
import com.iver.cit.gvsig.fmap.core.IGeometry;
28
import com.iver.cit.gvsig.fmap.core.styles.ILineStyle;
29
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol;
30
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol;
31
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol;
32
import com.iver.cit.gvsig.fmap.core.symbols.IMultiLayerSymbol;
33
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
34
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol;
35
import com.iver.cit.gvsig.fmap.core.symbols.SimpleTextSymbol;
36
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator;
37
import com.iver.cit.gvsig.fmap.layers.FLayer;
38
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
39
import com.iver.cit.gvsig.fmap.operations.strategies.DefaultStrategy;
40
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy;
41
import com.iver.cit.gvsig.fmap.rendering.IVectorialLegend;
42
import com.iver.cit.gvsig.fmap.rendering.ZSort;
43
import com.iver.utiles.swing.threads.Cancellable;
44

  
45
import es.upv.ai2.libjosg.Group;
46
import es.upv.ai2.libjosg.Node;
47
import es.upv.ai2.libjosg.Vec3;
48
import es.upv.ai2.libjosg.Vec4;
49
import es.upv.ai2.libjosg.features.PixelPoint;
50
import es.upv.ai2.libjosg.planets.Planet;
51
import es.upv.ai2.libjosg.planets.PlanetViewer;
52
import es.upv.ai2.libjosg.planets.Planet.PlanetType;
53
import es.upv.ai2.libjosg.viewer.IViewerContainer;
54

  
55
public class VectorCacheService extends CacheService {// implements
56
	// ExtendsFeatureVisitor{
57

  
58
	private IViewerContainer _canvas3D;
59
	
60
	private PlanetViewer _planetViewer;
61

  
62
	private Planet _planet;
63

  
64
	private Extent _extent;
65

  
66
	private Rectangle2D _lyrExtentRect;
67

  
68
	private FLayer _layer;
69

  
70
	private IProjection _viewProj;
71

  
72
	// vector caching for libJOSG
73
	private Group _layerNode;
74

  
75
	private Node _currentNode;
76

  
77
	private int _currentGeomType;
78

  
79
	private List m_labels;
80

  
81
	private float heigth = 5000;
82

  
83
	private boolean inPixels = true;
84

  
85
	private int fontSize = 14;
86

  
87
	private int n = 0;
88

  
89
	// Create a hash table
90
	Map pointsMap;
91

  
92
	private int option;
93

  
94
	private boolean primera = true;
95

  
96
	// private ISymbol _currentSymbol;
97

  
98
	public VectorCacheService(IViewerContainer canvas3D, Planet planet,
99
			String name, FLayer layer, IProjection viewProj) {
100
		super(planet.getPlanetName(), name);
101

  
102
		getNames();
103

  
104
		_canvas3D = canvas3D;
105
		_planetViewer =  (PlanetViewer) canvas3D.getOSGViewer();
106
		_planet = planet;
107
		_layer = layer;
108
		_viewProj = viewProj;
109
		_layerNode = new Group();
110
		_planetViewer.addSpecialNode(_layerNode);
111

  
112
		int cacheType = CacheService.GLOBAL;
113
		if (planet.getType() == PlanetType.SPHERICAL_MODE)
114
			cacheType += SPHERIC;
115
		else
116
			cacheType += PLANE;
117
		setCacheType(cacheType);
118

  
119
		try {
120
			_lyrExtentRect = _layer.getFullExtent();
121
		} catch (ExpansionFileReadException e) {
122
			// TODO Auto-generated catch block
123
			e.printStackTrace();
124
		} catch (ReadDriverException e) {
125
			// TODO Auto-generated catch block
126
			e.printStackTrace();
127
		}
128

  
129
		_extent = new Extent(_lyrExtentRect);
130

  
131
		// EJEMPLO DE COMO SE COGE LEL ITERATOR DE LA CAPA VECTORIAL
132
		FLyrVect flyrVect = (FLyrVect) _layer;
133
		
134

  
135
	}
136

  
137
	// uses a strategy to get all features from layer and their symbols
138
	// and add them to the planet
139

  
140
	public void AddFeaturesToPlanet() {
141

  
142
		// for testing, use DefaultStrategy. Later on we can implement
143
		// the optimized strategies
144

  
145
		Strategy strat = new DefaultStrategy(_layer);
146
		try {
147
			pointsMap = new HashMap();
148

  
149
			// YA NO SE USAN STRATEGYS POR LO TANTO NO EXISTE EL
150
			// PROCESSWITHSYMBOLS
151
			// strat.processWithSymbols(this, null /* no extent for now */,
152
			// null);
153
			newDraw();
154
			_layerNode.addChild(FeatureFactory.insertPointS((HashMap) pointsMap));
155
			getNames();
156
			_canvas3D.repaint();
157
		} catch (Exception e) {
158
			e.printStackTrace();
159
		}
160
	}
161

  
162
	public void RefreshFeaturesToPlanet() {
163
		// for testing, use DefaultStrategy. Later on we can implement
164
		// the optimized strategies
165
		this.DeleteFeaturesToPlanet();
166
		pointsMap = new HashMap();
167
		_layerNode = new Group();
168
		_planetViewer.addSpecialNode(_layerNode);
169
		_currentGeomType = -1;
170

  
171
		// SALVA_FEATURES
172
		Strategy strat = new DefaultStrategy(_layer);
173
		try {
174
			// YA NO SE USAN STRATEGYS POR LO TANTO NO EXISTE EL
175
			// PROCESSWITHSYMBOLS
176
			// strat.processWithSymbols(this, null /* no extent for now */,
177
			// null);
178
			newDraw();
179
			_layerNode.addChild(FeatureFactory.insertPointS((HashMap) pointsMap));
180
			getNames();
181
		} catch (Exception e) {
182
			e.printStackTrace();
183
		}
184
	}
185

  
186
	public void DeleteFeaturesToPlanet() {
187
		_planetViewer.removeSpecialNode(_layerNode);
188
	}
189

  
190
	public void refreshFeaturesToPlanet(boolean visible) {
191
		// _canvas3D.removeSpecialNode(_layerNode);
192
		_layerNode.setEnabledNode(visible);
193
	}
194

  
195
	// FeatureVisitor methods
196

  
197
	public String getProcessDescription() {
198
		// TODO Auto-generated method stub
199
		return null;
200
	}
201

  
202
	public boolean start(FLayer layer) {
203
		_currentNode = null;
204
		_currentGeomType = -1; // not set
205
		// _currentSymbol = null;
206

  
207
		return true; // if everything is okay
208
	}
209

  
210
	// public void stop(FLayer layer) {
211
	// // process of adding features is finished
212
	// }
213
	//
214
	// public void visit(IGeometry g, int index) throws VisitException {
215
	// // TODO Auto-generated method stub
216
	//
217
	// }
218

  
219
	// SALVA_FEATURES
220
	public void visitWithSymbol(IGeometry g, int index, ISymbol symbol) {
221

  
222
		ISymbol fsym = null;
223
		Color color = null;
224
		int geomType;
225
		// Point parameters
226
		int pointSize = 15;
227
		// Line parameters
228
		ILineStyle lineStyle;
229
		float lineWidth = 2;
230
		// Polygon parameters
231

  
232
		if (g == null || symbol == null)
233
			return;
234

  
235
		// Getting geometri
236
		geomType = g.getGeometryType();
237
		// Setting up geometri
238
		startGeometry(geomType, symbol);
239

  
240
		// Casting to symbol type
241

  
242
		// Point type
243
		if (symbol instanceof IMarkerSymbol) {
244
			fsym = (IMarkerSymbol) symbol;
245
			color = ((IMarkerSymbol) fsym).getColor();
246
			pointSize = (int) ((IMarkerSymbol) fsym).getSize();
247
//			pointSize = 10;
248

  
249
		}
250
		// Line Type
251
		if (symbol instanceof ILineSymbol) {
252
			fsym = (ILineSymbol) symbol;
253
			color = ((ILineSymbol) fsym).getColor();
254
			color = new Color(1.0f,0.0f,0.0f);
255
			lineStyle = ((ILineSymbol) fsym).getLineStyle();
256
			lineWidth = lineStyle.getLineWidth();
257
			SimpleLineSymbol a;
258
		}
259
		// Polygon type
260
		if (symbol instanceof IFillSymbol) {
261
			fsym = (IFillSymbol) symbol;
262
			color = ((IFillSymbol) fsym).getFillColor();
263

  
264
		}
265

  
266
		// TRANSFORMANDO A GEOMETRIA CON VALOR Z
267
		FGeometry g3D = null;
268
		if (g instanceof FGeometry) {
269
			g3D = (FGeometry) g;
270
		}
271

  
272
		// Setup point hash map
273
		List pointListAux = null;
274
		if ((geomType & FShape.POINT) == FShape.POINT) {
275
			if (pointsMap.containsKey(new Integer(pointSize))) {
276
				// System.out.println("ya contiene esa key");
277
				pointListAux = (List) pointsMap.get(new Double(pointSize));
278
			} else {
279
				pointListAux = new ArrayList();
280
				pointsMap.put(new Integer(pointSize), pointListAux);
281
			}
282

  
283
		}
284

  
285
		// if ((BasicStroke) fsym.getStroke() != null)
286
		// lineSize = ((BasicStroke) fsym.getStroke()).getLineWidth();
287
		// float comp[] = new float[4];
288
		// Color color = ((SimpleFillSymbol) fsym).getOutline().getColor();
289
		// comp = color.getColorComponents(comp);
290
		// color.getColorComponents(comp);
291

  
292
		// Getting font size
293
//		Font font = fsym.getFont();
294
//		if (font != null) {
295
//			inPixels = fsym.isFontSizeInPixels();
296
//			if (inPixels)
297
//				fontSize = (int) (((fsym.getFontSize() / FConstant.FONT_HEIGHT_SCALE_FACTOR)) * 2.5);
298
//			else
299
//				fontSize = (int) (fsym.getFontSize() / FConstant.FONT_HEIGHT_SCALE_FACTOR);
300
//		}
301

  
302
		// float alpha = ((float) fsym.getColor().getAlpha()) / 255.0f;
303

  
304
		float alpha = 1.0f;
305
		 Vec4 rgba = new Vec4(color.getRed(),color.getGreen(),color.getBlue(), alpha);
306
//		Vec4 rgba = new Vec4(1.0, 0.0, 0.0, alpha);
307

  
308
		// System.out.println("Transparencia :" + fsym.getColor().getAlpha());
309

  
310
		// Setting up heigth of feature
311
		// heigth = 5000;
312

  
313
		// Getting the Iterator
314
		PathIterator theIteratorL = g.getPathIterator(null);
315

  
316
		double[] dataLine = new double[6];
317
		List posi = new ArrayList();
318
		int contH = 0;
319
		// System.out.println("ENTRO");
320
		while (!theIteratorL.isDone()) {
321
			// System.out.println("ITERO");
322
			int type = theIteratorL.currentSegment(dataLine);
323

  
324
			Vec3 posGeo = null;
325
			Vec3 pos = null;
326
			double h = 0;
327
			if (Layer3DProps.getLayer3DProps(_layer).isZEnable()) {
328
				if ((_currentGeomType & FShape.Z) == FShape.Z) {
329
					if (g3D != null) {
330
						// h = (g3D.getZs()[contH])
331
						// * _planet.getVerticalExaggeration();
332
						h = (g3D.getZs()[contH])
333
								* Layer3DProps.getLayer3DProps(_layer)
334
										.getVerticalEx();
335
					}
336
				}
337
			} else {
338

  
339
				Layer3DProps props3D = Layer3DProps.getLayer3DProps(_layer);
340
				heigth = props3D.getHeigth();
341
				h = heigth;
342
			}
343

  
344
			if (this._planet.getType() == PlanetType.SPHERICAL_MODE) {
345
				// Transform to geodesical coordinates
346
				// posGeo = new Vec3(dataLine[1], dataLine[0], heigth);
347
				// posReal = new Vec3(dataLine[0], dataLine[1], dataLine[2]);
348
				// posGeo = _planet.convertLatLongHeightToXYZ(new Vec3(40.0,
349
				// 0.0, h));
350
				// posReal.setZ(posGeo.z());
351
				// pos = posReal;
352
				// pos.setX(posGeo.x());
353
				// pos.setY(posGeo.y());
354

  
355
				posGeo = new Vec3(dataLine[1], dataLine[0], h);
356
				pos = _planet.convertLatLongHeightToXYZ(posGeo);
357
			} else {
358
				pos = new Vec3(dataLine[0], dataLine[1], h);
359
			}
360
			// System.out.println("\nPosition posicion geodesicas: " +
361
			// posReal.x() + " " + posReal.y()
362
			// + " " + posReal.z());
363
			// System.out.println("Position cartesianas : " + pos.x() + " " +
364
			// pos.y()
365
			// + " " + pos.z());
366

  
367
			// Adding points
368
			switch (type) {
369
			case PathIterator.SEG_MOVETO:
370
				// System.out.println("SEG_MOVETO");
371
				Node node = _currentNode;
372

  
373
				if ((geomType & FShape.POINT) == FShape.POINT) {
374
					// pointListAux.add(new Punto3D(pos, rgba, pointSize));
375
					FeatureFactory.addNodeToPoint(node, pos, rgba, pointSize);
376
				} else if ((geomType & FShape.LINE) == FShape.LINE) {
377
					node = FeatureFactory.insertLine(posi, rgba, lineWidth);
378
				}
379
				if ((geomType & FShape.POLYGON) == FShape.POLYGON) {
380
					node = FeatureFactory.insertPolygon(posi, rgba);
381
				}
382

  
383
				if ((geomType & FShape.POINT) != FShape.POINT) {
384

  
385
					if (node != null) {
386
						_layerNode.addChild(node);
387
						posi.clear();
388
						posi = new ArrayList();
389
					}
390
					posi.add(pos);
391
				}
392
				break;
393

  
394
			case PathIterator.SEG_LINETO:
395
				// System.out.println("SEG_LINETO");
396
				posi.add(pos);
397
				break;
398

  
399
			case PathIterator.SEG_QUADTO:
400
				// System.out.println("SEG_QUADTO");
401
				break;
402

  
403
			case PathIterator.SEG_CUBICTO:
404
				// System.out.println("SEG_CUBICTO");
405
				break;
406

  
407
			case PathIterator.SEG_CLOSE:
408
				// System.out.println("SEG_CLOSE");
409
				break;
410
			}
411
			contH++;
412
			theIteratorL.next();
413
		}
414
		// System.out.println("Numero de puntos: " + contH);
415

  
416
		// Adding last symbol
417
		Node node = _currentNode;
418
		if (posi.size() > 0) {
419
			if ((geomType & FShape.POINT) == FShape.POINT) {
420
				node = FeatureFactory.insertPoints(posi, rgba, pointSize);
421
				// pointListAux.add(new Punto3D(pos,rgba,size));
422
				// System.out.println("entro");
423
			} else if ((geomType & FShape.LINE) == FShape.LINE) {
424
				node = FeatureFactory.insertLine(posi, rgba, lineWidth);
425
			}
426
			if ((geomType & FShape.POLYGON) == FShape.POLYGON) {
427
				node = FeatureFactory.insertPolygon(posi, rgba);
428
			}
429
			if (geomType != FShape.POINT)
430
				if (node != null) {
431
					_layerNode.addChild(node);
432
					posi.clear();
433
				}
434
		}
435

  
436
		// TODO: ADD GEOMETRY WITH SYMBOL to Planet
437
	}
438

  
439
	private void startGeometry(int geomType, ISymbol symb) {
440

  
441
		// TODO: create new node if some properties change in symbol (like point
442
		// size)
443

  
444
		// if ((geomType != _currentGeomType) || ((geomType & FShape.POINT) ==
445
		// FShape.POINT)) {
446
		if (geomType != _currentGeomType) {
447
			_currentGeomType = geomType;
448

  
449
			if ((geomType & FShape.Z) == FShape.Z)
450
				geomType = geomType - FShape.Z;
451

  
452
			if (((geomType & FShape.POINT) == FShape.POINT)) {
453
				Group g = new Group();
454
				PixelPoint point = (PixelPoint) FeatureFactory.insertPointS(new Vec3(0.0,
455
						0.0, 0.0), new Vec4(1.0f, 1.0f, 1.0f, 1.0f), 100);
456
				_currentNode = point;
457
				_layerNode.addChild(g);
458
				g.addChild(point);
459
			} else if (((geomType & FShape.LINE) == FShape.LINE)) {
460
				;
461
			} else if (((geomType & FShape.POLYGON) == FShape.POLYGON)) {
462
				;
463
			}
464
			// switch (geomType) {
465
			//
466
			// case FShape.POINT:
467
			// // Point point = (Point) VectorTest.insertPointS(new Vec3(0.0,
468
			// // 0.0, 0.0), new Vec4(1.0f, 1.0f, 1.0f, 1.0f), 100);
469
			// Group g = new Group();
470
			// _currentNode = g;
471
			// _layerNode.addChild(g);
472
			// break;
473
			// case FShape.LINE:
474
			// // No set up
475
			// break;
476
			// case FShape.POLYGON:
477
			// // No set up
478
			// break;
479
			//
480
			// }
481

  
482
		}
483
	}
484

  
485
	private void getNames() {
486

  
487
		if (_layer instanceof FLyrVect) {
488
			FLyrVect flyrVect = (FLyrVect) _layer;
489
			// REVISAR COMO SE GENERAN LOS LABELS CON LOS ITERADORES
490

  
491
			// createLabels(flyrVect);
492
			// // if (m_labels != null)
493
			// if (((VectorialLegend) flyrVect.getLegend()).getLabelField() !=
494
			// null)
495
			// if (m_labels.size() > 0)
496
			// _layerNode.addChild(VectorTest.insertLabels(
497
			// this.m_labels, fontSize, this.heigth,
498
			// inPixels, this._planet.getType()));
499
			//
500
			// } catch (DriverException e) {
501
			// // TODO Auto-generated catch block
502
			// e.printStackTrace();
503
			// }
504
		}
505

  
506
	}
507

  
508
	public void createLabels(FLyrVect lyrVect) throws DriverException {
509

  
510
		// SelectableDataSource ds = null;
511
		// ds = lyrVect.getRecordset();
512

  
513
		// try {
514
		// ReadableVectorial adapter = lyrVect.getSource();
515
		// adapter.start();
516
		// ds.start();
517
		// int sc;
518
		//
519
		// VectorialLegend l = (VectorialLegend) lyrVect.getLegend();
520
		//
521
		// if (((VectorialLegend) lyrVect.getLegend()).getLabelField() != null)
522
		// {
523
		// int fieldId = ds.getFieldIndexByName(((VectorialLegend) lyrVect
524
		// .getLegend()).getLabelField());
525
		// int idFieldHeightText = -1;
526
		// int idFieldRotationText = -1;
527
		//
528
		// FSymbol defaultSym = (FSymbol) l.getDefaultSymbol();
529
		//
530
		// if (l.getLabelHeightField() != null) {
531
		// idFieldHeightText = ds.getFieldIndexByName(l
532
		// .getLabelHeightField());
533
		// defaultSym.setFontSizeInPixels(false);
534
		// }
535
		//
536
		// if (l.getLabelRotationField() != null) {
537
		// idFieldRotationText = ds.getFieldIndexByName(l
538
		// .getLabelRotationField());
539
		// }
540
		//
541
		// sc = (int) ds.getRowCount();
542
		// m_labels = new ArrayList(sc);
543
		//
544
		// DriverAttributes attr = adapter.getDriverAttributes();
545
		// boolean bMustClone = false;
546
		// if (attr != null) {
547
		// if (attr.isLoadedInMemory()) {
548
		// bMustClone = attr.isLoadedInMemory();
549
		// }
550
		// }
551
		// ICoordTrans ct = lyrVect.getCoordTrans();
552
		//
553
		// for (int i = 0; i < sc; i++) {
554
		// IGeometry geom = adapter.getShape(i);
555
		//
556
		// if (geom == null) {
557
		// m_labels.add(null);
558
		// continue;
559
		// }
560
		// if (ct != null) {
561
		// if (bMustClone)
562
		// geom = geom.cloneGeometry();
563
		// geom.reProject(ct);
564
		// }
565
		//
566
		// // TODO: El m�todo contenedor (createLabelLayer) debe
567
		// // recoger
568
		// // los par�metros de posicionamiento y de allowDuplicates
569
		// // if (i >= 328)
570
		// // System.out.println("i= " + i + " " + val.toString());
571
		// Value val = ds.getFieldValue(i, fieldId);
572
		//
573
		// if ((val instanceof NullValue) || (val == null)) {
574
		// continue;
575
		// }
576
		//
577
		// FLabel[] lbls = geom.createLabels(0, true);
578
		// for (int j = 0; j < lbls.length; j++) {
579
		// if (lbls[j] != null) {
580
		// lbls[j].setString(val.toString());
581
		//
582
		// if (idFieldHeightText != -1) {
583
		// NumericValue height = (NumericValue) ds
584
		// .getFieldValue(i, idFieldHeightText);
585
		// lbls[j].setHeight(height.floatValue());
586
		// } else {
587
		// // El tama�o del texto va siempre en el
588
		// // simbolo
589
		// // por
590
		// // defecto
591
		// // cuando no hay un campo de altura de texto
592
		// // TODO: Todo esto cambiar� con el nuevo
593
		// // sistema
594
		// // de
595
		// // leyendas...
596
		// if (l.getDefaultSymbol() != null) {
597
		// lbls[j].setHeight(defaultSym.getFontSize());
598
		// // lbls[j].setColor(defaultSym.getFontColor()
599
		// // .getRGB());
600
		//
601
		// }
602
		// }
603
		//
604
		// if (idFieldRotationText != -1) {
605
		// DoubleValue rotation = (DoubleValue) ds
606
		// .getFieldValue(i, idFieldRotationText);
607
		// lbls[j].setRotation(rotation.getValue());
608
		// }
609
		// m_labels.add(lbls[j]);
610
		//
611
		// }
612
		//
613
		// }
614
		//
615
		// /*
616
		// * if (lbls[0] == null) m_labels.add(null); else
617
		// * m_labels.add(lbls[0].getOrig());
618
		// */
619
		// }
620
		//
621
		// }
622
		// ds.stop();
623
		// adapter.stop();
624
		//
625
		// } catch (DriverIOException e) {
626
		// e.printStackTrace();
627
		// throw new DriverException(e);
628
		// } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
629
		// e.printStackTrace();
630
		// throw new DriverException(e);
631
		// }
632

  
633
	}
634

  
635
	public void _draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
636
			Cancellable cancel, double scale) throws ReadDriverException {
637

  
638
		FLyrVect fLyrVect = (FLyrVect) _layer;
639
		// FEATURE ITERATORS (TEST METHOD)
640
		if (fLyrVect.isWithinScale(scale)) {
641
			// Las que solo tienen etiquetado sin pintar el shape,
642
			// no pasamos por ellas
643
			boolean bDrawShapes = true;
644
			// if (legend instanceof SingleSymbolLegend) {
645
			// if (legend.getDefaultSymbol().isShapeVisible() == false)
646
			// bDrawShapes = false;
647
			// }
648
			if (bDrawShapes) {
649
				try {
650
					// prepareDrawing(image, g, viewPort);
651

  
652
					ArrayList fieldList = new ArrayList();
653

  
654
					// fields from legend
655
					// String[] aux = legend.getUsedFields();
656
					// for (int i = 0; i < aux.length; i++) {
657
					// fieldList.add(aux[i]);
658
					// }
659

  
660
					// fields from labeling
661
					// if (fLyrVect.isLabeled()) {
662
					// aux = fLyrVect.getLabelingStrategy().getUsedFields();
663
					// for (int i = 0; i < aux.length; i++) {
664
					// fieldList.add(aux[i]);
665
					// }
666
					// }
667

  
668
					IFeatureIterator it = fLyrVect.getSource()
669
							.getFeatureIterator(/*
670
												 * viewPort.getAdjustedExtent(),
671
												 * (String[])
672
												 * fieldList.toArray(new
673
												 * String[fieldList.size()]),
674
												 * getProjection()
675
												 */);
676

  
677
					ZSort zSort = ((IVectorialLegend) fLyrVect.getLegend())
678
							.getZSort();
679
					if (zSort != null && zSort.isUsingZSort()) {
680
						BufferedImage[] imageLevels = new BufferedImage[zSort
681
								.getLevelCount() + 1];
682
						// System.out.println(zSort);
683
						Graphics2D[] graphics = new Graphics2D[imageLevels.length];
684
						for (int i = 0; !cancel.isCanceled()
685
								&& i < imageLevels.length; i++) {
686
							imageLevels[i] = new BufferedImage(
687
									image.getWidth(), image.getHeight(), image
688
											.getType());
689
							graphics[i] = imageLevels[i].createGraphics();
690
						}
691
						while (!cancel.isCanceled() && it.hasNext()) {
692
							IFeature feat = it.next();
693
							IGeometry geom = feat.getGeometry();
694

  
695
							ISymbol sym = ((IVectorialLegend) fLyrVect
696
									.getLegend()).getSymbolByFeature(feat);
697
							if (sym instanceof IMultiLayerSymbol) {
698
								IMultiLayerSymbol mlSym = (IMultiLayerSymbol) sym;
699
								for (int i = 0; i < mlSym.getLayerCount(); i++) {
700
									ISymbol mySym = mlSym.getLayer(i);
701
									// System.out.println("drawing on level
702
									// "+zSort.getSymbolLevel(mySym));
703
									geom.drawInts(graphics[zSort
704
											.getSymbolLevel(mySym)], viewPort,
705
											mySym);
706
								}
707
							} else {
708
								geom.drawInts(graphics[zSort
709
										.getSymbolLevel(sym)], viewPort, sym);
710
							}
711
						}
712

  
713
						for (int i = 0; i < imageLevels.length; i++) {
714
							g.drawImage(imageLevels[i], 0, 0, null);
715
						}
716
					} else {
717

  
718
						while (!cancel.isCanceled() && it.hasNext()) {
719
							IFeature feat = it.next();
720
							ISymbol sym = ((IVectorialLegend) fLyrVect
721
									.getLegend()).getSymbolByFeature(feat);
722
							IGeometry geom = feat.getGeometry();
723

  
724
							geom.drawInts(g, viewPort, sym);
725
						}
726
					}
727
				} catch (ReadDriverException e) {
728

  
729
					throw e;
730
				} catch (ExpansionFileReadException e) {
731

  
732
					// throw new DriverException(e);
733
					// TODO throw a correct exception (??? ReadDriverException
734
					// ???)
735
					e.printStackTrace();
736
				}
737
			}
738

  
739
		}
740

  
741
	}
742

  
743
	public void newDraw() {
744
		FLyrVect fLyrVect = (FLyrVect) _layer;
745
		try {
746
			
747
//			String[] aux;
748
//			ArrayList fieldList = new ArrayList();
749
//			if (fLyrVect.isLabeled()) {
750
//				aux = fLyrVect.getLabelingStrategy().getUsedFields();
751
//				aux = fLyrVect.getLabelingStrategy().getPlacementConstraints().getLocationsFor(geom, labelShape, exclusionZone);
752
//				for (int i = 0; i < aux.length; i++) {
753
//					fieldList.add(aux[i]);
754
//				}
755
//			}
756

  
757
			IFeatureIterator it = fLyrVect.getSource().getFeatureIterator();
758
			try {
759
				while (it.hasNext()) {
760
					IFeature feat = it.next();
761
					ISymbol sym = ((IVectorialLegend) fLyrVect.getLegend())
762
							.getSymbolByFeature(feat);
763
					IGeometry geom = feat.getGeometry();
764
					
765
					SimpleTextSymbol text = new SimpleTextSymbol();
766
					text.setText("hola");
767
					
768
//					text.set
769
//					text.draw(g, affineTransform, shp)
770
//					FShape shp = fLyrVect.getLabelingStrategy().getLabelingMethod().getDefaultLabelClass().getShape(g, at, geom);
771
//					fLyrVect.getLabelingStrategy().getPlacementConstraints().getLocationsFor(geom, shp , null);
772

  
773
					// Si no hacemos esto no se reproyecta la capa
774
					ICoordTrans ct = fLyrVect.getCoordTrans();
775

  
776
					if (ct != null) {
777
						geom.reProject(ct);
778
					}
779

  
780
					int geomType = geom.getGeometryType();
781

  
782
					visitWithSymbol(geom, 0, sym);
783
				
784
				}
785
			} catch (ExpansionFileReadException e) {
786
				// TODO Auto-generated catch block
787
				e.printStackTrace();
788
			}
789

  
790
		} catch (ReadDriverException e) {
791
			// TODO Auto-generated catch block
792
			e.printStackTrace();
793
		}
794

  
795
	}
796
}
import/ext3D/branches/ext3D_v1.1/lib3DMap/src/com/iver/ai2/gvsig3d/resources/ResourcesFactory.java
1
package com.iver.ai2.gvsig3d.resources;
2

  
3
import java.io.File;
4

  
5
/**
6
 * @author julio
7
 * 
8
 * This class is a factory to find resources in 3D extensions
9
 * 
10
 */
11
public class ResourcesFactory {
12

  
13
	private static String textPath;
14

  
15
	private static String extPath;
16

  
17
	static {
18
		extPath = "/gvSIG/extensiones/com.iver.ai2.gvsig3dgui/resources/";
19

  
20
		textPath = System.getProperty("user.dir") + extPath;
21
	}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff