001: /*
002: * $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/plugins/AppearanceAttributesPanel.java,v 1.1 2005/04/20 21:04:38 paulby Exp $
003: *
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License Version
007: * 1.0 (the "License"). You may not use this file except in compliance with
008: * the License. A copy of the License is available at http://www.sun.com/
009: *
010: * The Original Code is Java 3D(tm) Fly Through.
011: * The Initial Developer of the Original Code is Paul Byrne.
012: * Portions created by Paul Byrne are Copyright (C) 2002.
013: * All Rights Reserved.
014: *
015: * Contributor(s): Paul Byrne.
016: *
017: **/
018: package org.jdesktop.j3dfly.plugins;
019:
020: import javax.swing.JComboBox;
021: import javax.media.j3d.BranchGroup;
022: import javax.media.j3d.PolygonAttributes;
023:
024: import org.jdesktop.j3d.utils.scenegraph.traverser.ChangePolygonAttributes;
025: import org.jdesktop.j3d.utils.scenegraph.traverser.BehaviorSetEnable;
026: import org.jdesktop.j3d.utils.scenegraph.traverser.ChangeMaterial;
027: import org.jdesktop.j3d.utils.scenegraph.traverser.ChangeTextureAttributes;
028:
029: /**
030: *
031: * @author Paul Byrne
032: * @version $Revision: 1.1 $
033: */
034: public class AppearanceAttributesPanel extends javax.swing.JPanel {
035:
036: private AppearanceAttributesPlugin plugin;
037:
038: /** Creates new form RenderingAttributesPanel */
039: public AppearanceAttributesPanel(AppearanceAttributesPlugin plugin) {
040: this .plugin = plugin;
041: initComponents();
042: }
043:
044: /** This method is called from within the constructor to
045: * initialize the form.
046: * WARNING: Do NOT modify this code. The content of this method is
047: * always regenerated by the FormEditor.
048: */
049: private void initComponents() {//GEN-BEGIN:initComponents
050: java.awt.GridBagConstraints gridBagConstraints;
051:
052: lightingC = new javax.swing.JCheckBox();
053: polygonModeCB = new JComboBox(new String[] { "POLYGON_FILL",
054: "POLYGON_LINE", "POLYGON_POINT" });
055: textureEnableC = new javax.swing.JCheckBox();
056: behaviorEnableC = new javax.swing.JCheckBox();
057:
058: setLayout(new java.awt.GridBagLayout());
059:
060: lightingC.setText("Lighting Enabled");
061: lightingC.setToolTipText("Enable lighting in the model");
062: lightingC
063: .addActionListener(new java.awt.event.ActionListener() {
064: public void actionPerformed(
065: java.awt.event.ActionEvent evt) {
066: lightingCActionPerformed(evt);
067: }
068: });
069:
070: gridBagConstraints = new java.awt.GridBagConstraints();
071: gridBagConstraints.gridx = 0;
072: gridBagConstraints.gridy = 1;
073: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
074: add(lightingC, gridBagConstraints);
075:
076: polygonModeCB.setToolTipText("Select Polygon Rendering Mode");
077: polygonModeCB
078: .addActionListener(new java.awt.event.ActionListener() {
079: public void actionPerformed(
080: java.awt.event.ActionEvent evt) {
081: polygonModeCBActionPerformed(evt);
082: }
083: });
084:
085: gridBagConstraints = new java.awt.GridBagConstraints();
086: gridBagConstraints.gridx = 0;
087: gridBagConstraints.gridy = 0;
088: add(polygonModeCB, gridBagConstraints);
089:
090: textureEnableC.setSelected(true);
091: textureEnableC.setText("Texture Enabled");
092: textureEnableC
093: .setToolTipText("Enable/Disable Texture map on geometry");
094: textureEnableC
095: .addActionListener(new java.awt.event.ActionListener() {
096: public void actionPerformed(
097: java.awt.event.ActionEvent evt) {
098: textureEnableCActionPerformed(evt);
099: }
100: });
101:
102: gridBagConstraints = new java.awt.GridBagConstraints();
103: gridBagConstraints.gridx = 0;
104: gridBagConstraints.gridy = 2;
105: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
106: add(textureEnableC, gridBagConstraints);
107:
108: behaviorEnableC.setSelected(true);
109: behaviorEnableC.setText("Behaviors Enabled");
110: behaviorEnableC.setToolTipText("Set state of all Behaviors");
111: behaviorEnableC
112: .addActionListener(new java.awt.event.ActionListener() {
113: public void actionPerformed(
114: java.awt.event.ActionEvent evt) {
115: behaviorEnableCActionPerformed(evt);
116: }
117: });
118:
119: gridBagConstraints = new java.awt.GridBagConstraints();
120: gridBagConstraints.gridx = 0;
121: gridBagConstraints.gridy = 3;
122: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
123: add(behaviorEnableC, gridBagConstraints);
124:
125: }//GEN-END:initComponents
126:
127: private void polygonModeCBActionPerformed(
128: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_polygonModeCBActionPerformed
129: // Add your handling code here:
130: int mode;
131: switch (polygonModeCB.getSelectedIndex()) {
132: case 0:
133: mode = PolygonAttributes.POLYGON_FILL;
134: break;
135: case 1:
136: mode = PolygonAttributes.POLYGON_LINE;
137: break;
138: case 2:
139: mode = PolygonAttributes.POLYGON_POINT;
140: break;
141: default:
142: throw new RuntimeException("Unrecognised PolygonMode");
143: }
144:
145: plugin.setPolygonMode(mode);
146: }//GEN-LAST:event_polygonModeCBActionPerformed
147:
148: private void behaviorEnableCActionPerformed(
149: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_behaviorEnableCActionPerformed
150: // Add your handling code here:
151: plugin.setBehaviorsEnabled(behaviorEnableC.isSelected());
152: }//GEN-LAST:event_behaviorEnableCActionPerformed
153:
154: private void lightingCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lightingCActionPerformed
155: // Add your handling code here:
156: plugin.setLightsEnabled(lightingC.isSelected());
157: }//GEN-LAST:event_lightingCActionPerformed
158:
159: private void textureEnableCActionPerformed(
160: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textureEnableCActionPerformed
161: // Add your handling code here:
162: plugin.setTexturesEnabled(textureEnableC.isSelected());
163: }//GEN-LAST:event_textureEnableCActionPerformed
164:
165: // Variables declaration - do not modify//GEN-BEGIN:variables
166: private javax.swing.JCheckBox lightingC;
167: private javax.swing.JCheckBox behaviorEnableC;
168: private javax.swing.JComboBox polygonModeCB;
169: private javax.swing.JCheckBox textureEnableC;
170: // End of variables declaration//GEN-END:variables
171:
172: }
|