Revision 32623 branches/gvSIG_19_ext3D_osgVP_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/import3D/CreateNewLayerOSG.java
CreateNewLayerOSG.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.gvsig.gvsig3dgui.import3D; |
21 | 21 |
|
22 |
import java.awt.Component; |
|
23 | 22 |
import java.io.File; |
24 |
import java.util.Hashtable; |
|
25 |
import java.util.Iterator; |
|
26 | 23 |
|
27 |
import javax.swing.JFileChooser; |
|
28 |
import javax.swing.JOptionPane; |
|
29 |
import javax.swing.filechooser.FileFilter; |
|
30 |
|
|
31 |
import org.gvsig.gvsig3d.cacheservices.OSGCacheService; |
|
32 |
import org.gvsig.gvsig3d.drivers.GvsigDriverOSG; |
|
33 | 24 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
34 | 25 |
import org.gvsig.gvsig3dgui.view.View3D; |
35 | 26 |
|
36 |
import com.hardcode.gdbms.driver.exceptions.OpenDriverException; |
|
37 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
38 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
|
39 | 27 |
import com.iver.andami.PluginServices; |
40 | 28 |
import com.iver.andami.plugins.Extension; |
41 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
42 |
import com.iver.cit.gvsig.exceptions.layers.LegendLayerException; |
|
43 |
|
|
44 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
45 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
|
46 |
import com.iver.cit.gvsig.fmap.layers.VectorialFileAdapter; |
|
47 |
import com.iver.cit.gvsig.fmap.rendering.IVectorLegend; |
|
48 | 29 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
49 | 30 |
|
50 | 31 |
/** |
... | ... | |
53 | 34 |
* |
54 | 35 |
*/ |
55 | 36 |
public class CreateNewLayerOSG extends Extension { |
56 |
protected FLyrVect _layerOSG; |
|
37 |
|
|
57 | 38 |
private File _file = null; |
58 | 39 |
|
59 | 40 |
/** |
... | ... | |
65 | 46 |
.getMDIManager().getActiveWindow(); |
66 | 47 |
|
67 | 48 |
if (activeWindow instanceof View3D) { |
68 |
PluginServices.getMDIManager().addCentredWindow(new CreateNewLayerOSGPanel()); |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
if(actionCommand.equals("GUARDARCAPA")) { |
|
73 |
com.iver.andami.ui.mdiManager.IWindow activeWindow = PluginServices |
|
74 |
.getMDIManager().getActiveWindow(); |
|
75 |
|
|
76 |
if (activeWindow instanceof View3D) { |
|
77 |
if(_file == null) return; |
|
78 |
|
|
79 |
GvsigDriverOSG d = new GvsigDriverOSG(); |
|
80 |
try { |
|
81 |
d.open(_file); |
|
82 |
} catch (OpenDriverException e2) { |
|
83 |
// TODO Auto-generated catch block |
|
84 |
e2.printStackTrace(); |
|
85 |
} |
|
86 |
try { |
|
87 |
d.initialize(); |
|
88 |
} catch (ReadDriverException e1) { |
|
89 |
// TODO Auto-generated catch block |
|
90 |
e1.printStackTrace(); |
|
91 |
} |
|
92 |
|
|
93 |
VectorialAdapter adapter = new VectorialFileAdapter(_file); |
|
94 |
adapter.setDriver(d); |
|
95 |
|
|
96 |
_layerOSG = new FLyrVect(); |
|
97 |
|
|
98 |
View3D vista = (View3D) PluginServices.getMDIManager().getActiveWindow(); |
|
49 |
View3D vista = (View3D) activeWindow; |
|
99 | 50 |
IProjectView model = vista.getModel(); |
100 | 51 |
|
101 | 52 |
MapContext3D mapa = (MapContext3D) model.getMapContext(); |
102 |
_layerOSG.setName(_file.getName()); |
|
103 |
_layerOSG.setSource(adapter); |
|
104 |
try { |
|
105 |
_layerOSG.setLegend((IVectorLegend) d.getDefaultLegend()); |
|
106 |
_layerOSG.setLabelingStrategy(d |
|
107 |
.getDefaultLabelingStrategy()); |
|
108 |
} catch (LegendLayerException e) { |
|
109 |
// TODO Auto-generated catch block |
|
110 |
e.printStackTrace(); |
|
111 |
} |
|
112 |
|
|
113 |
// add 3D properties, mainly to keep track of hooked state |
|
114 |
Layer3DProps props3D = new Layer3DProps(); |
|
115 |
props3D.setType(Layer3DProps.layer3DOSG); |
|
116 |
props3D.setChooseType(false); |
|
117 |
props3D.setLayer(_layerOSG); |
|
118 |
props3D.setNewLayerOSG(true); |
|
119 |
_layerOSG.setProperty("3DLayerExtension", props3D); |
|
120 |
_layerOSG.setProjection(mapa.getProjection()); |
|
121 |
mapa.getLayers().addLayer(_layerOSG); |
|
122 |
OSGCacheService osgCacheService = (OSGCacheService) props3D |
|
123 |
.getCacheService(); |
|
124 |
//osgCacheService.startEditing(); |
|
53 |
PluginServices.getMDIManager().addCentredWindow(new CreateNewLayerOSGPanel(mapa)); |
|
125 | 54 |
} |
55 |
|
|
56 |
return; |
|
126 | 57 |
} |
127 | 58 |
} |
128 | 59 |
|
Also available in: Unified diff