/*
* $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/PropertiesDialog.java,v 1.1 2005/04/20 22:20:48 paulby Exp $
*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License Version
* 1.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is available at http://www.sun.com/
*
* The Original Code is the Java 3D(tm) Scene Graph Editor.
* The Initial Developer of the Original Code is Paul Byrne.
* Portions created by Paul Byrne are Copyright (C) 2002.
* All Rights Reserved.
*
* Contributor(s): Paul Byrne.
*
**/
package org.jdesktop.j3dedit.scenegrapheditor;
import javax.media.j3d.Canvas3D;
/**
* @author Paul Byrne
* @version 1.6, 01/18/02
*/
public class PropertiesDialog extends javax.swing.JDialog {
public static final int NONE_ALLOWED=0; // Best Java3D performance
public static final int READ_ALLOWED = 1; // ALLOW_READ set on all node parameters
public static final int READ_WRITE_ALLOWED = 2; // ALLOW_READ and ALLOW_WRITE set on all node parameters
public static int performanceLevel = READ_WRITE_ALLOWED;
private boolean origStereoEnable;
private boolean origDoubleBufferEnable;
private boolean gotOK; // Was the OK button pressed to exit
/** Creates new form PropertiesDialog */
public PropertiesDialog(java.awt.Frame parent,boolean modal) {
super (parent, modal);
initComponents ();
pack ();
javax.swing.ButtonGroup performanceGroup = new javax.swing.ButtonGroup();
performanceGroup.add( minimumCapabilityRB );
performanceGroup.add( readCapabilityRB );
performanceGroup.add( readWriteCapabilityRB );
setPerformanceLevel( performanceLevel );
}
public void setPerformanceLevel( int level ) {
performanceLevel = level;
switch( level ) {
case NONE_ALLOWED:
minimumCapabilityRB.setSelected( true );
break;
case READ_ALLOWED:
readCapabilityRB.setSelected( true );
break;
case READ_WRITE_ALLOWED:
readWriteCapabilityRB.setSelected( true );
break;
default:
throw new RuntimeException("Bad Performance Level "+level);
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
java.awt.GridBagConstraints gridBagConstraints;
jPanel2 = new javax.swing.JPanel();
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
jPanel5 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
stereoEnableCB = new javax.swing.JCheckBox();
doubleBufferEnableCB = new javax.swing.JCheckBox();
jPanel3 = new javax.swing.JPanel();
minimumCapabilityRB = new javax.swing.JRadioButton();
readCapabilityRB = new javax.swing.JRadioButton();
readWriteCapabilityRB = new javax.swing.JRadioButton();
setModal(true);
setName("PropertiesDialog");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
public void windowActivated(java.awt.event.WindowEvent evt) {
formWindowActivated(evt);
}
});
okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
jPanel2.add(okButton);
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
jPanel2.add(cancelButton);
getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
jPanel5.setLayout(new java.awt.GridBagLayout());
jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS));
jPanel4.setBorder(new javax.swing.border.TitledBorder("Canvas3D Controls"));
stereoEnableCB.setText("Stereo Enable");
stereoEnableCB.setToolTipText("Display Canvas3D contents in Stereo");
stereoEnableCB.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
stereoEnableCBStateChanged(evt);
}
});
jPanel4.add(stereoEnableCB);
doubleBufferEnableCB.setText("Double Buffer Enable");
doubleBufferEnableCB.setToolTipText("Enable Double Buffering");
doubleBufferEnableCB.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
doubleBufferEnableStateChanged(evt);
}
});
jPanel4.add(doubleBufferEnableCB);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel5.add(jPanel4, gridBagConstraints);
jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS));
jPanel3.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), "Java3D Performance"));
jPanel3.setToolTipText("\nJava3D uses Capabilities to allow the runtime system to optimise\nthe SceneGraph for maximum performance. In general the\nfewer Capabilities set, the more optimisations can take place and\nhence better performance is achieved.\n\nThe Java3D Editor always maintains a record of the minimal \ncapability settings for a SceneGraph. However when the tool\noperates with these minimal settings all user interactions require\nthe scene graph to be detached from the universe, often causing\nflickering.\n\nThis dialog allows you to choose the level of capabilities used\nby the Java3D Editor during editing. The minimal capability settings\nwill be stored in the output file.");
minimumCapabilityRB.setText("Minimum Capabilities");
minimumCapabilityRB.setToolTipText("Maximum Java3D Performance. The capabilities required to execute the SceneGraph are the only ones set.");
jPanel3.add(minimumCapabilityRB);
readCapabilityRB.setText("Read Capabilities");
readCapabilityRB.setToolTipText("Intermediate Java3D Performance. Capabilites are set on all nodes to allow their properties to be READ, any changes the user makes will require a scenegraph detach");
jPanel3.add(readCapabilityRB);
readWriteCapabilityRB.setText("Read/Write Capabilities");
readWriteCapabilityRB.setToolTipText("Poorest Java3D Performance. All capabilities in the SceneGraph are set allowing all changes to be made dynamically");
jPanel3.add(readWriteCapabilityRB);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel5.add(jPanel3, gridBagConstraints);
getContentPane().add(jPanel5, java.awt.BorderLayout.CENTER);
}//GEN-END:initComponents
private void cancelButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
// Add your handling code here:
stereoEnableCB.setSelected( origStereoEnable );
doubleBufferEnableCB.setSelected( origDoubleBufferEnable );
this.hide();
}//GEN-LAST:event_cancelButtonActionPerformed
private void okButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
// Add your handling code here:
gotOK = true;
this.hide();
}//GEN-LAST:event_okButtonActionPerformed
/**
* Return true if the user clicked on OK to close the Dialog
*/
public boolean exitOK() {
return gotOK;
}
private void formWindowActivated (java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
// Add your handling code here:
/*
Canvas3D canvas = WindowManager.getManager().getUserUniverse().getCanvas3D();
stereoEnableCB.setEnabled( canvas.getStereoAvailable() );
doubleBufferEnableCB.setEnabled( canvas.getDoubleBufferAvailable() );
origStereoEnable = canvas.getStereoEnable();
origDoubleBufferEnable = canvas.getDoubleBufferEnable();
stereoEnableCB.setSelected( origStereoEnable );
doubleBufferEnableCB.setSelected( origDoubleBufferEnable );
gotOK = false;
*/
}//GEN-LAST:event_formWindowActivated
private void doubleBufferEnableStateChanged (javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_doubleBufferEnableStateChanged
// Add your handling code here:
/*
Canvas3D canvas = WindowManager.getManager().getUserUniverse().getCanvas3D();
canvas.setDoubleBufferEnable( doubleBufferEnableCB.isSelected() );
*/
}//GEN-LAST:event_doubleBufferEnableStateChanged
private void stereoEnableCBStateChanged (javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_stereoEnableCBStateChanged
// Add your handling code here:
/*
Canvas3D canvas = WindowManager.getManager().getUserUniverse().getCanvas3D();
canvas.setStereoEnable( stereoEnableCB.isSelected() );
*/
}//GEN-LAST:event_stereoEnableCBStateChanged
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
setVisible (false);
dispose ();
}//GEN-LAST:event_closeDialog
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton readCapabilityRB;
private javax.swing.JPanel jPanel5;
private javax.swing.JCheckBox stereoEnableCB;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel2;
private javax.swing.JRadioButton minimumCapabilityRB;
private javax.swing.JCheckBox doubleBufferEnableCB;
private javax.swing.JButton okButton;
private javax.swing.JRadioButton readWriteCapabilityRB;
private javax.swing.JButton cancelButton;
// End of variables declaration//GEN-END:variables
}
|