001: /*
002: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/nodeeditors/panels/PointAttributesPanel.java,v 1.1 2005/04/20 22:21:06 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 the Java 3D(tm) Scene Graph Editor.
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.j3dedit.scenegrapheditor.nodeeditors.panels;
019:
020: import javax.swing.*;
021: import javax.media.j3d.PointAttributes;
022: import javax.media.j3d.NodeComponent;
023: import javax.media.j3d.Appearance;
024:
025: import org.jdesktop.j3dfly.utils.gui.FloatDocument;
026: import org.jdesktop.j3dedit.scenegraph.SGPointAttributes;
027: import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.NodeComponentEditorPanel;
028:
029: /**
030: *
031: * @author Paul Byrne
032: * @version $Id: PointAttributesPanel.java,v 1.1 2005/04/20 22:21:06 paulby Exp $
033: */
034: public class PointAttributesPanel extends NodeComponentEditorPanel {
035:
036: private float origPointSize;
037: private boolean origAAEnable;
038: private java.awt.CardLayout cardLayout;
039: private boolean doingSetControls = false;
040:
041: /** Creates new form PointAttributesPanel */
042: public PointAttributesPanel() {
043: initComponents();
044: cardLayout = (java.awt.CardLayout) getLayout();
045: }
046:
047: public void setReadOnly(boolean readOnly) {
048: this .readOnly = readOnly;
049:
050: createAttributeB.setEnabled(!readOnly);
051: pointSizeTF.setEnabled(!readOnly);
052: antialiasingEnableCB.setEnabled(!readOnly);
053: }
054:
055: /** This method is called from within the constructor to
056: * initialize the form.
057: * WARNING: Do NOT modify this code. The content of this method is
058: * always regenerated by the FormEditor.
059: */
060: private void initComponents() {//GEN-BEGIN:initComponents
061: java.awt.GridBagConstraints gridBagConstraints;
062:
063: normalPanel = new javax.swing.JPanel();
064: jPanel1 = new javax.swing.JPanel();
065: antialiasingEnableCB = new javax.swing.JCheckBox();
066: pointSizeTF = new javax.swing.JTextField();
067: jLabel1 = new javax.swing.JLabel();
068: ncCommonP = new org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.CommonNodeComponentPanel();
069: nullPanel = new javax.swing.JPanel();
070: jPanel2 = new javax.swing.JPanel();
071: jLabel2 = new javax.swing.JLabel();
072: createAttributeB = new javax.swing.JButton();
073:
074: setLayout(new java.awt.CardLayout());
075:
076: setMinimumSize(new java.awt.Dimension(169, 100));
077: setPreferredSize(new java.awt.Dimension(169, 100));
078: jPanel1.setLayout(new java.awt.GridBagLayout());
079:
080: antialiasingEnableCB.setText("Antialiasing Enabled");
081: gridBagConstraints = new java.awt.GridBagConstraints();
082: gridBagConstraints.gridx = 0;
083: gridBagConstraints.gridy = 1;
084: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
085: jPanel1.add(antialiasingEnableCB, gridBagConstraints);
086:
087: pointSizeTF.setDocument(new FloatDocument());
088: pointSizeTF.setText("1.0");
089: pointSizeTF.setMaximumSize(new java.awt.Dimension(0, 0));
090: pointSizeTF.setMinimumSize(new java.awt.Dimension(0, 0));
091: gridBagConstraints = new java.awt.GridBagConstraints();
092: gridBagConstraints.gridx = 1;
093: gridBagConstraints.gridy = 2;
094: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
095: jPanel1.add(pointSizeTF, gridBagConstraints);
096:
097: jLabel1.setText("Point Size :");
098: gridBagConstraints = new java.awt.GridBagConstraints();
099: gridBagConstraints.gridx = 0;
100: gridBagConstraints.gridy = 2;
101: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
102: jPanel1.add(jLabel1, gridBagConstraints);
103:
104: gridBagConstraints = new java.awt.GridBagConstraints();
105: gridBagConstraints.gridwidth = 2;
106: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
107: jPanel1.add(ncCommonP, gridBagConstraints);
108:
109: normalPanel.add(jPanel1);
110:
111: add(normalPanel, "card4");
112:
113: jPanel2.setLayout(new java.awt.GridBagLayout());
114:
115: jLabel2.setFont(new java.awt.Font("Dialog", 1, 14));
116: jLabel2.setText("Attribute is Null");
117: jPanel2.add(jLabel2, new java.awt.GridBagConstraints());
118:
119: createAttributeB.setText("Create Attribute");
120: createAttributeB
121: .addActionListener(new java.awt.event.ActionListener() {
122: public void actionPerformed(
123: java.awt.event.ActionEvent evt) {
124: createAttributeBActionPerformed(evt);
125: }
126: });
127:
128: gridBagConstraints = new java.awt.GridBagConstraints();
129: gridBagConstraints.gridx = 0;
130: gridBagConstraints.gridy = 1;
131: jPanel2.add(createAttributeB, gridBagConstraints);
132:
133: nullPanel.add(jPanel2);
134:
135: add(nullPanel, "card5");
136:
137: }//GEN-END:initComponents
138:
139: private void createAttributeBActionPerformed(
140: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createAttributeBActionPerformed
141: // Add your handling code here:
142: node = new SGPointAttributes(new PointAttributes(), nodeParent
143: .getContext());
144: if (org.jdesktop.j3dedit.scenegrapheditor.PropertiesDialog.performanceLevel == org.jdesktop.j3dedit.scenegrapheditor.PropertiesDialog.READ_ALLOWED)
145: setReadCapabilityBits((NodeComponent) node.getJ3dNode());
146: else if (org.jdesktop.j3dedit.scenegrapheditor.PropertiesDialog.performanceLevel == org.jdesktop.j3dedit.scenegrapheditor.PropertiesDialog.READ_WRITE_ALLOWED)
147: setReadWriteCapabilityBits((NodeComponent) node
148: .getJ3dNode());
149:
150: ((Appearance) getParentJ3dNodeComponent())
151: .setPointAttributes((PointAttributes) node.getJ3dNode());
152: setControls();
153: cardLayout.first(this );
154:
155: ncCommonP.startEdit(node);
156: setUpdateRequired(true);
157: }//GEN-LAST:event_createAttributeBActionPerformed
158:
159: private void pointSizeTFKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_pointSizeTFKeyPressed
160: // Add your handling code here:
161: // TODO
162: System.out.println("Not Implemented");
163: }//GEN-LAST:event_pointSizeTFKeyPressed
164:
165: private void antialiasingEnableActionPerformed(
166: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_antialiasingEnableActionPerformed
167: // Add your handling code here:
168: if (doingSetControls)
169: return;
170: ((PointAttributes) node.getJ3dNode())
171: .setPointAntialiasingEnable(antialiasingEnableCB
172: .isSelected());
173: }//GEN-LAST:event_antialiasingEnableActionPerformed
174:
175: public void setControls() {
176: if (node == null || node.getJ3dNode() == null) {
177: cardLayout.last(this );
178: } else {
179: cardLayout.first(this );
180: doingSetControls = true;
181: PointAttributes pointAttr = (PointAttributes) node
182: .getJ3dNode();
183:
184: origAAEnable = pointAttr.getPointAntialiasingEnable();
185: antialiasingEnableCB.setSelected(origAAEnable);
186:
187: origPointSize = pointAttr.getPointSize();
188: pointSizeTF.setText(Float.toString(origPointSize));
189:
190: doingSetControls = false;
191: }
192: }
193:
194: public void applyChanges() {
195: if (node != null) {
196: setControls();
197: setUpdateRequired(false);
198: }
199: }
200:
201: public void resetChanges() {
202: if (node != null) {
203: PointAttributes pointAttr = (PointAttributes) node
204: .getJ3dNode();
205: pointAttr.setPointAntialiasingEnable(origAAEnable);
206: pointAttr.setPointSize(origPointSize);
207: setControls();
208: setUpdateRequired(false);
209: }
210: }
211:
212: /**
213: * Set capability bits for read-only operations on this
214: * Nodes properties
215: */
216: protected void setReadCapabilityBits(NodeComponent node) {
217: if (node == null || node.isLive())
218: return;
219:
220: node.setCapability(PointAttributes.ALLOW_ANTIALIASING_READ);
221: node.setCapability(PointAttributes.ALLOW_SIZE_READ);
222: }
223:
224: /**
225: * Set capability bits for read/write operations on this
226: * Nodes properties.
227: *
228: */
229: protected void setReadWriteCapabilityBits(NodeComponent node) {
230: if (node == null || node.isLive())
231: return;
232:
233: node.setCapability(PointAttributes.ALLOW_ANTIALIASING_READ);
234: node.setCapability(PointAttributes.ALLOW_SIZE_READ);
235: node.setCapability(PointAttributes.ALLOW_ANTIALIASING_WRITE);
236: node.setCapability(PointAttributes.ALLOW_SIZE_WRITE);
237:
238: }
239:
240: /**
241: * Get the CommonNodeComponentPanel
242: */
243: protected org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.CommonNodeComponentPanel getCommonNCPanel() {
244: return ncCommonP;
245: }
246:
247: // Variables declaration - do not modify//GEN-BEGIN:variables
248: private javax.swing.JPanel nullPanel;
249: private javax.swing.JPanel jPanel2;
250: private javax.swing.JPanel jPanel1;
251: private javax.swing.JCheckBox antialiasingEnableCB;
252: private javax.swing.JTextField pointSizeTF;
253: private javax.swing.JPanel normalPanel;
254: private org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.CommonNodeComponentPanel ncCommonP;
255: private javax.swing.JLabel jLabel2;
256: private javax.swing.JLabel jLabel1;
257: private javax.swing.JButton createAttributeB;
258: // End of variables declaration//GEN-END:variables
259:
260: }
|