Revision 352 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 | ||
---|---|---|
12 | 12 |
import java.io.File; |
13 | 13 |
import java.io.FileNotFoundException; |
14 | 14 |
|
15 |
import javax.swing.DefaultComboBoxModel; |
|
15 | 16 |
import javax.swing.JButton; |
17 |
import javax.swing.JComboBox; |
|
16 | 18 |
import javax.swing.JFileChooser; |
17 | 19 |
import javax.swing.JLabel; |
18 | 20 |
import javax.swing.JPanel; |
19 |
import javax.swing.JRadioButton; |
|
20 | 21 |
import javax.swing.JSpinner; |
21 | 22 |
import javax.swing.JTabbedPane; |
22 | 23 |
import javax.swing.JTextField; |
... | ... | |
29 | 30 |
import org.gvsig.gvsig3d.symbology3d.marker.ISimpleMarker3DSymbol; |
30 | 31 |
import org.gvsig.osgvp.core.osg.Group; |
31 | 32 |
import org.gvsig.osgvp.core.osg.Node; |
32 |
import org.gvsig.osgvp.core.osg.Vec3; |
|
33 | 33 |
import org.gvsig.osgvp.core.osgdb.osgDB; |
34 | 34 |
import org.gvsig.osgvp.exceptions.node.LoadNodeException; |
35 | 35 |
import org.gvsig.osgvp.viewer.IViewerContainer; |
36 | 36 |
import org.gvsig.osgvp.viewer.ViewerFactory; |
37 |
import javax.swing.JComboBox; |
|
38 |
import javax.swing.DefaultComboBoxModel; |
|
39 | 37 |
|
40 | 38 |
public class Object3DSymbolTab extends JPanel implements ISymbolSelectorTab { |
41 | 39 |
|
... | ... | |
49 | 47 |
|
50 | 48 |
private JSpinner sizeSpinner; |
51 | 49 |
|
52 |
private JComboBox _comboBox;
|
|
50 |
private JComboBox _particleComboBox;
|
|
53 | 51 |
|
52 |
private JComboBox _instancesComboBox; |
|
53 |
|
|
54 |
private String _textureURL; |
|
55 |
|
|
54 | 56 |
/** |
55 | 57 |
* Create the panel. |
56 | 58 |
*/ |
... | ... | |
112 | 114 |
public void actionPerformed(ActionEvent e) { |
113 | 115 |
|
114 | 116 |
JFileChooser fc = new JFileChooser(); |
115 |
FileFilter ff = new TypeFileFilter(); |
|
117 |
FileFilter ff = new OSGTypeFileFilter();
|
|
116 | 118 |
fc.setFileFilter(ff); |
117 | 119 |
|
118 | 120 |
int returnVal = fc.showDialog(Object3DSymbolTab.this, "Accept"); |
... | ... | |
163 | 165 |
tabbedPane.addTab("Collection", null, panel_4, null); |
164 | 166 |
GridBagLayout gbl_panel_4 = new GridBagLayout(); |
165 | 167 |
gbl_panel_4.columnWidths = new int[] { 175 }; |
166 |
gbl_panel_4.rowHeights = new int[] { 250, 45 };
|
|
167 |
gbl_panel_4.columnWeights = new double[] { 1.0 };
|
|
168 |
gbl_panel_4.rowWeights = new double[] { 1.0, 0.0 };
|
|
168 |
gbl_panel_4.rowHeights = new int[] { 180, 18, 18, 18, 18 };
|
|
169 |
gbl_panel_4.columnWeights = new double[] { 0.0 };
|
|
170 |
gbl_panel_4.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0 };
|
|
169 | 171 |
panel_4.setLayout(gbl_panel_4); |
170 | 172 |
|
171 | 173 |
JPanel panel_1 = new JPanel(); |
... | ... | |
181 | 183 |
|
182 | 184 |
panel_1.add(getAlternateOsgPanel()); |
183 | 185 |
|
184 |
_comboBox = new JComboBox();
|
|
185 |
_comboBox.addActionListener(new ActionListener() {
|
|
186 |
_particleComboBox = new JComboBox();
|
|
187 |
_particleComboBox.addActionListener(new ActionListener() {
|
|
186 | 188 |
public void actionPerformed(ActionEvent arg0) { |
187 | 189 |
|
188 | 190 |
if (arg0.getSource() instanceof JComboBox) { |
189 |
switch (_comboBox.getSelectedIndex()) {
|
|
191 |
switch (_particleComboBox.getSelectedIndex()) {
|
|
190 | 192 |
|
191 | 193 |
case 0: |
192 | 194 |
_nodeURL = Object3DSymbolTab.class.getResource( |
... | ... | |
225 | 227 |
} |
226 | 228 |
} |
227 | 229 |
}); |
228 |
_comboBox.setModel(new DefaultComboBoxModel(new String[] { "Fire", |
|
229 |
"Radial", "Space", "Flare" })); |
|
230 |
|
|
231 |
JLabel lblParticles = new JLabel("Particles:"); |
|
232 |
GridBagConstraints gbc_lblParticles = new GridBagConstraints(); |
|
233 |
gbc_lblParticles.anchor = GridBagConstraints.WEST; |
|
234 |
gbc_lblParticles.insets = new Insets(0, 0, 5, 0); |
|
235 |
gbc_lblParticles.gridx = 0; |
|
236 |
gbc_lblParticles.gridy = 1; |
|
237 |
panel_4.add(lblParticles, gbc_lblParticles); |
|
238 |
_particleComboBox.setModel(new DefaultComboBoxModel(new String[] { |
|
239 |
"Fire", "Radial", "Space", "Flare" })); |
|
230 | 240 |
GridBagConstraints gbc_comboBox = new GridBagConstraints(); |
241 |
gbc_comboBox.insets = new Insets(0, 0, 5, 0); |
|
231 | 242 |
gbc_comboBox.fill = GridBagConstraints.HORIZONTAL; |
232 | 243 |
gbc_comboBox.gridx = 0; |
233 |
gbc_comboBox.gridy = 1;
|
|
234 |
panel_4.add(_comboBox, gbc_comboBox);
|
|
244 |
gbc_comboBox.gridy = 2;
|
|
245 |
panel_4.add(_particleComboBox, gbc_comboBox);
|
|
235 | 246 |
|
247 |
JPanel panelComboInstances = new JPanel(); |
|
248 |
|
|
249 |
GridBagConstraints gbc_panelI = new GridBagConstraints(); |
|
250 |
gbc_panelI.fill = GridBagConstraints.HORIZONTAL; |
|
251 |
gbc_panelI.gridx = 0; |
|
252 |
gbc_panelI.gridy = 4; |
|
253 |
panel_4.add(panelComboInstances, gbc_panelI); |
|
254 |
GridBagLayout gbl_panelComboInstances = new GridBagLayout(); |
|
255 |
gbl_panelComboInstances.columnWidths = new int[] { 0, 0, 0 }; |
|
256 |
gbl_panelComboInstances.rowHeights = new int[] { 0 }; |
|
257 |
gbl_panelComboInstances.columnWeights = new double[] { |
|
258 |
Double.MIN_VALUE, 0.0, Double.MIN_VALUE }; |
|
259 |
gbl_panelComboInstances.rowWeights = new double[] { Double.MIN_VALUE }; |
|
260 |
panelComboInstances.setLayout(gbl_panelComboInstances); |
|
261 |
|
|
262 |
_instancesComboBox = new JComboBox(); |
|
263 |
_instancesComboBox.addActionListener(new ActionListener() { |
|
264 |
public void actionPerformed(ActionEvent arg0) { |
|
265 |
|
|
266 |
if (arg0.getSource() instanceof JComboBox) { |
|
267 |
switch (_instancesComboBox.getSelectedIndex()) { |
|
268 |
|
|
269 |
case 0: |
|
270 |
_nodeURL = Object3DSymbolTab.class.getResource( |
|
271 |
"/particle/fire.osgb").getPath(); |
|
272 |
break; |
|
273 |
case 1: |
|
274 |
_nodeURL = Object3DSymbolTab.class.getResource( |
|
275 |
"/particle/radial.osgb").getPath(); |
|
276 |
break; |
|
277 |
case 2: |
|
278 |
_nodeURL = Object3DSymbolTab.class.getResource( |
|
279 |
"/particle/space.osgb").getPath(); |
|
280 |
break; |
|
281 |
case 3: |
|
282 |
_nodeURL = Object3DSymbolTab.class.getResource( |
|
283 |
"/particle/trisistema.osgb").getPath(); |
|
284 |
break; |
|
285 |
|
|
286 |
default: |
|
287 |
break; |
|
288 |
|
|
289 |
} |
|
290 |
|
|
291 |
try { |
|
292 |
Node node = osgDB.readNodeFile(_nodeURL); |
|
293 |
_alternateCanvas3d.getOSGViewer().setSceneData(node); |
|
294 |
|
|
295 |
} catch (LoadNodeException e) { |
|
296 |
// TODO Auto-generated catch block |
|
297 |
e.printStackTrace(); |
|
298 |
} catch (FileNotFoundException e) { |
|
299 |
// TODO Auto-generated catch block |
|
300 |
e.printStackTrace(); |
|
301 |
} |
|
302 |
|
|
303 |
} |
|
304 |
} |
|
305 |
}); |
|
306 |
|
|
307 |
JLabel lblObjects = new JLabel("Geometries:"); |
|
308 |
GridBagConstraints gbc_lblObjects = new GridBagConstraints(); |
|
309 |
gbc_lblObjects.anchor = GridBagConstraints.WEST; |
|
310 |
gbc_lblObjects.insets = new Insets(0, 0, 5, 0); |
|
311 |
gbc_lblObjects.gridx = 0; |
|
312 |
gbc_lblObjects.gridy = 3; |
|
313 |
panel_4.add(lblObjects, gbc_lblObjects); |
|
314 |
_instancesComboBox.setModel(new DefaultComboBoxModel( |
|
315 |
new String[] { "Cube" })); |
|
316 |
GridBagConstraints gbc_icomboBox = new GridBagConstraints(); |
|
317 |
gbc_icomboBox.insets = new Insets(0, 0, 0, 5); |
|
318 |
gbc_icomboBox.fill = GridBagConstraints.HORIZONTAL; |
|
319 |
gbc_icomboBox.gridx = 0; |
|
320 |
gbc_icomboBox.gridy = 0; |
|
321 |
panelComboInstances.add(_instancesComboBox, gbc_icomboBox); |
|
322 |
|
|
323 |
JButton btnTexture = new JButton("Texture"); |
|
324 |
btnTexture.addActionListener(new ActionListener() { |
|
325 |
|
|
326 |
public void actionPerformed(ActionEvent arg0) { |
|
327 |
|
|
328 |
JFileChooser fc = new JFileChooser(); |
|
329 |
fc.setCurrentDirectory(new File(Object3DSymbolTab.class |
|
330 |
.getResource("/markers").getPath())); |
|
331 |
FileFilter ff = new ImageTypeFileFilter(); |
|
332 |
fc.setFileFilter(ff); |
|
333 |
|
|
334 |
ImagePreviewPanel preview = new ImagePreviewPanel(); |
|
335 |
fc.setAccessory(preview); |
|
336 |
fc.addPropertyChangeListener(preview); |
|
337 |
|
|
338 |
int returnVal = fc.showDialog(Object3DSymbolTab.this, "Accept"); |
|
339 |
|
|
340 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
|
341 |
File file = fc.getSelectedFile(); |
|
342 |
_textureURL = file.getAbsolutePath(); |
|
343 |
|
|
344 |
} else { |
|
345 |
|
|
346 |
} |
|
347 |
|
|
348 |
// _symbol.setColor(newColor); |
|
349 |
// _colorPanel.setBackground(newColor); |
|
350 |
// _colorPanel.repaint(); |
|
351 |
// symbolPreviewPanel.repaint(); |
|
352 |
// ((SymbolSelector3D) _parent).setSymbol(_symbol); |
|
353 |
|
|
354 |
} |
|
355 |
|
|
356 |
}); |
|
357 |
GridBagConstraints gbc_btnTexture = new GridBagConstraints(); |
|
358 |
gbc_btnTexture.gridx = 1; |
|
359 |
gbc_btnTexture.gridy = 0; |
|
360 |
panelComboInstances.add(btnTexture, gbc_btnTexture); |
|
361 |
|
|
236 | 362 |
} |
237 | 363 |
|
238 | 364 |
private JPanel getOsgPanel() { |
... | ... | |
319 | 445 |
|
320 | 446 |
} |
321 | 447 |
|
322 |
public class TypeFileFilter extends FileFilter { |
|
448 |
public class OSGTypeFileFilter extends FileFilter {
|
|
323 | 449 |
private final String[] okFileExtensions = new String[] { "3ds", "ive", |
324 | 450 |
"osg" }; |
325 | 451 |
|
... | ... | |
340 | 466 |
return "OSG File Types"; |
341 | 467 |
} |
342 | 468 |
} |
469 |
|
|
470 |
public class ImageTypeFileFilter extends FileFilter { |
|
471 |
private final String[] okFileExtensions = new String[] { "bmp", "png", |
|
472 |
"jpg", "jpeg", "gif" }; |
|
343 | 473 |
|
474 |
public boolean accept(File file) { |
|
475 |
for (String extension : okFileExtensions) { |
|
476 |
if (file.getName().toLowerCase().endsWith(extension) |
|
477 |
|| file.isDirectory()) { |
|
478 |
return true; |
|
479 |
} |
|
480 |
|
|
481 |
} |
|
482 |
return false; |
|
483 |
} |
|
484 |
|
|
485 |
@Override |
|
486 |
public String getDescription() { |
|
487 |
// TODO Auto-generated method stub |
|
488 |
return "Image File Types"; |
|
489 |
} |
|
490 |
} |
|
491 |
|
|
344 | 492 |
} |
Also available in: Unified diff