/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info: http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2007, by :
* Corporate:
* EADS Astrium
* Individual:
* Claude Cazenave
*
* $Id: AnimatorNode.java,v 1.12 2008/11/14 17:03:14 cazenave Exp $
*
* Changes
* -------
* 14 janv. 08 : Initial public release
*
*/
package jsynoptic.plugins.java3d.tree;
import java.util.ArrayList;
import javax.media.j3d.Group;
import javax.media.j3d.SceneGraphObject;
import jsynoptic.plugins.java3d.Animator;
import jsynoptic.plugins.java3d.GraphObjectReference;
import jsynoptic.plugins.java3d.SceneGraphObjectHolder;
import jsynoptic.plugins.java3d.Universe;
/**
* Base class for animator nodes
*/
public class AnimatorNode extends SceneGraphTreeNode {
/**
* Register nodes resources and actions
*/
static void loadResources(){
TransformAnimatorNode.loadTransformResources();
SwitchAnimatorNode.loadSwitchResources();
Tuple3fAnimatorNode.loadTuple3fResources();
addActions( "jsynoptic.plugins.java3d.Animator",NoDefaultAction,PropertiesAction.class);
}
// required for dynamic node creation
public AnimatorNode(Tree tree, Object graphObject, boolean getChildren) {
super(tree, graphObject, getChildren);
}
/* (non-Javadoc)
* @see jsynoptic.plugins.java3d.tree.AbstractNode#getChildrenNodeClass(java.lang.Object)
*/
@Override
protected Class<? extends AbstractNode> getChildrenNodeClass(Object sceneGraphObject) {
return ReferenceNode.class;
}
/* (non-Javadoc)
* @see jsynoptic.plugins.java3d.tree.AbstractNode#getSceneGraphChildren(java.util.ArrayList)
*/
@Override
protected void getSceneGraphChildren(ArrayList<Object> list) {
Animator n=(Animator)getGraphObject();
list.addAll(n.getGraphObjects());
}
@Override
public SceneGraphObject addSceneGraphObject(SceneGraphObject obj){
addRef(obj);
refresh();
return null;
}
@Override
public void removeSceneGraphObject(SceneGraphObject obj, SceneGraphObject oldObj){
if(obj instanceof GraphObjectReference){
removeRef((GraphObjectReference)obj);
refresh();
return;
}
throw new RuntimeException("addSceneGraphObject invalid argument ="+obj.getClass());
}
public void addRef(SceneGraphObject o) {
Animator a=(Animator)getGraphObject();
boolean forced=forceCapability(Group.ALLOW_CHILDREN_EXTEND);
SceneGraphObjectHolder res=Universe.findHolder(this, o);
a.addGraphObject(o, res.getSceneGraphNode() , _ad);
if(forced) restoreCapability(Group.ALLOW_CHILDREN_EXTEND);
}
public void removeRef(GraphObjectReference r) {
Animator a=(Animator)getGraphObject();
boolean forced=forceCapability(Group.ALLOW_CHILDREN_WRITE);
a.removeGraphObject(r, _ad);
if(forced) restoreCapability(Group.ALLOW_CHILDREN_WRITE);
}
}