001: /*
002: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/nodeeditors/panels/Shape3DPanel.java,v 1.1 2005/04/20 22:21:09 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 java.awt.Frame;
021: import java.awt.image.BufferedImage;
022: import javax.media.j3d.*;
023: import org.jdesktop.j3dedit.scenegraph.SGNode;
024: import org.jdesktop.j3dedit.scenegraph.SGShape3D;
025: import org.jdesktop.j3dedit.scenegraph.SGNodeComponent;
026: import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.NodeEditorPanel;
027: import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.EditorPanelContainer;
028:
029: /**
030: * @author Paul Byrne
031: * @version $id$
032: */
033: public class Shape3DPanel extends NodeEditorPanel {
034:
035: AppearancePanel appearancePanel;
036:
037: public Shape3DPanel() {
038: super ();
039: initComponents();
040: frameTitle = "Shape3D";
041: appearancePanel = new AppearancePanel();
042:
043: appearanceP.add(appearancePanel);
044: }
045:
046: public void startEdit(SGNode node, EditorPanelContainer frame) {
047: this .node = node;
048: parentFrame = frame;
049: parentFrame.setTitle(frameTitle);
050:
051: Shape3D shape = (Shape3D) node.getJ3dNode();
052:
053: appearancePanel.startEdit(((SGShape3D) node).getSGAppearance(),
054: node, this );
055:
056: setControls();
057: }
058:
059: public void setReadOnly(boolean readOnly) {
060: this .readOnly = readOnly;
061:
062: appearancePanel.setReadOnly(readOnly);
063: }
064:
065: /**
066: * Ensure that all of the sub components of Appearance have
067: * a value other than null
068: */
069: /*
070: private void ensureNoNulls( Shape3D shape ) {
071: Appearance app = shape.getAppearance();
072: if (app==null) {
073: app = new Appearance();
074: shape.setAppearance( app );
075: }
076:
077: if (app.getMaterial()==null) {
078: Material mat = new Material();
079: app.setMaterial( mat );
080: }
081: if (app.getColoringAttributes()==null)
082: app.setColoringAttributes( new ColoringAttributes() );
083: if (app.getTransparencyAttributes()==null)
084: app.setTransparencyAttributes( new TransparencyAttributes() );
085: if (app.getRenderingAttributes()==null)
086: app.setRenderingAttributes( new RenderingAttributes() );
087: if (app.getPolygonAttributes()==null)
088: app.setPolygonAttributes( new PolygonAttributes() );
089: if (app.getLineAttributes()==null)
090: app.setLineAttributes( new LineAttributes() );
091: if (app.getPointAttributes()==null)
092: app.setPointAttributes( new PointAttributes() );
093: if (app.getTextureAttributes()==null)
094: app.setTextureAttributes( new TextureAttributes() );
095: if (app.getTexture()==null) {
096: Texture texture = new Texture2D( Texture.BASE_LEVEL, Texture.RGB,
097: 2,2 );
098: texture.setImage( 0, new ImageComponent2D(
099: ImageComponent2D.FORMAT_RGB,
100: new BufferedImage( 2, 2,
101: BufferedImage.TYPE_INT_RGB )));
102: texture.setEnable( false);
103: app.setTexture(texture);
104: }
105:
106: }*/
107:
108: /** This method is called from within the constructor to
109: * initialize the form.
110: * WARNING: Do NOT modify this code. The content of this method is
111: * always regenerated by the FormEditor.
112: */
113: private void initComponents() {//GEN-BEGIN:initComponents
114: appearanceP = new javax.swing.JPanel();
115:
116: setLayout(new java.awt.BorderLayout());
117:
118: add(appearanceP, java.awt.BorderLayout.CENTER);
119:
120: }//GEN-END:initComponents
121:
122: /**
123: * Set the GUI controls to represent node
124: * Store the state of the node so any subsequent changes
125: * can be reset
126: */
127: protected void setControls() {
128: appearancePanel.setControls();
129: setUpdateRequired(false);
130: }
131:
132: public void applyChanges() {
133: appearancePanel.applyChanges();
134: setUpdateRequired(false);
135: }
136:
137: public void resetChanges() {
138: appearancePanel.resetChanges();
139: setUpdateRequired(false);
140: }
141:
142: /**
143: * Set capability bits for read-only operations on this
144: * Nodes properties
145: */
146: protected void setReadCapabilityBits(Node node) {
147:
148: Shape3D shape = (Shape3D) node;
149: shape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
150:
151: appearancePanel.setReadCapabilityBits(shape.getAppearance());
152:
153: }
154:
155: /**
156: * Set capability bits for write-only operations on this
157: * Nodes properties.
158: *
159: * This will probably only be used by setReadWriteCapabilityBits
160: */
161: protected void setReadWriteCapabilityBits(Node node) {
162:
163: // In the event of the NodeComponents being shared with other Shape3D
164: // which are live, each NodeComponent panel must return without error
165: // even if the NodeComponnet is live.
166:
167: Shape3D shape = (Shape3D) node;
168: shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
169: shape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
170: shape.setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE);
171: shape.setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_READ);
172: appearancePanel.setReadWriteCapabilityBits(shape
173: .getAppearance());
174:
175: }
176:
177: // Variables declaration - do not modify//GEN-BEGIN:variables
178: private javax.swing.JPanel appearanceP;
179: // End of variables declaration//GEN-END:variables
180:
181: }
|