Statistics
| Revision:

gvsig-3d / 1.10 / trunk / extensions / ext3Dgui / src / org / gvsig / gvsig3dgui / display / FullScreenPanel.java @ 116

History | View | Annotate | Download (22 KB)

1
package org.gvsig.gvsig3dgui.display;
2

    
3
import java.awt.BorderLayout;
4
import java.awt.Component;
5
import java.awt.Dimension;
6
import java.awt.GraphicsDevice;
7
import java.awt.GraphicsEnvironment;
8
import java.awt.HeadlessException;
9
import java.awt.Toolkit;
10
import java.awt.event.ActionEvent;
11
import java.awt.event.ComponentEvent;
12
import java.awt.event.ComponentListener;
13
import java.awt.event.ItemEvent;
14
import java.awt.event.ItemListener;
15
import java.awt.event.KeyEvent;
16
import java.awt.event.KeyListener;
17
import java.awt.event.WindowAdapter;
18
import java.awt.event.WindowEvent;
19
import java.io.File;
20
import java.io.FileNotFoundException;
21

    
22
import javax.swing.JButton;
23
import javax.swing.JCheckBox;
24
import javax.swing.JDialog;
25
import javax.swing.JFileChooser;
26
import javax.swing.JFormattedTextField;
27
import javax.swing.JLabel;
28
import javax.swing.JOptionPane;
29
import javax.swing.JPanel;
30
import javax.swing.JSpinner;
31
import javax.swing.JTextField;
32
import javax.swing.SpinnerNumberModel;
33
import javax.swing.event.ChangeEvent;
34
import javax.swing.event.ChangeListener;
35

    
36
import org.apache.log4j.Logger;
37
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
38
import org.gvsig.gvsig3d.gui.Compass;
39
import org.gvsig.gvsig3d.map3d.MapContext3D;
40
import org.gvsig.gvsig3dgui.view.View3D;
41
import org.gvsig.osgvp.core.osg.Group;
42
import org.gvsig.osgvp.core.osg.Matrix;
43
import org.gvsig.osgvp.core.osg.Node;
44
import org.gvsig.osgvp.core.osg.Vec3;
45
import org.gvsig.osgvp.core.osg.Vec4;
46
import org.gvsig.osgvp.core.osgdb.osgDB;
47
import org.gvsig.osgvp.exceptions.node.ChildIndexOutOfBoundsExceptions;
48
import org.gvsig.osgvp.exceptions.node.LoadNodeException;
49
import org.gvsig.osgvp.exceptions.node.NodeException;
50
import org.gvsig.osgvp.features.Polygon;
51
import org.gvsig.osgvp.stereoconfig.StereoConfig;
52
import org.gvsig.osgvp.terrain.Terrain;
53
import org.gvsig.osgvp.terrain.TerrainCameraManipulator;
54
import org.gvsig.osgvp.terrain.TerrainViewer;
55
import org.gvsig.osgvp.util.CameraHUD;
56
import org.gvsig.osgvp.util.UpdateNodeListener;
57
import org.gvsig.osgvp.viewer.Camera;
58
import org.gvsig.osgvp.viewer.DisplaySettings;
59
import org.gvsig.osgvp.viewer.ISlaveComponent;
60
import org.gvsig.osgvp.viewer.IViewerContainer;
61
import org.gvsig.osgvp.viewer.ViewerFactory;
62
import org.gvsig.osgvp.viewer.ViewerStateListener;
63

    
64
import com.iver.andami.PluginServices;
65
import com.iver.andami.messages.NotificationManager;
66
import com.iver.andami.ui.mdiManager.IWindow;
67
import com.iver.andami.ui.mdiManager.IWindowListener;
68
import com.iver.andami.ui.mdiManager.WindowInfo;
69
import com.iver.core.NotificationDialog;
70

    
71
public class FullScreenPanel extends GridBagLayoutPanel implements IWindow,
72
                ChangeListener, IWindowListener {
73

    
74
        /**
75
         * 
76
         */
77
        private static final long serialVersionUID = 7918162328474597496L;
78
        private static Logger _logger = Logger.getLogger(FullScreenPanel.class
79
                        .getName());
80

    
81
        private WindowInfo _viewinfo;
82
        private int _width = 650;
83
        private int _height = 270;
84
        private View3D _view3D;
85
        private TerrainViewer _fullScreenViewer;
86
        private DisplaySettings _ds;
87
        private IViewerContainer _canvas3d;
88

    
89
        private JPanel jPanel1;
90
        private JButton jButton2;
91
        private JButton jButton1;
92
        private JTextField jTextField1;
93
        private JCheckBox jCheckBox1;
94
        private JCheckBox jCheckBox2;
95
        private JCheckBox jCheckBox3;
96
        private JCheckBox wowjCheckBox;
97
        private JCheckBox xyzjCheckBox;
98

    
99
        private javax.swing.JSpinner jSpinner1;
100
        private javax.swing.JSpinner jSpinner2;
101
        private javax.swing.JSpinner jSpinner3;
102
        private javax.swing.JSpinner jSpinner4;
103
        private javax.swing.JSpinner jSpinner5;
104

    
105
        private JLabel jLabel4;
106
        private JLabel jLabel3;
107

    
108
        public FullScreenPanel() {
109

    
110
                if (PluginServices.getMDIManager().getActiveWindow() instanceof View3D) {
111
                        _view3D = (View3D) PluginServices.getMDIManager().getActiveWindow();
112
                        initialize();
113
                }
114

    
115
                else
116
                        PluginServices.getMDIManager().closeWindow(this);
117

    
118
        }
119

    
120
        public Object getWindowModel() {
121
                return _view3D;
122
        }
123

    
124
        public void initialize() {
125

    
126
                java.awt.GridBagConstraints gridBagConstraints;
127

    
128
                jPanel1 = new javax.swing.JPanel();
129
                jButton2 = new javax.swing.JButton();
130
                jButton1 = new javax.swing.JButton();
131
                jLabel3 = new javax.swing.JLabel();
132
                jLabel4 = new javax.swing.JLabel();
133
                jCheckBox1 = new javax.swing.JCheckBox();
134
                jCheckBox2 = new javax.swing.JCheckBox();
135
                jCheckBox3 = new javax.swing.JCheckBox();
136
                jSpinner1 = new javax.swing.JSpinner();
137
                jSpinner2 = new javax.swing.JSpinner();
138
                jSpinner3 = new javax.swing.JSpinner();
139
                jSpinner4 = new javax.swing.JSpinner();
140
                jSpinner5 = new javax.swing.JSpinner();
141
                wowjCheckBox = new JCheckBox();
142
        //        xyzjCheckBox = new JCheckBox();
143

    
144
                setLayout(new java.awt.GridBagLayout());
145

    
146
                jPanel1.setLayout(new java.awt.GridBagLayout());
147

    
148
                jButton2.setText(PluginServices.getText(this, "Cancel"));
149
                gridBagConstraints = new java.awt.GridBagConstraints();
150
                gridBagConstraints.gridx = 1;
151
                gridBagConstraints.gridy = 9;
152
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
153
                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
154
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
155
                jButton2.addActionListener(new java.awt.event.ActionListener() {
156
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
157
                                jButton2ActionPerformed(evt);
158
                        }
159
                });
160
                jPanel1.add(jButton2, gridBagConstraints);
161

    
162
                jButton1.setText(PluginServices.getText(this, "Accept"));
163
                jButton1.addActionListener(new java.awt.event.ActionListener() {
164
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
165
                                jButton1ActionPerformed(evt);
166
                        }
167
                });
168

    
169
                gridBagConstraints = new java.awt.GridBagConstraints();
170
                gridBagConstraints.gridx = 2;
171
                gridBagConstraints.gridy = 9;
172
                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
173
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
174
                jPanel1.add(jButton1, gridBagConstraints);
175

    
176
                jCheckBox1.setText(PluginServices.getText(this, "Sincronizar_camaras"));
177
                gridBagConstraints = new java.awt.GridBagConstraints();
178
                gridBagConstraints.gridx = 0;
179
                gridBagConstraints.gridy = 2;
180
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
181
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
182
                jPanel1.add(jCheckBox1, gridBagConstraints);
183
                jCheckBox1.setSelected(false);
184

    
185
                jCheckBox2.setText(PluginServices.getText(this, "Elegir_pantalla"));
186
                gridBagConstraints = new java.awt.GridBagConstraints();
187
                gridBagConstraints.gridx = 0;
188
                gridBagConstraints.gridy = 3;
189
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
190
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
191
                jPanel1.add(jCheckBox2, gridBagConstraints);
192

    
193
                jCheckBox2.addItemListener(new ItemListener() {
194

    
195
                        public void itemStateChanged(ItemEvent e) {
196
                                jCheckBox1ItemSelected(e);
197
                        }
198

    
199
                });
200

    
201
                wowjCheckBox.setText(PluginServices.getText(this, "Activar_WOW"));
202
                gridBagConstraints = new java.awt.GridBagConstraints();
203
                gridBagConstraints.gridx = 0;
204
                gridBagConstraints.gridy = 7;
205
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
206
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
207
                jPanel1.add(wowjCheckBox, gridBagConstraints);
208
                wowjCheckBox.setSelected(false);
209

    
210
//                xyzjCheckBox.setText(PluginServices.getText(this, "Activar_XYZ"));
211
//                xyzjCheckBox.setToolTipText(PluginServices.getText(this,
212
//                                "Activar_XYZ_tooltip"));
213
                gridBagConstraints = new java.awt.GridBagConstraints();
214
                gridBagConstraints.gridx = 0;
215
                gridBagConstraints.gridy = 8;
216
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
217
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
218
        //        jPanel1.add(xyzjCheckBox, gridBagConstraints);
219
                //xyzjCheckBox.setSelected(false);
220

    
221
                jCheckBox3.setText(PluginServices.getText(this, "Modo_ventana"));
222
                gridBagConstraints = new java.awt.GridBagConstraints();
223
                gridBagConstraints.gridx = 0;
224
                gridBagConstraints.gridy = 4;
225
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
226
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
227
                jPanel1.add(jCheckBox3, gridBagConstraints);
228

    
229
                jCheckBox3.addItemListener(new ItemListener() {
230

    
231
                        public void itemStateChanged(ItemEvent e) {
232
                                jCheckBox3ItemSelected(e);
233
                        }
234

    
235
                });
236

    
237
                int min = 0;
238
                int max = 2;
239
                int step = 1;
240
                int initValue = 0;
241
                SpinnerNumberModel model = new SpinnerNumberModel(initValue, min, max,
242
                                step);
243

    
244
                jSpinner1 = new JSpinner(model);
245
                JFormattedTextField tf = ((JSpinner.DefaultEditor) jSpinner1
246
                                .getEditor()).getTextField();
247
                tf.setEditable(false);
248

    
249
                gridBagConstraints = new java.awt.GridBagConstraints();
250
                gridBagConstraints.gridx = 1;
251
                gridBagConstraints.gridy = 3;
252
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
253
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
254
                jSpinner1.setEnabled(false);
255
                jPanel1.add(jSpinner1, gridBagConstraints);
256

    
257
                min = 0;
258
                max = 10000;
259
                step = 1;
260
                initValue = 0;
261
                SpinnerNumberModel model2 = new SpinnerNumberModel(initValue, min, max,
262
                                step);
263

    
264
                jLabel3.setText(PluginServices.getText(this, "Posicion_origen"));
265
                gridBagConstraints = new java.awt.GridBagConstraints();
266
                gridBagConstraints.gridx = 0;
267
                gridBagConstraints.gridy = 5;
268
                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
269
                jPanel1.add(jLabel3, gridBagConstraints);
270

    
271
                jSpinner2 = new JSpinner(model2);
272
                gridBagConstraints = new java.awt.GridBagConstraints();
273
                gridBagConstraints.gridx = 1;
274
                gridBagConstraints.gridy = 5;
275
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
276
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
277
                jSpinner2.setEnabled(false);
278
                jPanel1.add(jSpinner2, gridBagConstraints);
279

    
280
                min = 0;
281
                max = 10000;
282
                step = 1;
283
                initValue = 0;
284
                SpinnerNumberModel model3 = new SpinnerNumberModel(initValue, min, max,
285
                                step);
286

    
287
                jSpinner3 = new JSpinner(model3);
288
                gridBagConstraints = new java.awt.GridBagConstraints();
289
                gridBagConstraints.gridx = 2;
290
                gridBagConstraints.gridy = 5;
291
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
292
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
293
                jSpinner3.setEnabled(false);
294
                jPanel1.add(jSpinner3, gridBagConstraints);
295

    
296
                jLabel4.setText(PluginServices.getText(this, "Resolucion"));
297
                gridBagConstraints = new java.awt.GridBagConstraints();
298
                gridBagConstraints.gridx = 0;
299
                gridBagConstraints.gridy = 6;
300
                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
301
                jPanel1.add(jLabel4, gridBagConstraints);
302

    
303
                min = 0;
304
                max = 10000;
305
                step = 1;
306
                initValue = 0;
307
                SpinnerNumberModel model4 = new SpinnerNumberModel(initValue, min, max,
308
                                step);
309

    
310
                jSpinner4 = new JSpinner(model4);
311
                gridBagConstraints = new java.awt.GridBagConstraints();
312
                gridBagConstraints.gridx = 1;
313
                gridBagConstraints.gridy = 6;
314
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
315
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
316
                jSpinner4.setEnabled(false);
317
                jSpinner4.setValue((int) 800);
318
                jPanel1.add(jSpinner4, gridBagConstraints);
319

    
320
                min = 0;
321
                max = 10000;
322
                step = 1;
323
                initValue = 0;
324
                SpinnerNumberModel model5 = new SpinnerNumberModel(initValue, min, max,
325
                                step);
326

    
327
                jSpinner5 = new JSpinner(model5);
328
                gridBagConstraints = new java.awt.GridBagConstraints();
329
                gridBagConstraints.gridx = 2;
330
                gridBagConstraints.gridy = 6;
331
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
332
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
333
                jSpinner5.setEnabled(false);
334
                jSpinner5.setValue((int) 600);
335
                jPanel1.add(jSpinner5, gridBagConstraints);
336

    
337
                add(jPanel1, new java.awt.GridBagConstraints());
338

    
339
        }
340

    
341
        protected void jCheckBox3ItemSelected(ItemEvent e) {
342

    
343
                if (e.getStateChange() == ItemEvent.SELECTED) {
344
                        jSpinner2.setEnabled(true);
345
                        jSpinner3.setEnabled(true);
346
                        jSpinner4.setEnabled(true);
347
                        jSpinner5.setEnabled(true);
348
                } else {
349
                        jSpinner2.setEnabled(false);
350
                        jSpinner3.setEnabled(false);
351
                        jSpinner4.setEnabled(false);
352
                        jSpinner5.setEnabled(false);
353
                }
354

    
355
        }
356

    
357
        protected void jCheckBox1ItemSelected(ItemEvent e) {
358

    
359
                if (e.getStateChange() == ItemEvent.SELECTED)
360
                        jSpinner1.setEnabled(true);
361
                else
362
                        jSpinner1.setEnabled(false);
363

    
364
        }
365

    
366
        protected void jButton3ActionPerformed(ActionEvent evt) {
367
                JFileChooser jFileChooser1 = new JFileChooser();
368
                int returnVal = jFileChooser1.showOpenDialog(this);
369

    
370
                if (returnVal == JFileChooser.APPROVE_OPTION)
371
                        jTextField1.setText(jFileChooser1.getSelectedFile()
372
                                        .getAbsolutePath());
373

    
374
        }
375

    
376
        private JDialog frame;
377
        private boolean changedManipulator;
378
        private Camera viewCam;
379
        private int _numScreens;
380
        private int _screenWidth;
381
        private int _screenHeight;
382

    
383
        private Compass compass;
384

    
385
        protected void jButton1ActionPerformed(ActionEvent evt) {
386

    
387
                _view3D = (View3D) PluginServices.getMDIManager().getActiveWindow();
388
                PluginServices.getMDIManager().closeWindow(this);
389

    
390
                _ds = _view3D.getDisplaySettings();
391

    
392
                final boolean synchronize = jCheckBox1.isSelected();
393
                changedManipulator = false;
394

    
395
                GraphicsEnvironment ge = GraphicsEnvironment
396
                                .getLocalGraphicsEnvironment();
397
                try {
398
                        GraphicsDevice[] gs = ge.getScreenDevices();
399
                        int screenNum = ((SpinnerNumberModel) jSpinner1.getModel())
400
                                        .getNumber().intValue();
401
                        _numScreens = gs.length;
402
                        if (_numScreens <= screenNum)
403
                                screenNum = 0;
404
                        _screenWidth = gs[screenNum].getDisplayMode().getWidth();
405
                        _screenHeight = gs[screenNum].getDisplayMode().getHeight();
406
                        _logger.debug("Num Screens:" + _numScreens);
407
                        _logger.debug("Selected Screen:" + screenNum);
408
                        _logger.debug("Selected Screen Resolution:(" + _screenWidth + ","
409
                                        + _screenHeight + ")");
410
                } catch (HeadlessException e) {
411
                        // Is thrown if there are no screen devices
412
                }
413

    
414
                try {
415
                        Terrain planetView3D = ((TerrainViewer) _view3D.getCanvas3d()
416
                                        .getOSGViewer()).getTerrain(0);
417
                        final Terrain terrain = new Terrain();
418
                        terrain.setCoordinateSystemType(planetView3D
419
                                        .getCoordinateSystemType());
420
                        terrain.setCoordinateSystemName(planetView3D
421
                                        .getCoordinateSystemName());
422
                        terrain.setCoordinateSystemFormat(planetView3D
423
                                        .getCoordinateSystemFormat());
424
                        terrain.setExtent(planetView3D.getExtent());
425
                        terrain.setTerrainName(planetView3D.getTerrainName());
426

    
427
                        MapContext3D mc = (MapContext3D) _view3D.getMapControl()
428
                                        .getMapContext();
429
                        terrain.init();
430
                        terrain.setLayerManager(mc.getTerrain().getLayerManager());
431
                        viewCam = new Camera();
432
                        _fullScreenViewer = new TerrainViewer() {
433

    
434
                                public void frame() {
435
                                        if (synchronize) {
436
                                                _fullScreenViewer.setFusionDistance((float) terrain
437
                                                                .getZoom());
438
                                                 Matrix refView = _view3D.getCanvas3d().getOSGViewer()
439
                                                 .getViewMatrix();
440
                                                 viewCam.setViewMatrix(refView);
441
                                                _fullScreenViewer.setCamera(viewCam);
442
                                        }
443

    
444
                                        super.frame();
445
                                };
446
                        };
447
                        _fullScreenViewer.addTerrain(terrain);
448
                        _fullScreenViewer.addFeature((((TerrainViewer) _view3D
449
                                        .getCanvas3d().getOSGViewer()).getFeatures()));
450
                        Terrain pl = (((TerrainViewer) _view3D.getCanvas3d().getOSGViewer())
451
                                        .getTerrain(0));
452
                        compass = new Compass(pl);
453

    
454
                        if (pl.getCoordinateSystemType() == Terrain.CoordinateSystemType.GEOCENTRIC) {
455
                                compass.setPanetType(Compass.Mode.SPHERIC);
456
                        } else
457
                                compass.setPanetType(Compass.Mode.FLAT);
458

    
459
                        compass.setUpdateListener(new UpdateNodeListener() {
460

    
461
                                public void update(Node arg0) {
462
                                        compass.update(_fullScreenViewer.getCamera());
463

    
464
                                }
465
                        });
466

    
467
                        _fullScreenViewer.addNodeToCameraHUD(compass);
468

    
469
                        Vec4 color = ((TerrainViewer) _view3D.getCanvas3d().getOSGViewer())
470
                                        .getClearColor();
471
                        _fullScreenViewer.setClearColor(color.x(), color.y(), color.z(),
472
                                        color.w());
473
                        _fullScreenViewer.setDisplaySettings(_ds);
474
                        Matrix refView = _view3D.getCanvas3d().getOSGViewer()
475
                                        .getViewMatrix();
476
                        viewCam.setViewMatrix(refView);
477
                        _fullScreenViewer.setCamera(viewCam);
478

    
479
                        _canvas3d = ViewerFactory.getInstance().createViewer(
480
                                        ViewerFactory.VIEWER_TYPE.CANVAS_VIEWER, _fullScreenViewer);
481
                        _canvas3d
482
                                        .addKeyListener(new ViewerStateListener(_fullScreenViewer));
483
                        frame = new JDialog();
484
                        JPanel jContentPane = new JPanel();
485
                        jContentPane.setLayout(new BorderLayout());
486
                        frame.setContentPane(jContentPane);
487
                        jContentPane.add((Component) _canvas3d, BorderLayout.CENTER);
488
                        ViewerFactory.getInstance().startAnimator();
489
                        frame.addWindowListener(new WindowAdapter() {
490
                                public void windowClosing(WindowEvent e) {
491
                                        /*
492
                                         * if (changedManipulator) { ((TerrainViewer)
493
                                         * (_view3D.getCanvas3d().getOSGViewer()))
494
                                         * .setCameraManipulator(null); }
495
                                         */
496

    
497
                                        _canvas3d.dispose();
498
                                }
499
                        });
500

    
501
                        frame.addComponentListener(new ComponentListener() {
502
                                public void componentResized(ComponentEvent arg0) {
503
                                        compass.setPosition(new Vec3(frame.getWidth() - 70, frame
504
                                                        .getHeight() - 70, 0));
505

    
506
                                }
507

    
508
                                public void componentMoved(ComponentEvent arg0) {
509
                                        // TODO Auto-generated method stub
510

    
511
                                }
512

    
513
                                public void componentShown(ComponentEvent arg0) {
514
                                        // TODO Auto-generated method stub
515

    
516
                                }
517

    
518
                                public void componentHidden(ComponentEvent e) {
519
                                        // TODO Auto-generated method stub
520

    
521
                                }
522
                        });
523
                        _canvas3d.addKeyListener(new KeyListener() {
524

    
525
                                public void keyPressed(KeyEvent arg0) {
526
                                        // TODO Auto-generated method stub
527

    
528
                                }
529

    
530
                                public void keyReleased(KeyEvent arg0) {
531

    
532
                                        if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE) {
533

    
534
                                                frame.dispose();
535

    
536
                                        }
537

    
538
                                }
539

    
540
                                public void keyTyped(KeyEvent arg0) {
541
                                        // TODO Auto-generated method stub
542

    
543
                                }
544
                        });
545

    
546
                } catch (ChildIndexOutOfBoundsExceptions e1) {
547

    
548
                        e1.printStackTrace();
549
                } catch (NodeException e1) {
550

    
551
                        e1.printStackTrace();
552
                }
553

    
554
                /*
555
                 * if (_view3D.getCanvas3d().getOSGViewer().getCameraManipulator() ==
556
                 * null) { ((TerrainViewer) (_view3D.getCanvas3d().getOSGViewer()))
557
                 * .restoreCustomTerrainManipulator(); changedManipulator = true; }
558
                 */
559

    
560
                if (synchronize)
561
                        _fullScreenViewer.setCameraManipulator(null);
562

    
563
                if (!jCheckBox3.isSelected()) { // the viewer is created in
564
                        // fullscreen
565
                        if (wowjCheckBox.isSelected()) {
566
                                enableWOWDisplay();
567
                                runViewer();
568
                        } else if (_ds.getStereoMode() == DisplaySettings.StereoMode.QUAD_BUFFER) {
569
                                enableQUADBUFFERDisplay();
570
                                runViewer();
571
                        } else {
572
                                if (!jCheckBox2.isSelected()) {
573
//                                        if (xyzjCheckBox.isSelected()) {
574
//                                                enableXYZDisplay();
575
//                                        }
576
                                        frame.setUndecorated(true);
577
                                        frame.requestFocus();
578
                                        // Dimension dim =
579
                                        // Toolkit.getDefaultToolkit().getScreenSize();
580
                                        // frame.setSize(dim.width, dim.height);
581
                                        frame.setSize(_screenWidth, _screenHeight);
582
                                        frame.setVisible(true);
583
                                }
584

    
585
                                else {
586
//                                        if (xyzjCheckBox.isSelected()) {
587
//                                                enableXYZDisplay();
588
//                                        }
589
                                        frame.setUndecorated(true);
590
                                        frame.requestFocus();
591
                                        // Dimension dim =
592
                                        // Toolkit.getDefaultToolkit().getScreenSize();
593
                                        // frame.setSize(dim.width / _numScreens, dim.height);
594
                                        frame.setSize(_screenWidth, _screenHeight);
595
                                        frame.setLocation(((SpinnerNumberModel) jSpinner1
596
                                                        .getModel()).getNumber().intValue()
597
                                                        * _screenWidth, 0);
598
                                        frame.setVisible(true);
599
                                }
600
                        }
601
                }
602

    
603
                else { // here is created a windowed viewer
604

    
605
                        if (jCheckBox2.isSelected()) {
606

    
607
                                Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
608
                                frame.setSize(((SpinnerNumberModel) jSpinner4.getModel())
609
                                                .getNumber().intValue(),
610
                                                ((SpinnerNumberModel) jSpinner5.getModel()).getNumber()
611
                                                                .intValue());
612
                                frame.setLocation((((SpinnerNumberModel) jSpinner1.getModel())
613
                                                .getNumber().intValue() * dim.width)
614
                                                + ((SpinnerNumberModel) jSpinner2.getModel())
615
                                                                .getNumber().intValue(),
616
                                                ((SpinnerNumberModel) jSpinner3.getModel()).getNumber()
617
                                                                .intValue());
618
                                frame.setVisible(true);
619
                        } else {
620

    
621
                                frame.setSize(((SpinnerNumberModel) jSpinner4.getModel())
622
                                                .getNumber().intValue(),
623
                                                ((SpinnerNumberModel) jSpinner5.getModel()).getNumber()
624
                                                                .intValue());
625
                                frame.setLocation(((SpinnerNumberModel) jSpinner2.getModel())
626
                                                .getNumber().intValue(),
627
                                                ((SpinnerNumberModel) jSpinner3.getModel()).getNumber()
628
                                                                .intValue());
629
                                frame.setVisible(true);
630
                        }
631

    
632
                }
633

    
634
                compass.setScale(new Vec3(75, 75, 75));
635
                System.gc();
636

    
637
        }
638

    
639
        protected void jButton2ActionPerformed(ActionEvent evt) {
640
                PluginServices.getMDIManager().closeWindow(this);
641

    
642
        }
643

    
644
        public WindowInfo getWindowInfo() {
645
                _viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
646
                _viewinfo.setTitle(PluginServices.getText(this, "FullScreen"));
647
                _viewinfo.setHeight(_height);
648
                _viewinfo.setWidth(_width);
649
                return _viewinfo;
650
        }
651

    
652
        public void stateChanged(ChangeEvent e) {
653

    
654
        }
655

    
656
        public void windowActivated() {
657
                _view3D = (View3D) PluginServices.getMDIManager().getActiveWindow();
658
                System.out.println(_view3D.getName());
659
        }
660

    
661
        public void windowClosed() {
662

    
663
        }
664

    
665
        public Object getWindowProfile() {
666
                // TODO Auto-generated method stub
667
                return WindowInfo.DIALOG_PROFILE;
668
        }
669

    
670
        protected void enableWOWDisplay() {
671
                char wow_content = 0x02, wow_factor = 0x40, wow_offset = 0x80;
672
                float wow_Zd = 0.459813f;
673
                float wow_vz = 6.180772f;
674
                float wow_M = -1586.34f;
675
                float wow_C = 127.5f;
676
                int screenNum = ((SpinnerNumberModel) jSpinner1.getModel()).getNumber()
677
                                .intValue();
678

    
679
                _fullScreenViewer.setUpViewForWoWVxDisplay(screenNum, wow_content,
680
                                wow_factor, wow_offset, wow_Zd, wow_vz, wow_M, wow_C);
681
        }
682

    
683
//        protected void enableXYZDisplay() {
684
//                // int screenNum = ((SpinnerNumberModel) jSpinner1
685
//                // .getModel()).getNumber().intValue();
686
//                // _fullScreenViewer.setUpViewOnSingleScreen(screenNum);
687
//                Node n = _fullScreenViewer.getSceneData();
688
//                Node multiview = osgDB.readNodeFileNoException(String.valueOf(n
689
//                                .getCPtr())
690
//                                + ".multiview");
691
//                _fullScreenViewer.setSceneData(multiview);
692
//        }
693

    
694
        protected void enableQUADBUFFERDisplay() {
695
                if (!_fullScreenViewer.setUpViewerWithQuadBuffer(0, 0, _screenWidth,
696
                                _screenHeight))
697
                        JOptionPane.showMessageDialog((Component) PluginServices
698
                                        .getMainFrame(), PluginServices.getText(this,
699
                                        "Quadbuffer_error"));
700
                compass.setPosition(new Vec3(_screenWidth - 70, _screenHeight - 70, 0));
701
        }
702

    
703
        protected void runViewer() {
704
                final ISlaveComponent slavePainter = new ISlaveComponent() {
705

    
706
                        public void repaint() {
707
                                if(_fullScreenViewer != null)
708
                                {
709
                                        if(_fullScreenViewer.done())
710
                                        {
711
                                                _view3D.getCanvas3d().removeRenderSlaveComponent(this);
712
                                                _fullScreenViewer.dispose();
713
                                                _fullScreenViewer = null;
714
                                        }
715
                                        else
716
                                                _fullScreenViewer.frame();
717
                                }
718
                        }
719
                };
720
                _view3D.getCanvas3d().addRenderSlaveComponent(slavePainter);
721
        }
722
}