gvsig-3d / 2.0 / trunk / org.gvsig.gvsig3d.app / org.gvsig.gvsig3d.app.extension / src / main / java / org / gvsig / gvsig3d / app / multiresolution / MultiResolutionTool.java @ 346
History | View | Annotate | Download (20.6 KB)
1 |
package org.gvsig.gvsig3d.app.multiresolution; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Cursor; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.GridBagConstraints; |
7 |
import java.awt.GridBagLayout; |
8 |
import java.awt.Insets; |
9 |
import java.awt.event.ActionEvent; |
10 |
import java.awt.event.ActionListener; |
11 |
import java.io.File; |
12 |
|
13 |
import javax.swing.JButton; |
14 |
import javax.swing.JCheckBox; |
15 |
import javax.swing.JFileChooser; |
16 |
import javax.swing.JLabel; |
17 |
import javax.swing.JOptionPane; |
18 |
import javax.swing.JPanel; |
19 |
import javax.swing.JProgressBar; |
20 |
import javax.swing.JSpinner; |
21 |
import javax.swing.JTextField; |
22 |
import javax.swing.SwingConstants; |
23 |
import javax.swing.border.EmptyBorder; |
24 |
import javax.swing.filechooser.FileFilter; |
25 |
|
26 |
import org.gvsig.andami.PluginServices; |
27 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
28 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
29 |
import org.gvsig.app.project.documents.view.ViewDocument; |
30 |
import org.gvsig.fmap.dal.DALLocator; |
31 |
import org.gvsig.fmap.dal.DataManager; |
32 |
import org.gvsig.fmap.dal.DataStore; |
33 |
import org.gvsig.fmap.dal.DataStoreParameters; |
34 |
import org.gvsig.fmap.dal.exception.InitializeException; |
35 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
36 |
import org.gvsig.fmap.dal.exception.ReadException; |
37 |
import org.gvsig.fmap.dal.store.shp.SHPStoreParameters; |
38 |
import org.gvsig.fmap.dal.store.shp.SHPStoreProvider; |
39 |
import org.gvsig.fmap.geom.Geometry; |
40 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
41 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
42 |
import org.gvsig.fmap.mapcontext.ViewPort; |
43 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
44 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
45 |
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer; |
46 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
47 |
import org.gvsig.fmap.mapcontext.rendering.legend.ISingleSymbolLegend; |
48 |
import org.gvsig.gvsig3d.app.extension.DefaultView3DDocument; |
49 |
import org.gvsig.gvsig3d.impl.symbology3d.marker.impl.SimpleMarker3DSymbol; |
50 |
import org.gvsig.gvsig3d.map3d.Layer3DProps; |
51 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
52 |
import org.gvsig.gvsig3d.osg.io.OSGStoreParameters; |
53 |
import org.gvsig.gvsig3d.osg.io.OSGStoreProvider; |
54 |
import org.gvsig.gvsig3d.symbology3d.I3DSymbol; |
55 |
import org.gvsig.osgvp.geometry.GeoPointArray3D; |
56 |
import org.gvsig.osgvp.multiresolution.PointTreeBuilderOperator; |
57 |
import org.gvsig.osgvp.terrain.Terrain; |
58 |
import org.gvsig.tools.task.Cancellable; |
59 |
|
60 |
public class MultiResolutionTool extends JPanel implements IWindow { |
61 |
|
62 |
/**
|
63 |
*
|
64 |
*/
|
65 |
private static final long serialVersionUID = -4840130277321843108L; |
66 |
private final JPanel contentPanel = new JPanel(); |
67 |
private JTextField textField; |
68 |
private JTextField textField_2; |
69 |
|
70 |
// private Task _task;
|
71 |
private DefaultView3DDocument _view3D;
|
72 |
private JButton buttonInput; |
73 |
private JCheckBox _useLayerCheck; |
74 |
private JButton _okButton; |
75 |
private boolean _inputReady = false; |
76 |
private boolean _outputReady = false; |
77 |
private JProgressBar _progressBar; |
78 |
private FLayer _layer;
|
79 |
|
80 |
/**
|
81 |
* Create the dialog.
|
82 |
*/
|
83 |
public MultiResolutionTool(ViewDocument v) {
|
84 |
|
85 |
_view3D = (DefaultView3DDocument) v; |
86 |
MapContext3D mapa = (MapContext3D) v.getMapContext(); |
87 |
FLayer[] activeLayers = mapa.getLayers().getActives();
|
88 |
if (activeLayers.length > 0) |
89 |
_layer = activeLayers[0];
|
90 |
|
91 |
setBounds(100, 100, 390, 110); |
92 |
BorderLayout borderLayout = new BorderLayout(); |
93 |
borderLayout.setVgap(5);
|
94 |
borderLayout.setHgap(5);
|
95 |
this.setLayout(borderLayout);
|
96 |
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); |
97 |
this.add(contentPanel, BorderLayout.NORTH); |
98 |
GridBagLayout gbl_contentPanel = new GridBagLayout(); |
99 |
gbl_contentPanel.columnWidths = new int[] { 0 }; |
100 |
gbl_contentPanel.rowHeights = new int[] { 30, 30, 30 }; |
101 |
gbl_contentPanel.columnWeights = new double[] { 1.0 }; |
102 |
gbl_contentPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE, 1.0 }; |
103 |
contentPanel.setLayout(gbl_contentPanel); |
104 |
// Fila con el input file
|
105 |
{ |
106 |
JPanel panel = new JPanel(); |
107 |
GridBagConstraints gbc_panel = new GridBagConstraints(); |
108 |
gbc_panel.anchor = GridBagConstraints.WEST;
|
109 |
gbc_panel.insets = new Insets(0, 0, 5, 0); |
110 |
gbc_panel.gridx = 0;
|
111 |
gbc_panel.gridy = 0;
|
112 |
contentPanel.add(panel, gbc_panel); |
113 |
GridBagLayout gbl_panel = new GridBagLayout(); |
114 |
gbl_panel.columnWidths = new int[] { 100, 180, 100, 50 }; |
115 |
gbl_panel.rowHeights = new int[] { 0 }; |
116 |
gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, |
117 |
Double.MIN_VALUE };
|
118 |
gbl_panel.rowWeights = new double[] { Double.MIN_VALUE }; |
119 |
panel.setLayout(gbl_panel); |
120 |
{ |
121 |
JLabel lblNewLabel = new JLabel("Input: "); |
122 |
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); |
123 |
gbc_lblNewLabel.fill = GridBagConstraints.HORIZONTAL;
|
124 |
gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
|
125 |
gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5); |
126 |
gbc_lblNewLabel.gridx = 0;
|
127 |
gbc_lblNewLabel.gridy = 0;
|
128 |
panel.add(lblNewLabel, gbc_lblNewLabel); |
129 |
} |
130 |
{ |
131 |
textField = new JTextField(); |
132 |
textField.setEditable(false);
|
133 |
textField.setHorizontalAlignment(SwingConstants.CENTER);
|
134 |
GridBagConstraints gbc_textField = new GridBagConstraints(); |
135 |
gbc_textField.fill = GridBagConstraints.BOTH;
|
136 |
gbc_textField.anchor = GridBagConstraints.WEST;
|
137 |
gbc_textField.insets = new Insets(0, 0, 5, 0); |
138 |
gbc_textField.gridx = 1;
|
139 |
gbc_textField.gridy = 0;
|
140 |
panel.add(textField, gbc_textField); |
141 |
textField.setColumns(10);
|
142 |
} |
143 |
{ |
144 |
buttonInput = new JButton("Browse"); |
145 |
GridBagConstraints gbc_btnNewButton = new GridBagConstraints(); |
146 |
gbc_btnNewButton.fill = GridBagConstraints.VERTICAL;
|
147 |
gbc_btnNewButton.insets = new Insets(0, 0, 0, 5); |
148 |
gbc_btnNewButton.gridx = 2;
|
149 |
gbc_btnNewButton.gridy = 0;
|
150 |
panel.add(buttonInput, gbc_btnNewButton); |
151 |
buttonInput.addActionListener(new ActionListener() { |
152 |
public void actionPerformed(ActionEvent e) { |
153 |
|
154 |
JFileChooser fc = new JFileChooser(); |
155 |
FileFilter ff = new TypeFileFilter(); |
156 |
fc.setFileFilter(ff); |
157 |
|
158 |
int returnVal = fc
|
159 |
.showOpenDialog(MultiResolutionTool.this); |
160 |
|
161 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
162 |
File file = fc.getSelectedFile();
|
163 |
if (file.exists() && isProcessable(file)) {
|
164 |
textField.setText(file.getAbsolutePath()); |
165 |
_inputReady = true;
|
166 |
if (_outputReady)
|
167 |
_okButton.setEnabled(true);
|
168 |
else
|
169 |
_okButton.setEnabled(false);
|
170 |
} else {
|
171 |
|
172 |
JOptionPane.showMessageDialog(MultiResolutionTool.this, "File incompatible"); |
173 |
System.out.println("CAPA INCOMPATIBLE"); |
174 |
|
175 |
} |
176 |
|
177 |
} else {
|
178 |
|
179 |
} |
180 |
} |
181 |
}); |
182 |
} |
183 |
} |
184 |
|
185 |
// fila con el output file
|
186 |
{ |
187 |
JPanel panel = new JPanel(); |
188 |
GridBagConstraints gbc_panel = new GridBagConstraints(); |
189 |
gbc_panel.anchor = GridBagConstraints.WEST;
|
190 |
gbc_panel.insets = new Insets(0, 0, 5, 0); |
191 |
gbc_panel.gridx = 0;
|
192 |
gbc_panel.gridy = 1;
|
193 |
contentPanel.add(panel, gbc_panel); |
194 |
GridBagLayout gbl_panel = new GridBagLayout(); |
195 |
gbl_panel.columnWidths = new int[] { 100, 180, 100, 50 }; |
196 |
gbl_panel.rowHeights = new int[] { 0 }; |
197 |
gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, |
198 |
Double.MIN_VALUE };
|
199 |
gbl_panel.rowWeights = new double[] { Double.MIN_VALUE }; |
200 |
panel.setLayout(gbl_panel); |
201 |
{ |
202 |
JLabel lblNewLabel = new JLabel("Output: "); |
203 |
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); |
204 |
gbc_lblNewLabel.fill = GridBagConstraints.HORIZONTAL;
|
205 |
gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
|
206 |
gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5); |
207 |
gbc_lblNewLabel.gridx = 0;
|
208 |
gbc_lblNewLabel.gridy = 0;
|
209 |
panel.add(lblNewLabel, gbc_lblNewLabel); |
210 |
} |
211 |
{ |
212 |
textField_2 = new JTextField(); |
213 |
textField_2.setEditable(false);
|
214 |
textField_2.setHorizontalAlignment(SwingConstants.CENTER);
|
215 |
GridBagConstraints gbc_textField = new GridBagConstraints(); |
216 |
gbc_textField.fill = GridBagConstraints.BOTH;
|
217 |
gbc_textField.anchor = GridBagConstraints.WEST;
|
218 |
gbc_textField.insets = new Insets(0, 0, 5, 0); |
219 |
gbc_textField.gridx = 1;
|
220 |
gbc_textField.gridy = 0;
|
221 |
panel.add(textField_2, gbc_textField); |
222 |
textField_2.setColumns(10);
|
223 |
} |
224 |
{ |
225 |
JButton btnNewButton = new JButton("Browse"); |
226 |
GridBagConstraints gbc_btnNewButton = new GridBagConstraints(); |
227 |
gbc_btnNewButton.fill = GridBagConstraints.VERTICAL;
|
228 |
gbc_btnNewButton.insets = new Insets(0, 0, 0, 5); |
229 |
gbc_btnNewButton.gridx = 2;
|
230 |
gbc_btnNewButton.gridy = 0;
|
231 |
panel.add(btnNewButton, gbc_btnNewButton); |
232 |
btnNewButton.addActionListener(new ActionListener() { |
233 |
public void actionPerformed(ActionEvent e) { |
234 |
|
235 |
JFileChooser fc = new JFileChooser(); |
236 |
FileFilter ff = new TypeFileFilter(); |
237 |
fc.setFileFilter(ff); |
238 |
|
239 |
int returnVal = fc
|
240 |
.showSaveDialog(MultiResolutionTool.this); |
241 |
|
242 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
243 |
File file = fc.getSelectedFile();
|
244 |
|
245 |
textField_2.setText(file.getAbsolutePath()); |
246 |
_outputReady = true;
|
247 |
if (_inputReady)
|
248 |
_okButton.setEnabled(true);
|
249 |
|
250 |
else
|
251 |
_okButton.setEnabled(false);
|
252 |
|
253 |
} |
254 |
} |
255 |
}); |
256 |
} |
257 |
} |
258 |
// Niveles y hojas spinners
|
259 |
{ |
260 |
JPanel panel = new JPanel(); |
261 |
GridBagConstraints gbc_panel = new GridBagConstraints(); |
262 |
gbc_panel.fill = GridBagConstraints.BOTH;
|
263 |
gbc_panel.gridx = 0;
|
264 |
gbc_panel.gridy = 2;
|
265 |
contentPanel.add(panel, gbc_panel); |
266 |
GridBagLayout gbl_panel = new GridBagLayout(); |
267 |
gbl_panel.columnWidths = new int[] { 60, 50, 60, 40, 140 }; |
268 |
gbl_panel.rowHeights = new int[] { 0 }; |
269 |
gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, |
270 |
Double.MIN_VALUE };
|
271 |
gbl_panel.rowWeights = new double[] { Double.MIN_VALUE }; |
272 |
panel.setLayout(gbl_panel); |
273 |
{ |
274 |
JLabel lblNewLabel_1 = new JLabel("Levels:"); |
275 |
GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints(); |
276 |
gbc_lblNewLabel_1.fill = GridBagConstraints.BOTH;
|
277 |
gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5); |
278 |
gbc_lblNewLabel_1.gridx = 0;
|
279 |
gbc_lblNewLabel_1.gridy = 0;
|
280 |
panel.add(lblNewLabel_1, gbc_lblNewLabel_1); |
281 |
} |
282 |
{ |
283 |
JSpinner spinner = new JSpinner(); |
284 |
GridBagConstraints gbc_spinner = new GridBagConstraints(); |
285 |
gbc_spinner.fill = GridBagConstraints.BOTH;
|
286 |
gbc_spinner.insets = new Insets(0, 0, 5, 5); |
287 |
gbc_spinner.anchor = GridBagConstraints.NORTHWEST;
|
288 |
gbc_spinner.gridx = 1;
|
289 |
gbc_spinner.gridy = 0;
|
290 |
spinner.setValue(20);
|
291 |
panel.add(spinner, gbc_spinner); |
292 |
} |
293 |
{ |
294 |
JLabel lblNewLabel_1 = new JLabel("Leaf nodes:"); |
295 |
GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints(); |
296 |
gbc_lblNewLabel_1.fill = GridBagConstraints.BOTH;
|
297 |
gbc_lblNewLabel_1.anchor = GridBagConstraints.WEST;
|
298 |
gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5); |
299 |
gbc_lblNewLabel_1.gridx = 2;
|
300 |
gbc_lblNewLabel_1.gridy = 0;
|
301 |
panel.add(lblNewLabel_1, gbc_lblNewLabel_1); |
302 |
} |
303 |
{ |
304 |
JSpinner spinner = new JSpinner(); |
305 |
GridBagConstraints gbc_spinner = new GridBagConstraints(); |
306 |
gbc_spinner.fill = GridBagConstraints.BOTH;
|
307 |
gbc_spinner.anchor = GridBagConstraints.WEST;
|
308 |
gbc_spinner.insets = new Insets(0, 0, 5, 5); |
309 |
gbc_spinner.gridx = 3;
|
310 |
gbc_spinner.gridy = 0;
|
311 |
spinner.setValue(100);
|
312 |
panel.add(spinner, gbc_spinner); |
313 |
} |
314 |
// Panel para el progressbar
|
315 |
{ |
316 |
JPanel panel_1 = new JPanel(); |
317 |
GridBagConstraints gbc_panel_1 = new GridBagConstraints(); |
318 |
gbc_panel_1.insets = new Insets(0, 0, 5, 5); |
319 |
gbc_panel_1.fill = GridBagConstraints.BOTH;
|
320 |
gbc_panel_1.gridx = 4;
|
321 |
gbc_panel_1.gridy = 0;
|
322 |
panel.add(panel_1, gbc_panel_1); |
323 |
|
324 |
panel_1.setLayout(new BorderLayout(0, 0)); |
325 |
{ |
326 |
_useLayerCheck = new JCheckBox("Use active layer"); |
327 |
panel_1.add(_useLayerCheck, BorderLayout.WEST);
|
328 |
if (_layer == null || !(_layer instanceof FLyrVect) |
329 |
|| !isProcessable((FLyrVect) _layer)) |
330 |
_useLayerCheck.setEnabled(false);
|
331 |
_useLayerCheck.addActionListener(new ActionListener() { |
332 |
|
333 |
public void actionPerformed(ActionEvent arg0) { |
334 |
|
335 |
System.out.println("Cambiado el checkbox"); |
336 |
if (_useLayerCheck.isSelected()) {
|
337 |
buttonInput.setEnabled(false);
|
338 |
_inputReady = true;
|
339 |
} else {
|
340 |
buttonInput.setEnabled(true);
|
341 |
} |
342 |
} |
343 |
|
344 |
}); |
345 |
_useLayerCheck.setHorizontalAlignment(SwingConstants.LEFT);
|
346 |
} |
347 |
} |
348 |
} |
349 |
|
350 |
// Botones aceptar y cancelar
|
351 |
{ |
352 |
JPanel buttonPane = new JPanel(); |
353 |
this.add(buttonPane, BorderLayout.CENTER); |
354 |
GridBagLayout gbl_buttonPane = new GridBagLayout(); |
355 |
gbl_buttonPane.columnWidths = new int[] { 210, 80, 80 }; |
356 |
gbl_buttonPane.rowHeights = new int[] { 0 }; |
357 |
gbl_buttonPane.columnWeights = new double[] { 0.0, 0.0, |
358 |
Double.MIN_VALUE };
|
359 |
gbl_buttonPane.rowWeights = new double[] { Double.MIN_VALUE }; |
360 |
buttonPane.setLayout(gbl_buttonPane); |
361 |
// Where the GUI is constructed:
|
362 |
_progressBar = new JProgressBar(0, 100); |
363 |
GridBagConstraints gbc__progressBar = new GridBagConstraints(); |
364 |
gbc__progressBar.ipady = 5;
|
365 |
gbc__progressBar.insets = new Insets(0, 0, 0, 5); |
366 |
gbc__progressBar.gridx = 0;
|
367 |
gbc__progressBar.gridy = 0;
|
368 |
buttonPane.add(_progressBar, gbc__progressBar); |
369 |
_progressBar.setValue(0);
|
370 |
_progressBar.setStringPainted(true);
|
371 |
_progressBar.setVisible(false);
|
372 |
{ |
373 |
_okButton = new JButton("Process"); |
374 |
_okButton.setActionCommand("OK");
|
375 |
_okButton.setEnabled(false);
|
376 |
GridBagConstraints gbc__okButton = new GridBagConstraints(); |
377 |
gbc__okButton.insets = new Insets(0, 0, 0, 5); |
378 |
gbc__okButton.gridx = 2;
|
379 |
gbc__okButton.gridy = 0;
|
380 |
buttonPane.add(_okButton, gbc__okButton); |
381 |
_okButton.addActionListener(new ActionListener() { |
382 |
public void actionPerformed(ActionEvent e) { |
383 |
|
384 |
_progressBar.setVisible(true);
|
385 |
setCursor(Cursor
|
386 |
.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
387 |
new Thread(new Runnable() { |
388 |
public void run() { |
389 |
|
390 |
PointTreeBuilderOperator octreeBuilder = new PointTreeBuilderOperator(
|
391 |
"Octree");
|
392 |
_progressBar.setIndeterminate(true);
|
393 |
|
394 |
if (!_useLayerCheck.isSelected()) {
|
395 |
|
396 |
octreeBuilder.buildFromFile( |
397 |
textField.getText(), |
398 |
textField_2.getText() + ".osgt");
|
399 |
} |
400 |
|
401 |
else {
|
402 |
|
403 |
buildFromLayer(octreeBuilder); |
404 |
|
405 |
} |
406 |
|
407 |
File file = new File(textField_2.getText() |
408 |
+ ".osgt");
|
409 |
file.renameTo(new File(file.getAbsolutePath() |
410 |
+ ".ptree"));
|
411 |
_progressBar.setIndeterminate(false);
|
412 |
_progressBar.setValue(100);
|
413 |
setCursor(Cursor
|
414 |
.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
415 |
addLayerToView(); |
416 |
|
417 |
} |
418 |
|
419 |
private void buildFromLayer( |
420 |
PointTreeBuilderOperator octreeBuilder) { |
421 |
|
422 |
if (_layer instanceof FLyrVect) { |
423 |
|
424 |
// Convenience casting, create a default 3D
|
425 |
// symbol
|
426 |
ISingleSymbolLegend legend = (ISingleSymbolLegend) ((FLyrVect) _layer) |
427 |
.getLegend(); |
428 |
I3DSymbol sy = (I3DSymbol) legend |
429 |
.getDefaultSymbol(); |
430 |
Terrain terrain = ((DefaultView3DDocument) _view3D) |
431 |
.getTerrain(); |
432 |
sy.setCoordinateSystemType(terrain |
433 |
.getCoordinateSystemType()); |
434 |
|
435 |
MapContext3D m3d = ((MapContext3D) _layer |
436 |
.getMapContext()); |
437 |
Layer3DProps layerprops = m3d |
438 |
.getLayer3DProps(_layer); |
439 |
|
440 |
if (layerprops.isZEnable() == false) |
441 |
sy.setFixedHeight(layerprops |
442 |
.getHeight()); |
443 |
|
444 |
ViewPort vp = m3d.getViewPort(); |
445 |
try {
|
446 |
vp.setEnvelope(m3d.getFullEnvelope()); |
447 |
} catch (ReadException e1) {
|
448 |
// TODO Auto-generated catch block
|
449 |
e1.printStackTrace(); |
450 |
} |
451 |
|
452 |
vp.setAdjustable(false);
|
453 |
vp.setImageSize(new Dimension(256, 256)); |
454 |
vp.setDist1pixel(0.000000001);
|
455 |
|
456 |
double scale = 0.5 * (_layer.getMaxScale() + _layer |
457 |
.getMinScale()); |
458 |
|
459 |
DataStore ds = ((SingleLayer) _layer) |
460 |
.getDataStore(); |
461 |
|
462 |
if (sy.getGeometry().getSize() == 0 |
463 |
|| layerprops.isGeometryDirty() == true) {
|
464 |
try {
|
465 |
((SimpleMarker3DSymbol) (sy)) |
466 |
.resetGeometry(); |
467 |
_layer.draw(null, null, |
468 |
m3d.getViewPort(), |
469 |
new MyCancel(), scale);
|
470 |
// setGeometryDirty to false to
|
471 |
// avoid unnecessary repaints
|
472 |
layerprops.setDirtyGeometry(false);
|
473 |
} catch (ReadException e) {
|
474 |
// TODO Auto-generated catch block
|
475 |
e.printStackTrace(); |
476 |
} |
477 |
} |
478 |
|
479 |
GeoPointArray3D points = (GeoPointArray3D) sy |
480 |
.getGeometry(); |
481 |
// points = new GeoPointArray3D();
|
482 |
octreeBuilder.build(points, |
483 |
textField_2.getText() + ".osgt");
|
484 |
|
485 |
} |
486 |
|
487 |
} |
488 |
|
489 |
}).start(); |
490 |
|
491 |
} |
492 |
}); |
493 |
|
494 |
} |
495 |
{ |
496 |
JButton cancelButton = new JButton("Close"); |
497 |
cancelButton.setActionCommand("Cancel");
|
498 |
GridBagConstraints gbc_cancelButton = new GridBagConstraints(); |
499 |
gbc_cancelButton.gridx = 1;
|
500 |
gbc_cancelButton.gridy = 0;
|
501 |
cancelButton.addActionListener(new ActionListener() { |
502 |
public void actionPerformed(ActionEvent e) { |
503 |
|
504 |
PluginServices.getMDIManager().closeWindow( |
505 |
MultiResolutionTool.this); |
506 |
|
507 |
} |
508 |
}); |
509 |
buttonPane.add(cancelButton, gbc_cancelButton); |
510 |
} |
511 |
} |
512 |
} |
513 |
|
514 |
protected boolean isProcessable(File file) { |
515 |
try {
|
516 |
int dotPos = file.getName().lastIndexOf("."); |
517 |
String extension = file.getName().substring(dotPos);
|
518 |
if (extension.equals(".shp") || extension.equals(".SHP")) { |
519 |
FLyrVect lyr = null;
|
520 |
MapContextManager manager = MapContextLocator.getMapContextManager(); |
521 |
lyr = (FLyrVect) manager.createLayer(file.getName(), |
522 |
getStoreParameters(file)); |
523 |
|
524 |
return isProcessable(lyr);
|
525 |
} |
526 |
return true; |
527 |
|
528 |
} catch (LoadLayerException e) {
|
529 |
// TODO Auto-generated catch block
|
530 |
e.printStackTrace(); |
531 |
return false; |
532 |
} |
533 |
|
534 |
} |
535 |
|
536 |
private boolean isProcessable(FLyrVect layer) { |
537 |
|
538 |
try {
|
539 |
if (layer.getShapeType() == Geometry.TYPES.POINT
|
540 |
|| layer.getShapeType() == Geometry.TYPES.MULTIPOINT) |
541 |
return true; |
542 |
else
|
543 |
return false; |
544 |
} catch (ReadException e) {
|
545 |
// TODO Auto-generated catch block
|
546 |
e.printStackTrace(); |
547 |
} |
548 |
return false; |
549 |
|
550 |
} |
551 |
|
552 |
private void addLayerToView() { |
553 |
|
554 |
_view3D.getMapContext().beginAtomicEvent(); |
555 |
|
556 |
FLyrVect lyr = null;
|
557 |
MapContextManager manager = MapContextLocator.getMapContextManager(); |
558 |
try {
|
559 |
File file = new File(textField_2.getText() + ".osgt" + ".ptree"); |
560 |
lyr = (FLyrVect) manager.createLayer(file.getName(), |
561 |
getOSGStoreParameters(file)); |
562 |
} catch (LoadLayerException e) {
|
563 |
// TODO Auto-generated catch block
|
564 |
e.printStackTrace(); |
565 |
} |
566 |
_view3D.getMapContext().getLayers().addLayer(lyr); |
567 |
_view3D.getMapContext().invalidate(); |
568 |
_view3D.getMapContext().endAtomicEvent(); |
569 |
|
570 |
} |
571 |
|
572 |
private DataStoreParameters getOSGStoreParameters(File file) { |
573 |
DataManager dataManager = DALLocator.getDataManager(); |
574 |
OSGStoreParameters parameters; |
575 |
try {
|
576 |
parameters = (OSGStoreParameters) dataManager |
577 |
.createStoreParameters(OSGStoreProvider.NAME); |
578 |
parameters.setFile(file); |
579 |
return parameters;
|
580 |
} catch (InitializeException e) {
|
581 |
// TODO Auto-generated catch block
|
582 |
e.printStackTrace(); |
583 |
} catch (ProviderNotRegisteredException e) {
|
584 |
// TODO Auto-generated catch block
|
585 |
e.printStackTrace(); |
586 |
} |
587 |
// refreshDataStoreParameters(parameters);
|
588 |
return null; |
589 |
} |
590 |
|
591 |
private DataStoreParameters getStoreParameters(File file) { |
592 |
DataManager dataManager = DALLocator.getDataManager(); |
593 |
SHPStoreParameters parameters; |
594 |
try {
|
595 |
|
596 |
parameters = (SHPStoreParameters) dataManager |
597 |
.createStoreParameters(SHPStoreProvider.NAME); |
598 |
parameters.setFile(file); |
599 |
parameters.setCRS(_view3D.getProjection()); |
600 |
|
601 |
return parameters;
|
602 |
} catch (InitializeException e) {
|
603 |
// TODO Auto-generated catch block
|
604 |
e.printStackTrace(); |
605 |
} catch (ProviderNotRegisteredException e) {
|
606 |
// TODO Auto-generated catch block
|
607 |
e.printStackTrace(); |
608 |
} |
609 |
// refreshDataStoreParameters(parameters);
|
610 |
return null; |
611 |
} |
612 |
|
613 |
public class TypeFileFilter extends FileFilter { |
614 |
private final String[] okFileExtensions = new String[] { ".las", "3dc", "shp" }; |
615 |
|
616 |
public boolean accept(File file) { |
617 |
for (String extension : okFileExtensions) { |
618 |
if (file.getName().toLowerCase().endsWith(extension)
|
619 |
|| file.isDirectory()) { |
620 |
return true; |
621 |
} |
622 |
|
623 |
} |
624 |
return false; |
625 |
} |
626 |
|
627 |
@Override
|
628 |
public String getDescription() { |
629 |
// TODO Auto-generated method stub
|
630 |
return "Multiresolution files"; |
631 |
} |
632 |
} |
633 |
|
634 |
public WindowInfo getWindowInfo() {
|
635 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
636 |
m_viewinfo.setTitle(PluginServices |
637 |
.getText(this, "MultiResolution Tool")); |
638 |
m_viewinfo.setHeight(110);
|
639 |
m_viewinfo.setWidth(390);
|
640 |
m_viewinfo.setX(100);
|
641 |
m_viewinfo.setY(100);
|
642 |
return m_viewinfo;
|
643 |
} |
644 |
|
645 |
public Object getWindowProfile() { |
646 |
return WindowInfo.PROPERTIES_PROFILE;
|
647 |
} |
648 |
|
649 |
public Object getWindowModel() { |
650 |
return _view3D;
|
651 |
} |
652 |
|
653 |
protected class MyCancel implements Cancellable { |
654 |
private boolean cancel = false; |
655 |
|
656 |
public MyCancel() {
|
657 |
} |
658 |
|
659 |
public void setCanceled(boolean canceled) { |
660 |
cancel = canceled; |
661 |
} |
662 |
|
663 |
public boolean isCanceled() { |
664 |
return cancel;
|
665 |
} |
666 |
} |
667 |
|
668 |
} |