/*
* $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/nodeeditors/panels/primitive/ColorCubeEditor.java,v 1.1 2005/04/20 22:21:14 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 Jan Becicka.
* Portions created by Jan Becicka are Copyright (C) 2002.
* All Rights Reserved.
*
* Contributor(s): Jan Becicka.
*
**/
package org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.primitive;
import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.PrimitiveGeometryPanel;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.Shape3D;
import org.jdesktop.j3dedit.scenegraph.SGNode;
import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.EditorPanelContainer;
import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.NodeEditorPanelTemplate;
import javax.media.j3d.Node;
import javax.media.j3d.Group;
/**
* @author Jan Becicka
* @version
*/
public class ColorCubeEditor extends NodeEditorPanelTemplate {
ColorCubeSizePanel colorCubeSizePanel;
/** Creates new form BoxPanel */
public ColorCubeEditor() {
super();
add( colorCubeSizePanel = new ColorCubeSizePanel() );
}
public void startEdit( SGNode node, EditorPanelContainer frame ) {
this.node = node;
parentFrame = frame;
parentFrame.setTitle( "ColorCube" );
setControls();
}
public void setControls() {
ColorCube sph = (ColorCube) node.getJ3dNode();
colorCubeSizePanel.setScale(sph.getScale());
super.setControls();
}
public void applyChanges() {
super.applyChanges();
ColorCube sph = (ColorCube) node.getJ3dNode();
boolean wasLive = node.getContext().getLocale().getLive();
node.getContext().getLocale().setLive(false);
ColorCube temp = new ColorCube(
colorCubeSizePanel.getScale());
replaceNode(temp);
node.getContext().getLocale().setLive(wasLive);
}
protected void replaceNode(Node n) {
Node j3dnode = node.getJ3dNode();
Group parent = (Group) j3dnode.getParent();
int i = 0;
while (parent.getChild(i)!=j3dnode) i++;
parent.removeChild(i);
parent.insertChild(n, i);
node.setJ3dNode(n);
}
}
|