001: /*
002: * $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/plugins/DefaultLightingPanel.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: /**
021: *
022: * A simple lighting control panel.
023: *
024: * This really needs updating to allows users to changed the colors of
025: * the lights and the position of the directional lights.
026: *
027: * @author Paul Byrne
028: * @version $Revision: 1.1 $
029: */
030: public class DefaultLightingPanel extends javax.swing.JPanel {
031:
032: private DefaultLightingPlugin plugin;
033:
034: /** Creates new form DefaultLightingPanel */
035: public DefaultLightingPanel(DefaultLightingPlugin plugin) {
036: super ();
037: this .plugin = plugin;
038: initComponents();
039:
040: // TODO update this class so it does not assume ordering of
041: // lights in the array
042: if (plugin.getLights()[0] != null) {
043: this .setEnabled(plugin.getLights()[0].isLive());
044: ambientLightEnableCB.setSelected(plugin.getLights()[0]
045: .getEnable());
046: dirLight1EnableCB.setSelected(plugin.getLights()[1]
047: .getEnable());
048: dirLight2EnableCB.setSelected(plugin.getLights()[2]
049: .getEnable());
050: } else
051: this .setEnabled(false);
052: }
053:
054: public void setEnabled(boolean enabled) {
055: super .setEnabled(enabled);
056: ambientLightEnableCB.setEnabled(enabled);
057: dirLight1EnableCB.setEnabled(enabled);
058: dirLight2EnableCB.setEnabled(enabled);
059: }
060:
061: /** This method is called from within the constructor to
062: * initialize the form.
063: * WARNING: Do NOT modify this code. The content of this method is
064: * always regenerated by the FormEditor.
065: */
066: private void initComponents() {//GEN-BEGIN:initComponents
067: java.awt.GridBagConstraints gridBagConstraints;
068:
069: lightControlsPanel = new javax.swing.JPanel();
070: ambientLightEnableCB = new javax.swing.JCheckBox();
071: dirLight1EnableCB = new javax.swing.JCheckBox();
072: dirLight2EnableCB = new javax.swing.JCheckBox();
073: jPanel2 = new javax.swing.JPanel();
074: askUserCB = new javax.swing.JCheckBox();
075: jLabel1 = new javax.swing.JLabel();
076: jLabel2 = new javax.swing.JLabel();
077:
078: setLayout(new java.awt.GridBagLayout());
079:
080: setEnabled(false);
081: lightControlsPanel.setLayout(new java.awt.GridBagLayout());
082:
083: lightControlsPanel
084: .setBorder(new javax.swing.border.EtchedBorder());
085: ambientLightEnableCB.setSelected(true);
086: ambientLightEnableCB.setText("AmbientLight");
087: ambientLightEnableCB
088: .addActionListener(new java.awt.event.ActionListener() {
089: public void actionPerformed(
090: java.awt.event.ActionEvent evt) {
091: ambientLightEnableCBActionPerformed(evt);
092: }
093: });
094:
095: gridBagConstraints = new java.awt.GridBagConstraints();
096: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
097: gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
098: lightControlsPanel
099: .add(ambientLightEnableCB, gridBagConstraints);
100:
101: dirLight1EnableCB.setSelected(true);
102: dirLight1EnableCB.setText("Directional Light 1");
103: dirLight1EnableCB
104: .addActionListener(new java.awt.event.ActionListener() {
105: public void actionPerformed(
106: java.awt.event.ActionEvent evt) {
107: dirLight1EnableCBActionPerformed(evt);
108: }
109: });
110:
111: gridBagConstraints = new java.awt.GridBagConstraints();
112: gridBagConstraints.gridx = 0;
113: gridBagConstraints.gridy = 1;
114: gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
115: lightControlsPanel.add(dirLight1EnableCB, gridBagConstraints);
116:
117: dirLight2EnableCB.setSelected(true);
118: dirLight2EnableCB.setText("Directional Light 2");
119: dirLight2EnableCB
120: .addActionListener(new java.awt.event.ActionListener() {
121: public void actionPerformed(
122: java.awt.event.ActionEvent evt) {
123: dirLight2EnableCBActionPerformed(evt);
124: }
125: });
126:
127: gridBagConstraints = new java.awt.GridBagConstraints();
128: gridBagConstraints.gridx = 0;
129: gridBagConstraints.gridy = 2;
130: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
131: gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
132: lightControlsPanel.add(dirLight2EnableCB, gridBagConstraints);
133:
134: gridBagConstraints = new java.awt.GridBagConstraints();
135: gridBagConstraints.gridx = 0;
136: gridBagConstraints.gridy = 1;
137: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
138: add(lightControlsPanel, gridBagConstraints);
139:
140: askUserCB.setText("Ask User");
141: askUserCB
142: .setToolTipText("Ask the User before adding the default lights");
143: askUserCB
144: .addActionListener(new java.awt.event.ActionListener() {
145: public void actionPerformed(
146: java.awt.event.ActionEvent evt) {
147: askUserCBActionPerformed(evt);
148: }
149: });
150:
151: jPanel2.add(askUserCB);
152:
153: gridBagConstraints = new java.awt.GridBagConstraints();
154: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
155: add(jPanel2, gridBagConstraints);
156:
157: jLabel1.setText("This is a place holder for a");
158: gridBagConstraints = new java.awt.GridBagConstraints();
159: gridBagConstraints.gridx = 0;
160: gridBagConstraints.gridy = 2;
161: gridBagConstraints.insets = new java.awt.Insets(30, 0, 0, 0);
162: add(jLabel1, gridBagConstraints);
163:
164: jLabel2.setText("a fully featured light editor");
165: gridBagConstraints = new java.awt.GridBagConstraints();
166: gridBagConstraints.gridx = 0;
167: gridBagConstraints.gridy = 3;
168: add(jLabel2, gridBagConstraints);
169:
170: }//GEN-END:initComponents
171:
172: private void askUserCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_askUserCBActionPerformed
173: // Add your handling code here:
174: plugin.setAskUser(askUserCB.isSelected());
175: }//GEN-LAST:event_askUserCBActionPerformed
176:
177: private void ambientLightEnableCBActionPerformed(
178: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ambientLightEnableCBActionPerformed
179: // Add your handling code here:
180: plugin.getLights()[0].setEnable(ambientLightEnableCB
181: .isSelected());
182: }//GEN-LAST:event_ambientLightEnableCBActionPerformed
183:
184: private void dirLight1EnableCBActionPerformed(
185: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirLight1EnableCBActionPerformed
186: // Add your handling code here:
187: plugin.getLights()[1].setEnable(dirLight1EnableCB.isSelected());
188: }//GEN-LAST:event_dirLight1EnableCBActionPerformed
189:
190: private void dirLight2EnableCBActionPerformed(
191: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirLight2EnableCBActionPerformed
192: // Add your handling code here:
193: plugin.getLights()[2].setEnable(dirLight2EnableCB.isSelected());
194: }//GEN-LAST:event_dirLight2EnableCBActionPerformed
195:
196: // Variables declaration - do not modify//GEN-BEGIN:variables
197: private javax.swing.JPanel jPanel2;
198: private javax.swing.JPanel lightControlsPanel;
199: private javax.swing.JCheckBox ambientLightEnableCB;
200: private javax.swing.JCheckBox dirLight2EnableCB;
201: private javax.swing.JCheckBox dirLight1EnableCB;
202: private javax.swing.JLabel jLabel2;
203: private javax.swing.JLabel jLabel1;
204: private javax.swing.JCheckBox askUserCB;
205: // End of variables declaration//GEN-END:variables
206:
207: }
|