Revision 334 2.0/trunk/org.gvsig.gvsig3d.app/org.gvsig.gvsig3d.app.extension/src/main/java/org/gvsig/gvsig3d/app/gui/styling/Object3DSymbolTab.java
Object3DSymbolTab.java | ||
---|---|---|
21 | 21 |
import javax.swing.JTabbedPane; |
22 | 22 |
import javax.swing.JTextField; |
23 | 23 |
import javax.swing.border.TitledBorder; |
24 |
import javax.swing.filechooser.FileFilter; |
|
24 | 25 |
|
25 | 26 |
import org.gvsig.gvsig3d.impl.symbology3d.marker.impl.NodeMarker3DSymbol; |
26 | 27 |
import org.gvsig.gvsig3d.symbology3d.I3DSymbol; |
... | ... | |
33 | 34 |
import org.gvsig.osgvp.viewer.ViewerFactory; |
34 | 35 |
import java.awt.event.ActionListener; |
35 | 36 |
import java.awt.event.ActionEvent; |
37 |
import javax.swing.JSlider; |
|
38 |
import javax.swing.SpinnerNumberModel; |
|
39 |
import javax.swing.event.ChangeListener; |
|
40 |
import javax.swing.event.ChangeEvent; |
|
36 | 41 |
|
37 |
public class Object3DSymbolTab extends JPanel implements ISymbolSelectorTab{ |
|
42 |
public class Object3DSymbolTab extends JPanel implements ISymbolSelectorTab {
|
|
38 | 43 |
|
39 | 44 |
private JTextField textField; |
40 | 45 |
|
41 | 46 |
private IViewerContainer _canvas3d; |
42 | 47 |
|
43 | 48 |
private ISimpleMarker3DSymbol _symbol; |
44 |
private String _nodeURL; |
|
49 |
private String _nodeURL = "";
|
|
45 | 50 |
|
51 |
private JSpinner sizeSpinner; |
|
52 |
|
|
46 | 53 |
/** |
47 | 54 |
* Create the panel. |
48 | 55 |
*/ |
... | ... | |
72 | 79 |
panel.add(propertiesPanel, gbc_propertiesPanel); |
73 | 80 |
propertiesPanel.setLayout(new GridLayout(0, 3, 15, 0)); |
74 | 81 |
|
75 |
JLabel lblNewLabel_1 = new JLabel("Ruta:");
|
|
82 |
JLabel lblNewLabel_1 = new JLabel("Path:");
|
|
76 | 83 |
propertiesPanel.add(lblNewLabel_1); |
77 | 84 |
|
78 | 85 |
textField = new JTextField(); |
79 | 86 |
textField.setEditable(false); |
87 |
// textField.setText(_nodeURL); |
|
80 | 88 |
propertiesPanel.add(textField); |
81 | 89 |
textField.setColumns(10); |
82 | 90 |
|
... | ... | |
85 | 93 |
public void actionPerformed(ActionEvent e) { |
86 | 94 |
|
87 | 95 |
JFileChooser fc = new JFileChooser(); |
96 |
FileFilter ff = new TypeFileFilter(); |
|
97 |
fc.setFileFilter(ff); |
|
88 | 98 |
|
89 |
int returnVal = fc.showDialog(Object3DSymbolTab.this, |
|
90 |
"Select Color"); |
|
99 |
int returnVal = fc.showDialog(Object3DSymbolTab.this, "Accept"); |
|
91 | 100 |
|
92 | 101 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
93 | 102 |
File file = fc.getSelectedFile(); |
... | ... | |
102 | 111 |
// TODO Auto-generated catch block |
103 | 112 |
e1.printStackTrace(); |
104 | 113 |
} |
105 |
// this is where a real application would open the file.
|
|
114 |
textField.setText(_nodeURL);
|
|
106 | 115 |
|
107 | 116 |
} else { |
108 |
|
|
117 |
|
|
109 | 118 |
} |
110 | 119 |
|
111 |
// _symbol.setColor(newColor);
|
|
112 |
// _colorPanel.setBackground(newColor);
|
|
113 |
// _colorPanel.repaint();
|
|
114 |
// symbolPreviewPanel.repaint();
|
|
115 |
// ((SymbolSelector3D) _parent).setSymbol(_symbol);
|
|
120 |
// _symbol.setColor(newColor);
|
|
121 |
// _colorPanel.setBackground(newColor);
|
|
122 |
// _colorPanel.repaint();
|
|
123 |
// symbolPreviewPanel.repaint();
|
|
124 |
// ((SymbolSelector3D) _parent).setSymbol(_symbol);
|
|
116 | 125 |
|
117 | 126 |
} |
118 | 127 |
}); |
... | ... | |
121 | 130 |
JLabel lblSize = new JLabel("Scale Factor:"); |
122 | 131 |
propertiesPanel.add(lblSize); |
123 | 132 |
|
124 |
JSpinner spinner = new JSpinner(); |
|
125 |
propertiesPanel.add(spinner); |
|
126 |
|
|
127 | 133 |
JPanel panel_3 = new JPanel(); |
128 | 134 |
propertiesPanel.add(panel_3); |
135 |
panel_3.setLayout(new BorderLayout(0, 0)); |
|
129 | 136 |
|
130 |
JLabel lblUnits = new JLabel("Units"); |
|
131 |
propertiesPanel.add(lblUnits); |
|
137 |
sizeSpinner = new JSpinner(); |
|
138 |
sizeSpinner.addChangeListener(new ChangeListener() { |
|
139 |
public void stateChanged(ChangeEvent arg0) { |
|
140 |
|
|
141 |
_symbol.setSize((Double) sizeSpinner.getValue()); } |
|
142 |
}); |
|
143 |
sizeSpinner.setModel(new SpinnerNumberModel(1, 1, 100, 1)); |
|
144 |
panel_3.add(sizeSpinner); |
|
132 | 145 |
|
133 |
JComboBox comboBox = new JComboBox(); |
|
134 |
propertiesPanel.add(comboBox); |
|
135 | 146 |
|
136 |
JComboBox comboBox_1 = new JComboBox(); |
|
137 |
propertiesPanel.add(comboBox_1); |
|
138 | 147 |
|
139 | 148 |
JPanel panel_2 = new JPanel(); |
140 | 149 |
panel_2.setBorder(new TitledBorder(null, "Preview", |
... | ... | |
217 | 226 |
_canvas3d = ViewerFactory.getInstance().createViewer( |
218 | 227 |
ViewerFactory.VIEWER_TYPE.CANVAS_VIEWER, null); |
219 | 228 |
_canvas3d.setSize(size, size); |
220 |
//_canvas3d.getOSGViewer().setClearColor(1.0, 1.0, 1.0, 0.0); |
|
229 |
// _canvas3d.getOSGViewer().setClearColor(1.0, 1.0, 1.0, 0.0);
|
|
221 | 230 |
ViewerFactory.getInstance().startAnimator(); |
222 | 231 |
} |
223 | 232 |
|
... | ... | |
230 | 239 |
|
231 | 240 |
private void loadFile() { |
232 | 241 |
Node node = null; |
233 |
// if (this.getFilePath() == "") { |
|
234 |
node = new Group(); |
|
235 |
// } else { |
|
236 |
// node = osgDB.readNodeFile(filePath); |
|
237 |
// } |
|
242 |
if (_nodeURL == "") { |
|
243 |
node = new Group(); |
|
244 |
} else { |
|
245 |
try { |
|
246 |
node = osgDB.readNodeFile(_nodeURL); |
|
247 |
_canvas3d.getOSGViewer().setSceneData(node); |
|
248 |
} catch (LoadNodeException e) { |
|
249 |
// TODO Auto-generated catch block |
|
250 |
e.printStackTrace(); |
|
251 |
} catch (FileNotFoundException e) { |
|
252 |
// TODO Auto-generated catch block |
|
253 |
e.printStackTrace(); |
|
254 |
} |
|
255 |
} |
|
238 | 256 |
|
239 | 257 |
_canvas3d.getOSGViewer().setSceneData(node); |
240 | 258 |
} |
... | ... | |
242 | 260 |
public I3DSymbol getNewSymbol() { |
243 | 261 |
// TODO Auto-generated method stub |
244 | 262 |
_symbol = new NodeMarker3DSymbol(); |
245 |
((NodeMarker3DSymbol) _symbol).setNodeFileURL(_nodeURL); |
|
246 |
|
|
263 |
((NodeMarker3DSymbol) _symbol).setNodeFileURL(_nodeURL); |
|
247 | 264 |
return _symbol; |
248 | 265 |
} |
249 | 266 |
|
267 |
public void updatePanel(I3DSymbol symbol) { |
|
268 |
// TODO Auto-generated method stub |
|
269 |
_nodeURL = ((NodeMarker3DSymbol) symbol).getNodeFileURL(); |
|
270 |
System.out.println("Setting text" + _nodeURL); |
|
271 |
textField.setText(_nodeURL); |
|
272 |
loadFile(); |
|
273 |
} |
|
274 |
|
|
275 |
public void saveParameters() { |
|
276 |
// TODO Auto-generated method stub |
|
277 |
|
|
278 |
} |
|
279 |
|
|
280 |
public class TypeFileFilter extends FileFilter { |
|
281 |
private final String[] okFileExtensions = new String[] { "3ds", "ive", |
|
282 |
"osg" }; |
|
283 |
|
|
284 |
public boolean accept(File file) { |
|
285 |
for (String extension : okFileExtensions) { |
|
286 |
if (file.getName().toLowerCase().endsWith(extension) |
|
287 |
|| file.isDirectory()) { |
|
288 |
return true; |
|
289 |
} |
|
290 |
|
|
291 |
} |
|
292 |
return false; |
|
293 |
} |
|
294 |
|
|
295 |
@Override |
|
296 |
public String getDescription() { |
|
297 |
// TODO Auto-generated method stub |
|
298 |
return "OSG File Types"; |
|
299 |
} |
|
300 |
} |
|
301 |
|
|
250 | 302 |
} |
Also available in: Unified diff