Revision 22628 trunk/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/import3D/ControlImport3D.java
ControlImport3D.java | ||
---|---|---|
3 | 3 |
import java.awt.BorderLayout; |
4 | 4 |
import java.awt.Component; |
5 | 5 |
import java.awt.GridLayout; |
6 |
import java.awt.Point; |
|
6 | 7 |
import java.awt.event.ActionEvent; |
7 | 8 |
import java.awt.event.ActionListener; |
9 |
import java.awt.event.MouseEvent; |
|
10 |
import java.awt.event.MouseListener; |
|
11 |
import java.awt.geom.Point2D; |
|
8 | 12 |
import java.io.File; |
13 |
import java.io.FileInputStream; |
|
14 |
import java.io.FileNotFoundException; |
|
9 | 15 |
import java.util.Hashtable; |
10 | 16 |
import java.util.Iterator; |
11 | 17 |
|
... | ... | |
18 | 24 |
import javax.swing.border.TitledBorder; |
19 | 25 |
import javax.swing.filechooser.FileFilter; |
20 | 26 |
|
27 |
import org.gvsig.driver.OSGDriver; |
|
28 |
import org.gvsig.geometries3D.MultiGeometry; |
|
29 |
import org.gvsig.gpe.osg.OSGParser; |
|
30 |
import org.gvsig.gui.beans.datainput.DataInputField; |
|
31 |
import org.gvsig.gvsig3d.cacheservices.OSGCacheService; |
|
32 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
|
33 |
import org.gvsig.gvsig3dgui.view.View3D; |
|
34 |
import org.gvsig.osgvp.Group; |
|
35 |
import org.gvsig.osgvp.Vec3; |
|
36 |
import org.gvsig.osgvp.viewer.Intersections; |
|
37 |
|
|
38 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
|
21 | 39 |
import com.iver.andami.PluginServices; |
22 | 40 |
import com.iver.andami.ui.mdiManager.IWindow; |
23 | 41 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
42 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
43 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
44 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
45 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
|
24 | 46 |
|
25 | 47 |
/** |
26 | 48 |
* DOCUMENT ME! |
27 | 49 |
* |
28 |
* @author
|
|
50 |
* @author |
|
29 | 51 |
*/ |
30 | 52 |
|
53 |
public class ControlImport3D extends JPanel implements IWindow, ActionListener, |
|
54 |
MouseListener { |
|
31 | 55 |
|
32 |
public class ControlImport3D extends JPanel implements IWindow, ActionListener{ |
|
33 |
|
|
34 |
|
|
35 | 56 |
private static final long serialVersionUID = 8557746972654979029L; |
36 | 57 |
private JPanel panelOpcionesObjeto; |
37 | 58 |
private TitledBorder borderOpcionesObjeto; |
38 | 59 |
private JLabel labelLatitud; |
39 |
private JTextField textLatitud;
|
|
60 |
private DataInputField textLatitud;
|
|
40 | 61 |
private JLabel labelLongitud; |
41 |
private JTextField textLongitud;
|
|
62 |
private DataInputField textLongitud;
|
|
42 | 63 |
private JLabel labelEscalado; |
43 |
private JTextField textEscalado;
|
|
64 |
private DataInputField textEscalado;
|
|
44 | 65 |
private JLabel labelRotacion; |
45 |
private JTextField textRotacion;
|
|
66 |
private DataInputField textRotacion;
|
|
46 | 67 |
private JPanel panelImportar; |
47 | 68 |
private TitledBorder borderImportar; |
48 | 69 |
private JButton buttonImportar; |
... | ... | |
50 | 71 |
private JTextField textFile; |
51 | 72 |
private TitledBorder border; |
52 | 73 |
private JPanel panelPath; |
53 |
|
|
54 |
private Hashtable cmsExtensionsSupported = null; |
|
55 |
private Hashtable jimiExtensionsSupported = null; |
|
74 |
private Hashtable iveExtensionsSupported = null; |
|
75 |
private Hashtable osgExtensionsSupported = null; |
|
56 | 76 |
private String lastPath = null; |
57 |
private File m_Fich; |
|
58 |
|
|
59 |
public ControlImport3D(int tipoObjeto){ |
|
60 |
|
|
77 |
private JLabel labelAltura; |
|
78 |
private DataInputField textAltura; |
|
79 |
private JPanel panelButtons; |
|
80 |
private JButton buttonAccept; |
|
81 |
private JButton buttonCancel; |
|
82 |
private JPanel panelAux; |
|
83 |
private JLabel labelX; |
|
84 |
private DataInputField textX; |
|
85 |
private JLabel labelY; |
|
86 |
private DataInputField textY; |
|
87 |
|
|
88 |
private View3D vista; |
|
89 |
private File fileOSG = null; |
|
90 |
private FileInputStream fileInput = null; |
|
91 |
private Vec3 position = new Vec3(0,0,0); |
|
92 |
|
|
93 |
public ControlImport3D(int tipoObjeto, View3D vista3D) { |
|
94 |
|
|
61 | 95 |
tipoObjectImport = tipoObjeto; |
62 |
this.panelOpcionesObjeto=new JPanel(); |
|
63 |
this.borderOpcionesObjeto=new TitledBorder(PluginServices.getText(this, "Opciones de objeto")); |
|
96 |
vista = vista3D; |
|
97 |
|
|
98 |
this.panelOpcionesObjeto = new JPanel(); |
|
99 |
this.borderOpcionesObjeto = new TitledBorder(PluginServices.getText( |
|
100 |
this, "Opciones de objeto")); |
|
64 | 101 |
this.panelOpcionesObjeto.setBorder(this.borderOpcionesObjeto); |
65 |
this.panelOpcionesObjeto.setLayout(new GridLayout(4, 3, 5, 5)); |
|
66 |
this.labelLatitud=new JLabel(PluginServices.getText(this,"Latitude"), JLabel.RIGHT); |
|
67 |
this.textLatitud=new JTextField(); |
|
68 |
this.labelLongitud=new JLabel(PluginServices.getText(this,"Longitude"), JLabel.RIGHT); |
|
69 |
this.textLongitud=new JTextField(); |
|
70 |
this.labelEscalado=new JLabel(PluginServices.getText(this,"Escalado"), JLabel.RIGHT); |
|
71 |
this.textEscalado=new JTextField(); |
|
72 |
this.labelRotacion=new JLabel(PluginServices.getText(this,"Rotation"), JLabel.RIGHT); |
|
73 |
this.textRotacion=new JTextField(); |
|
74 |
|
|
102 |
this.panelOpcionesObjeto.setLayout(new GridLayout(5, 4, 5, 5)); |
|
103 |
|
|
104 |
this.textLatitud = new DataInputField(); |
|
105 |
this.labelLatitud = new JLabel( |
|
106 |
PluginServices.getText(this, "Latitude"), JLabel.RIGHT); |
|
107 |
|
|
108 |
this.textLongitud = new DataInputField(); |
|
109 |
this.labelLongitud = new JLabel(PluginServices.getText(this, |
|
110 |
"Longitude"), JLabel.RIGHT); |
|
111 |
|
|
112 |
this.textEscalado = new DataInputField(); |
|
113 |
this.labelEscalado = new JLabel(PluginServices |
|
114 |
.getText(this, "Escalado"), JLabel.RIGHT); |
|
115 |
|
|
116 |
this.textRotacion = new DataInputField(); |
|
117 |
this.labelRotacion = new JLabel(PluginServices.getText(this, |
|
118 |
"Rotation_degrees"), JLabel.RIGHT); |
|
119 |
|
|
120 |
this.textAltura = new DataInputField(); |
|
121 |
this.labelAltura = new JLabel(PluginServices.getText(this, "Hight"), |
|
122 |
JLabel.RIGHT); |
|
123 |
|
|
124 |
this.textX = new DataInputField(); |
|
125 |
this.labelX = new JLabel(PluginServices.getText(this, "Coordenada X:"), |
|
126 |
JLabel.RIGHT); |
|
127 |
|
|
128 |
this.textY = new DataInputField(); |
|
129 |
this.labelY = new JLabel(PluginServices.getText(this, "Coordenada Y:"), |
|
130 |
JLabel.RIGHT); |
|
131 |
|
|
75 | 132 |
this.panelOpcionesObjeto.add(this.labelLatitud); |
76 | 133 |
this.panelOpcionesObjeto.add(this.textLatitud); |
77 |
this.panelOpcionesObjeto.add(new JPanel()); |
|
134 |
this.panelOpcionesObjeto.add(this.labelX); |
|
135 |
this.panelOpcionesObjeto.add(this.textX); |
|
136 |
|
|
78 | 137 |
this.panelOpcionesObjeto.add(this.labelLongitud); |
79 | 138 |
this.panelOpcionesObjeto.add(this.textLongitud); |
139 |
this.panelOpcionesObjeto.add(this.labelY); |
|
140 |
this.panelOpcionesObjeto.add(this.textY); |
|
141 |
|
|
142 |
this.panelOpcionesObjeto.add(this.labelAltura); |
|
143 |
this.panelOpcionesObjeto.add(this.textAltura); |
|
80 | 144 |
this.panelOpcionesObjeto.add(new JPanel()); |
145 |
this.panelOpcionesObjeto.add(new JPanel()); |
|
146 |
|
|
81 | 147 |
this.panelOpcionesObjeto.add(this.labelEscalado); |
82 | 148 |
this.panelOpcionesObjeto.add(this.textEscalado); |
83 | 149 |
this.panelOpcionesObjeto.add(new JPanel()); |
150 |
this.panelOpcionesObjeto.add(new JPanel()); |
|
151 |
|
|
84 | 152 |
this.panelOpcionesObjeto.add(this.labelRotacion); |
85 | 153 |
this.panelOpcionesObjeto.add(this.textRotacion); |
86 |
this.textLatitud.setHorizontalAlignment(JTextField.RIGHT); |
|
87 |
this.textLongitud.setHorizontalAlignment(JTextField.RIGHT); |
|
88 |
this.textRotacion.setHorizontalAlignment(JTextField.RIGHT); |
|
89 |
this.textEscalado.setHorizontalAlignment(JTextField.RIGHT); |
|
90 |
|
|
154 |
this.panelOpcionesObjeto.add(new JPanel()); |
|
155 |
this.panelOpcionesObjeto.add(new JPanel()); |
|
156 |
|
|
91 | 157 |
this.panelImportar = new JPanel(); |
92 |
this.borderImportar = new TitledBorder(PluginServices.getText(this,"File")); |
|
158 |
this.borderImportar = new TitledBorder(PluginServices.getText(this, |
|
159 |
"File")); |
|
93 | 160 |
this.panelImportar.setBorder(this.borderImportar); |
94 | 161 |
this.panelImportar.setLayout(new GridLayout(1, 1, 5, 5)); |
95 |
this.buttonImportar = new JButton(PluginServices.getText(this,"Examine")); |
|
162 |
this.buttonImportar = new JButton(PluginServices.getText(this, |
|
163 |
"Examine")); |
|
96 | 164 |
this.panelImportar.add(this.buttonImportar); |
97 | 165 |
this.buttonImportar.addActionListener(this); |
98 |
|
|
166 |
|
|
167 |
this.panelAux = new JPanel(); |
|
168 |
this.panelAux.setLayout(new BorderLayout(5, 5)); |
|
169 |
this.panelAux.add(this.panelOpcionesObjeto, BorderLayout.CENTER); |
|
170 |
this.panelAux.add(this.panelImportar, BorderLayout.SOUTH); |
|
171 |
|
|
99 | 172 |
this.panelPath = new JPanel(); |
100 |
this.border = new TitledBorder(PluginServices.getText(this,"Ruta_manual")); |
|
173 |
this.border = new TitledBorder(PluginServices.getText(this, |
|
174 |
"Ruta_manual")); |
|
101 | 175 |
this.panelPath.setBorder(this.border); |
102 | 176 |
this.panelPath.setLayout(new GridLayout(1, 1, 5, 5)); |
103 | 177 |
this.textFile = new JTextField(); |
104 | 178 |
this.panelPath.add(this.textFile); |
105 |
|
|
106 |
this.setLayout(new BorderLayout(5,5)); |
|
107 |
this.add(this.panelOpcionesObjeto, BorderLayout.NORTH); |
|
108 |
this.add(this.panelImportar, BorderLayout.CENTER); |
|
109 |
this.add(this.panelPath, BorderLayout.SOUTH); |
|
179 |
|
|
180 |
this.panelButtons = new JPanel(); |
|
181 |
this.panelButtons.setLayout(new GridLayout(1, 3, 5, 5)); |
|
182 |
this.buttonAccept = new JButton(PluginServices.getText(this, "Accept")); |
|
183 |
this.buttonAccept.addActionListener(this); |
|
184 |
this.buttonCancel = new JButton(PluginServices.getText(this, "Cancel")); |
|
185 |
this.buttonCancel.addActionListener(this); |
|
186 |
this.panelButtons.add(new JPanel()); |
|
187 |
this.panelButtons.add(this.buttonAccept); |
|
188 |
this.panelButtons.add(this.buttonCancel); |
|
189 |
|
|
190 |
this.setLayout(new BorderLayout(5, 5)); |
|
191 |
this.add(this.panelAux, BorderLayout.NORTH); |
|
192 |
this.add(this.panelPath, BorderLayout.CENTER); |
|
193 |
this.add(this.panelButtons, BorderLayout.SOUTH); |
|
194 |
|
|
195 |
vista.getCanvas3d().addMouseListener(this); |
|
196 |
|
|
110 | 197 |
} |
111 |
|
|
112 |
|
|
198 |
|
|
199 |
/* |
|
200 |
* Window properties |
|
201 |
* |
|
202 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo() |
|
203 |
*/ |
|
204 |
|
|
113 | 205 |
public WindowInfo getWindowInfo() { |
114 | 206 |
WindowInfo m_viewinfo = new WindowInfo(); |
115 | 207 |
String cad = null; |
116 |
if(tipoObjectImport == 0) |
|
208 |
// java.awt.Dimension minSize = new java.awt.Dimension(); |
|
209 |
// minSize.setSize(290, 400); |
|
210 |
|
|
211 |
if (tipoObjectImport == 0) |
|
117 | 212 |
cad = "Importar_Objeto_3D"; |
118 |
else if(tipoObjectImport == 1) |
|
213 |
else if (tipoObjectImport == 1)
|
|
119 | 214 |
cad = "Importar_Objeto_3D_GIS_vectorial"; |
120 |
|
|
215 |
|
|
121 | 216 |
m_viewinfo.setTitle(PluginServices.getText(this, cad)); |
122 |
m_viewinfo.setHeight(225); |
|
123 |
m_viewinfo.setWidth(450); |
|
217 |
m_viewinfo.setHeight(290); |
|
218 |
m_viewinfo.setWidth(410); |
|
219 |
// m_viewinfo.setMinimumSize(minSize); |
|
124 | 220 |
return m_viewinfo; |
125 | 221 |
} |
126 | 222 |
|
127 |
public void actionPerformed(ActionEvent e) { |
|
128 |
if(e.getSource()== this.buttonImportar){ |
|
129 |
JFileChooser jfc = new JFileChooser(lastPath); |
|
130 |
jfc.removeChoosableFileFilter(jfc.getAcceptAllFileFilter()); |
|
131 |
cmsExtensionsSupported = new Hashtable(); |
|
132 |
jimiExtensionsSupported = new Hashtable(); |
|
133 |
jimiExtensionsSupported.put("ive",new MyFileFilter("ive", |
|
134 |
PluginServices.getText(this, "Ficheros *.ive"), "ive")); |
|
135 |
cmsExtensionsSupported.put("osg", new MyFileFilter("osg", |
|
136 |
PluginServices.getText(this, "Ficheros *.osg"), "osg")); |
|
137 |
|
|
138 |
Iterator iter = cmsExtensionsSupported.values().iterator(); |
|
139 |
while (iter.hasNext()){ |
|
140 |
jfc.addChoosableFileFilter((FileFilter)iter.next()); |
|
223 |
/* |
|
224 |
* Buttons events listener |
|
225 |
*/ |
|
226 |
|
|
227 |
public void actionPerformed(ActionEvent event) { |
|
228 |
if (event.getSource() == this.buttonImportar) { |
|
229 |
actionPerformedImport(); |
|
230 |
|
|
231 |
} |
|
232 |
if (event.getSource() == this.buttonAccept) { |
|
233 |
actionPerformedAccept(); |
|
234 |
PluginServices.getMDIManager().closeWindow(this); |
|
235 |
|
|
236 |
} |
|
237 |
if (event.getSource() == this.buttonCancel) { |
|
238 |
PluginServices.getMDIManager().closeWindow(this); |
|
239 |
} |
|
240 |
} |
|
241 |
|
|
242 |
/* |
|
243 |
* Accept button listener |
|
244 |
*/ |
|
245 |
|
|
246 |
private void actionPerformedAccept() { |
|
247 |
|
|
248 |
String lat = getJTextFieldLatitud(); |
|
249 |
String lon = getJTextFieldLongitud(); |
|
250 |
String rot = getJTextFieldRotacion(); |
|
251 |
String higth = getJTextFieldAltura(); |
|
252 |
String scal = getJTextFieldEscalado(); |
|
253 |
|
|
254 |
if (fileOSG == null) {// of the user write the file |
|
255 |
// String fichManual = getJTextFieldFichero(); |
|
256 |
fileOSG = new File(getJTextFieldFichero()); |
|
257 |
try { |
|
258 |
fileInput = new FileInputStream(fileOSG); |
|
259 |
} catch (FileNotFoundException e) { |
|
260 |
e.printStackTrace(); |
|
141 | 261 |
} |
142 | 262 |
|
143 |
iter = jimiExtensionsSupported.values().iterator(); |
|
144 |
while (iter.hasNext()){ |
|
145 |
jfc.addChoosableFileFilter((FileFilter)iter.next()); |
|
263 |
} else { |
|
264 |
try { |
|
265 |
fileInput = new FileInputStream(fileOSG); |
|
266 |
} catch (FileNotFoundException e) { |
|
267 |
e.printStackTrace(); |
|
146 | 268 |
} |
147 |
|
|
148 |
if (jfc.showOpenDialog((Component) PluginServices.getMainFrame())== JFileChooser.APPROVE_OPTION){ |
|
149 |
|
|
150 |
com.iver.andami.ui.mdiManager.IWindow activeWindow = PluginServices |
|
151 |
.getMDIManager().getActiveWindow(); |
|
152 |
File f = jfc.getSelectedFile(); |
|
153 |
if (f.exists()){//file don't exists in the directory. |
|
154 |
|
|
155 |
MyFileFilter filter = (MyFileFilter)jfc.getFileFilter(); |
|
156 |
f = filter.normalizeExtension(f); |
|
157 |
f.getAbsolutePath(); |
|
158 |
|
|
159 |
} |
|
160 |
else { |
|
161 |
JOptionPane.showMessageDialog(null, "El fichero no existe.", |
|
162 |
"Fichero no encontrado", JOptionPane.WARNING_MESSAGE); |
|
163 |
return; |
|
164 |
} |
|
165 |
}//If aprove option. |
|
166 |
|
|
167 | 269 |
} |
270 |
|
|
271 |
OSGDriver _osgDriver = new OSGDriver(); |
|
272 |
OSGParser parser = new OSGParser("OSG", "OSG File Formats Parser"); |
|
273 |
parser.parse(_osgDriver, null, fileOSG.toURI()); |
|
274 |
MultiGeometry root = _osgDriver.getRootFeature(); |
|
275 |
Group rootGroup = new Group(); |
|
276 |
|
|
277 |
IProjectView model = vista.getModel(); |
|
278 |
MapContext mapContext = model.getMapContext(); |
|
279 |
FLayers layers = mapContext.getLayers(); |
|
280 |
FLayer[] actives = layers.getActives(); |
|
281 |
//Layer3DProps props3D = Layer3DProps.getLayer3DProps(actives[0]); |
|
282 |
if (actives.length == 1 |
|
283 |
&& Layer3DProps.getLayer3DProps(actives[0]).getType() == Layer3DProps.layer3DOSG) { |
|
284 |
OSGCacheService osgCache = (OSGCacheService) Layer3DProps.getLayer3DProps(actives[0]).getCacheService(); |
|
285 |
// Vec3 rotation = new Vec3(0, y, z); |
|
286 |
// Vec3 scale = new Vec3(x, y, z); |
|
287 |
osgCache.AddGeometryToLayer(root, position, null,null); |
|
288 |
//System.out.println("kjdfkjsdlkd"); |
|
289 |
} |
|
290 |
else |
|
291 |
JOptionPane.showMessageDialog(null, "Selecciona una capa editable OSG.", |
|
292 |
"Capa no selecionada o capa no v?lida", JOptionPane.WARNING_MESSAGE); |
|
293 |
|
|
168 | 294 |
} |
295 |
|
|
296 |
/* |
|
297 |
* Import file button listener |
|
298 |
*/ |
|
299 |
|
|
300 |
private void actionPerformedImport() { |
|
301 |
JFileChooser jfc = new JFileChooser(lastPath); |
|
302 |
jfc.removeChoosableFileFilter(jfc.getAcceptAllFileFilter()); |
|
303 |
iveExtensionsSupported = new Hashtable(); |
|
304 |
osgExtensionsSupported = new Hashtable(); |
|
305 |
iveExtensionsSupported.put("ive", new MyFileFilter("ive", |
|
306 |
PluginServices.getText(this, "Ficheros *.ive"), "ive")); |
|
307 |
osgExtensionsSupported.put("osg", new MyFileFilter("osg", |
|
308 |
PluginServices.getText(this, "Ficheros *.osg"), "osg")); |
|
309 |
|
|
310 |
Iterator iter = osgExtensionsSupported.values().iterator(); |
|
311 |
while (iter.hasNext()) { |
|
312 |
jfc.addChoosableFileFilter((FileFilter) iter.next()); |
|
313 |
} |
|
314 |
|
|
315 |
iter = iveExtensionsSupported.values().iterator(); |
|
316 |
while (iter.hasNext()) { |
|
317 |
jfc.addChoosableFileFilter((FileFilter) iter.next()); |
|
318 |
} |
|
319 |
|
|
320 |
if (jfc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
|
321 |
|
|
322 |
com.iver.andami.ui.mdiManager.IWindow activeWindow = PluginServices |
|
323 |
.getMDIManager().getActiveWindow(); |
|
324 |
fileOSG = jfc.getSelectedFile(); |
|
325 |
if (fileOSG.exists()) {// file don't exists in the directory. |
|
326 |
|
|
327 |
MyFileFilter filter = (MyFileFilter) jfc.getFileFilter(); |
|
328 |
fileOSG = filter.normalizeExtension(fileOSG); |
|
329 |
textFile.setText(fileOSG.getAbsolutePath()); |
|
330 |
} else { |
|
331 |
JOptionPane.showMessageDialog(null, "El fichero no existe.", |
|
332 |
"Fichero no encontrado", JOptionPane.WARNING_MESSAGE); |
|
333 |
return; |
|
334 |
} |
|
335 |
}// If aprove option. |
|
336 |
} |
|
337 |
|
|
338 |
/* |
|
339 |
* Getters of all TextFields values |
|
340 |
*/ |
|
341 |
|
|
342 |
public String getJTextFieldLatitud() { |
|
343 |
return textLatitud.getValue(); |
|
344 |
} |
|
345 |
|
|
346 |
public String getJTextFieldLongitud() { |
|
347 |
return textLongitud.getValue(); |
|
348 |
} |
|
349 |
|
|
350 |
public String getJTextFieldEscalado() { |
|
351 |
return textEscalado.getValue(); |
|
352 |
} |
|
353 |
|
|
354 |
public String getJTextFieldRotacion() { |
|
355 |
return textRotacion.getValue(); |
|
356 |
} |
|
357 |
|
|
358 |
public String getJTextFieldAltura() { |
|
359 |
return textAltura.getValue(); |
|
360 |
} |
|
361 |
|
|
362 |
public String getJTextFieldFichero() { |
|
363 |
return textFile.getText(); |
|
364 |
} |
|
365 |
|
|
366 |
/* |
|
367 |
* All MouseListener methods |
|
368 |
* |
|
369 |
*/ |
|
370 |
public void mouseClicked(MouseEvent e) { |
|
371 |
// TODO Auto-generated method stub |
|
372 |
} |
|
373 |
|
|
374 |
public void mouseEntered(MouseEvent e) { |
|
375 |
// TODO Auto-generated method stub |
|
376 |
|
|
377 |
} |
|
378 |
|
|
379 |
public void mouseExited(MouseEvent e) { |
|
380 |
// TODO Auto-generated method stub |
|
381 |
|
|
382 |
} |
|
383 |
|
|
384 |
public void mousePressed(MouseEvent e) { |
|
385 |
// TODO Auto-generated method stub |
|
386 |
} |
|
387 |
|
|
388 |
public void mouseReleased(MouseEvent e) { |
|
389 |
|
|
390 |
Point pScreen = e.getPoint(); |
|
391 |
|
|
392 |
if (e.getButton() == MouseEvent.BUTTON1) { |
|
393 |
Vec3 intersection = null; |
|
394 |
|
|
395 |
// System.err.println("Coordenadas de pantalla " + pScreen.getX() + |
|
396 |
// ","+ |
|
397 |
// pScreen.getY()); |
|
398 |
|
|
399 |
textX.setValue(Double.toString(pScreen.getX())); |
|
400 |
textY.setValue(Double.toString(pScreen.getY())); |
|
401 |
|
|
402 |
IProjectView model = vista.getModel(); |
|
403 |
|
|
404 |
MapContext3D mcontext = (MapContext3D) model.getMapContext(); |
|
405 |
mcontext.getCanvas3d(); |
|
406 |
|
|
407 |
Intersections hits = mcontext.getCanvas3d().getOSGViewer().rayPick( |
|
408 |
(int) pScreen.getX(), (int) pScreen.getY()); |
|
409 |
Point2D pWorld = new Point2D.Double(); |
|
410 |
if (hits.containsIntersections()) { |
|
411 |
Vec3 hit = hits.getFirstIntersection().getIntersectionPoint(); |
|
412 |
// convert to geo coordinates |
|
413 |
position = hit; |
|
414 |
// System.err.println("Interseccion de osg " + hit.x() + ","+ |
|
415 |
// hit.y()); |
|
416 |
if (mcontext.getProjection().getAbrev().compareToIgnoreCase( |
|
417 |
"EPSG:4326") == 0) { |
|
418 |
Vec3 geoPt = mcontext.getPlanet() |
|
419 |
.convertXYZToLatLongHeight(hit); |
|
420 |
// Swap the coordinates X and Y, because they are invert. |
|
421 |
intersection = new Vec3(geoPt.y(), geoPt.x(), geoPt.z()); |
|
422 |
} else { |
|
423 |
intersection = hit; |
|
424 |
} |
|
425 |
} else { |
|
426 |
if (mcontext.getProjection().getAbrev().compareToIgnoreCase( |
|
427 |
"EPSG:4326") == 0) { |
|
428 |
pWorld.setLocation(360, 120); |
|
429 |
intersection = new Vec3(360, 120, 0); |
|
430 |
} else { |
|
431 |
intersection = new Vec3(1e100, 1e100, 0); |
|
432 |
// pWorld.setLocation(1e100, 1e100); |
|
433 |
} |
|
434 |
} |
|
435 |
|
|
436 |
textLatitud.setValue(Double.toString(intersection.x())); |
|
437 |
textLongitud.setValue(Double.toString(intersection.y())); |
|
438 |
textAltura.setValue(Double.toString(intersection.z())); |
|
439 |
|
|
440 |
}// if e.getButton() |
|
441 |
}// if hits |
|
169 | 442 |
} |
170 | 443 |
|
171 | 444 |
/** |
172 |
*
|
|
173 |
* @version 14/08/2007 |
|
174 |
* @author Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
175 |
*
|
|
176 |
*/ |
|
177 |
class MyFileFilter extends FileFilter{ |
|
445 |
*
|
|
446 |
* @version 14/08/2007
|
|
447 |
* @author Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
|
448 |
*
|
|
449 |
*/
|
|
450 |
class MyFileFilter extends FileFilter {
|
|
178 | 451 |
|
179 |
private String[] extensiones=new String[1];
|
|
452 |
private String[] extensiones = new String[1];
|
|
180 | 453 |
private String description; |
181 | 454 |
private boolean dirs = true; |
182 |
private String info= null; |
|
455 |
private String info = null;
|
|
183 | 456 |
|
184 | 457 |
public MyFileFilter(String[] ext, String desc) { |
185 | 458 |
extensiones = ext; |
186 | 459 |
description = desc; |
187 | 460 |
} |
188 | 461 |
|
189 |
public MyFileFilter(String[] ext, String desc,String info) { |
|
462 |
public MyFileFilter(String[] ext, String desc, String info) {
|
|
190 | 463 |
extensiones = ext; |
191 | 464 |
description = desc; |
192 | 465 |
this.info = info; |
... | ... | |
197 | 470 |
description = desc; |
198 | 471 |
} |
199 | 472 |
|
200 |
public MyFileFilter(String ext, String desc,String info) { |
|
473 |
public MyFileFilter(String ext, String desc, String info) {
|
|
201 | 474 |
extensiones[0] = ext; |
202 | 475 |
description = desc; |
203 | 476 |
this.info = info; |
... | ... | |
209 | 482 |
this.dirs = dirs; |
210 | 483 |
} |
211 | 484 |
|
212 |
public MyFileFilter(String ext, String desc, boolean dirs,String info) { |
|
485 |
public MyFileFilter(String ext, String desc, boolean dirs, String info) {
|
|
213 | 486 |
extensiones[0] = ext; |
214 | 487 |
description = desc; |
215 | 488 |
this.dirs = dirs; |
... | ... | |
224 | 497 |
return false; |
225 | 498 |
} |
226 | 499 |
} |
227 |
for (int i=0;i<extensiones.length;i++){
|
|
228 |
if (extensiones[i].equals("")){ |
|
500 |
for (int i = 0; i < extensiones.length; i++) {
|
|
501 |
if (extensiones[i].equals("")) {
|
|
229 | 502 |
continue; |
230 | 503 |
} |
231 |
if (getExtensionOfAFile(f).equalsIgnoreCase(extensiones[i])){ |
|
504 |
if (getExtensionOfAFile(f).equalsIgnoreCase(extensiones[i])) {
|
|
232 | 505 |
return true; |
233 | 506 |
} |
234 | 507 |
} |
... | ... | |
247 | 520 |
return extensiones; |
248 | 521 |
} |
249 | 522 |
|
250 |
public boolean isDirectory(){ |
|
523 |
public boolean isDirectory() {
|
|
251 | 524 |
return dirs; |
252 | 525 |
} |
253 | 526 |
|
254 |
private String getExtensionOfAFile(File file){ |
|
527 |
private String getExtensionOfAFile(File file) {
|
|
255 | 528 |
String name; |
256 | 529 |
int dotPos; |
257 | 530 |
name = file.getName(); |
258 | 531 |
dotPos = name.lastIndexOf("."); |
259 |
if (dotPos < 1){ |
|
532 |
if (dotPos < 1) {
|
|
260 | 533 |
return ""; |
261 | 534 |
} |
262 |
return name.substring(dotPos+1);
|
|
535 |
return name.substring(dotPos + 1);
|
|
263 | 536 |
} |
264 | 537 |
|
265 |
public File normalizeExtension(File file){ |
|
538 |
public File normalizeExtension(File file) {
|
|
266 | 539 |
String ext = getExtensionOfAFile(file); |
267 |
if (ext.equals("") || !(this.accept(file))){ |
|
540 |
if (ext.equals("") || !(this.accept(file))) {
|
|
268 | 541 |
return new File(file.getAbsolutePath() + "." + extensiones[0]); |
269 | 542 |
} |
270 | 543 |
return file; |
271 | 544 |
} |
272 | 545 |
|
273 |
public String getInfo(){ |
|
546 |
public String getInfo() {
|
|
274 | 547 |
return this.info; |
275 | 548 |
} |
276 | 549 |
|
277 |
public void setInfo(String info){ |
|
550 |
public void setInfo(String info) {
|
|
278 | 551 |
this.info = info; |
279 | 552 |
} |
280 | 553 |
|
Also available in: Unified diff