Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / ext3Dgui / src / org / gvsig / gvsig3dgui / display / FullScreenPanel.java @ 24769

History | View | Annotate | Download (6.45 KB)

1
package org.gvsig.gvsig3dgui.display;
2

    
3
import java.awt.event.ActionEvent;
4
import java.io.IOException;
5

    
6
import javax.swing.AbstractButton;
7
import javax.swing.JButton;
8
import javax.swing.JCheckBox;
9
import javax.swing.JFileChooser;
10
import javax.swing.JLabel;
11
import javax.swing.JPanel;
12
import javax.swing.JTextField;
13
import javax.swing.event.ChangeEvent;
14
import javax.swing.event.ChangeListener;
15
import javax.swing.text.JTextComponent;
16

    
17
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
18
import org.gvsig.gvsig3dgui.view.View3D;
19
import org.gvsig.osgvp.EventHandler;
20
import org.gvsig.osgvp.Vec4;
21
import org.gvsig.osgvp.exceptions.node.NodeException;
22
import org.gvsig.osgvp.planets.CustomTerrainManipulator;
23
import org.gvsig.osgvp.planets.PlanetViewer;
24
import org.gvsig.osgvp.viewer.DisplaySettings;
25
import org.gvsig.osgvp.viewer.OSGViewer;
26
import org.gvsig.osgvp.viewer.manipulator.CameraManipulator;
27

    
28
import com.iver.andami.PluginServices;
29
import com.iver.andami.ui.mdiManager.IWindow;
30
import com.iver.andami.ui.mdiManager.IWindowListener;
31
import com.iver.andami.ui.mdiManager.WindowInfo;
32

    
33
public class FullScreenPanel extends GridBagLayoutPanel implements IWindow,
34
                ChangeListener, IWindowListener {
35

    
36
        private WindowInfo m_viewinfo;
37

    
38
        private int width = 400;
39

    
40
        private int height = 160;
41

    
42
        private View3D view3D;
43

    
44
        private JPanel jPanel1;
45

    
46
        private JButton jButton2;
47

    
48
        private JButton jButton1;
49

    
50
        private JLabel jLabel2;
51

    
52
        private JTextField jTextField1;
53

    
54
        private JButton jButton3;
55

    
56
        private JCheckBox jCheckBox1;
57

    
58
        public FullScreenPanel() {
59

    
60
                if (PluginServices.getMDIManager().getActiveWindow() instanceof View3D) {
61
                        view3D = (View3D) PluginServices.getMDIManager().getActiveWindow();
62
                        initialize();
63
                }
64

    
65
                else
66
                        PluginServices.getMDIManager().closeWindow(this);
67

    
68
        }
69

    
70
        public Object getWindowModel() {
71
                return view3D;
72
        }
73

    
74
        public void initialize() {
75

    
76
                java.awt.GridBagConstraints gridBagConstraints;
77

    
78
                jPanel1 = new javax.swing.JPanel();
79
                jButton2 = new javax.swing.JButton();
80
                jButton1 = new javax.swing.JButton();
81
                jLabel2 = new javax.swing.JLabel();
82
                jTextField1 = new javax.swing.JTextField();
83
                jButton3 = new javax.swing.JButton();
84
                jCheckBox1 = new javax.swing.JCheckBox();
85

    
86
                
87
                setLayout(new java.awt.GridBagLayout());
88

    
89
                jPanel1.setLayout(new java.awt.GridBagLayout());
90

    
91
                jButton2.setText("Cancelar");
92
                gridBagConstraints = new java.awt.GridBagConstraints();
93
                gridBagConstraints.gridx = 2;
94
                gridBagConstraints.gridy = 4;
95
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
96
                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
97
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
98
                jPanel1.add(jButton2, gridBagConstraints);
99

    
100
                jButton1.setText("Aceptar");
101
                jButton1.addActionListener(new java.awt.event.ActionListener() {
102
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
103
                                jButton1ActionPerformed(evt);
104
                        }
105
                });
106
        
107
                gridBagConstraints = new java.awt.GridBagConstraints();
108
                gridBagConstraints.gridx = 1;
109
                gridBagConstraints.gridy = 4;
110
                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
111
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
112
                jPanel1.add(jButton1, gridBagConstraints);
113

    
114
                jLabel2.setText("Archivo de Configuracion");
115
                gridBagConstraints = new java.awt.GridBagConstraints();
116
                gridBagConstraints.gridx = 0;
117
                gridBagConstraints.gridy = 0;
118
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 21);
119
                jPanel1.add(jLabel2, gridBagConstraints);
120
                gridBagConstraints = new java.awt.GridBagConstraints();
121
                gridBagConstraints.gridx = 1;
122
                gridBagConstraints.gridy = 0;
123
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
124
                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
125
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
126
                jPanel1.add(jTextField1, gridBagConstraints);
127

    
128
                jButton3.setText("Browse");
129
                gridBagConstraints = new java.awt.GridBagConstraints();
130
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
131
                jPanel1.add(jButton3, gridBagConstraints);
132

    
133
                jCheckBox1.setText("Sincronizar camaras");
134
                gridBagConstraints = new java.awt.GridBagConstraints();
135
                gridBagConstraints.gridx = 0;
136
                gridBagConstraints.gridy = 2;
137
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
138
                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
139
                jPanel1.add(jCheckBox1, gridBagConstraints);
140

    
141
                
142
                
143
                add(jPanel1, new java.awt.GridBagConstraints());
144

    
145
                
146

    
147
        }
148

    
149
        
150
        protected void jButton1ActionPerformed(ActionEvent evt) {
151
                view3D = (View3D) PluginServices.getMDIManager().getActiveWindow();
152
                DisplaySettings ds = view3D.getDisplaySettings();
153
                PluginServices.getMDIManager().closeWindow(this);
154
                PlanetViewer fullScreenViewer;
155

    
156
                try {
157
                        fullScreenViewer = new PlanetViewer();
158
                        fullScreenViewer.addPlanet(((PlanetViewer) view3D.getCanvas3d()
159
                                        .getOSGViewer()).getPlanet(0));
160
                        fullScreenViewer.addSpecialNode((((PlanetViewer) view3D
161
                                        .getCanvas3d().getOSGViewer()).getSpecialNodes()));
162
                        Vec4 color = ((PlanetViewer) view3D.getCanvas3d().getOSGViewer())
163
                                        .getClearColor();
164
                        fullScreenViewer.setClearColor(color.x(), color.y(), color.z(),
165
                                        color.w());
166
                        fullScreenViewer.setDisplaySettings(ds);
167
                        // CustomTerrainManipulator cm = new CustomTerrainManipulator();
168
                        //view3D.getCanvas3d().getOSGViewer().getCameraManipulator().ref();
169
                        // fullScreenViewer.setUpViewInWindow(10, 10, 100, 100);
170
                        // fullScreenViewer.setCameraManipulator(view3D.getCanvas3d().getOSGViewer().getCameraManipulator());
171
                        if(jCheckBox1.isSelected())
172
                                fullScreenViewer.setCameraManipulator(null);
173
                        while (!fullScreenViewer.done()) {
174
                                if(jCheckBox1.isSelected())
175
                                fullScreenViewer.setCamera(view3D.getCanvas3d().getOSGViewer()
176
                                                .getCamera());
177
                                fullScreenViewer.frame();
178

    
179
                                
180
                        }
181
                        fullScreenViewer.releaseGLContext();
182
                        fullScreenViewer.dispose();
183
                        fullScreenViewer=null;
184
                        System.gc();
185

    
186
                } catch (NodeException e) {
187
                        // TODO Auto-generated catch block
188
                        e.printStackTrace();
189
                }
190

    
191
        }
192

    
193
        protected void jButton2ActionPerformed(ActionEvent evt) {
194
                PluginServices.getMDIManager().closeWindow(this);
195

    
196
        }
197

    
198
        public WindowInfo getWindowInfo() {
199
                m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
200
                m_viewinfo.setTitle(PluginServices.getText(this, "FullScreen"));
201
                m_viewinfo.setHeight(height);
202
                m_viewinfo.setWidth(width);
203
                return m_viewinfo;
204
        }
205

    
206
        public void stateChanged(ChangeEvent e) {
207

    
208
        }
209

    
210
        public void windowActivated() {
211
                view3D = (View3D) PluginServices.getMDIManager().getActiveWindow();
212
                System.out.println(view3D.getName());
213
        }
214

    
215
        public void windowClosed() {
216

    
217
        }
218

    
219
}