/* ========================
* 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-2004, by :
* Corporate:
* EADS Corporate Research Center
* Individual:
* Nicolas Brodu
*
* $Id: Xith3DSyn3DBuiltin.java,v 1.1 2005/06/14 13:13:54 ogor Exp $
*
* Changes
* -------
* 19-Mar-2004 : Creation date (NB);
*
*/
package syn3d.builtin.xith3d;
import syn3d.base.ActiveNode;
import syn3d.nodes.GroupNode;
import syn3d.nodes.NodeResourcesManager;
import syn3d.nodes.RootNode;
import syn3d.nodes.xith3d.BranchGroupNodeXith3D;
import syn3d.nodes.xith3d.CubeNodeXith3D;
import syn3d.nodes.xith3d.SceneNodeXith3D;
import syn3d.nodes.xith3d.SphereNodeXith3D;
import syn3d.nodes.xith3d.SwitchNodeXith3D;
import syn3d.nodes.xith3d.TransformGroupNodeXith3D;
import syn3d.builtin.ControlledSyn3DBuiltin;
/**
* This plugin provides all basic types for a Xith3D scene graph
*
* @author Nicolas Brodu
*/
public class Xith3DSyn3DBuiltin extends ControlledSyn3DBuiltin {
protected static String[] nodeTypes = {
NodeResourcesManager.getResources().getString("Scene"),
NodeResourcesManager.getResources().getString("BranchGroup"),
NodeResourcesManager.getResources().getString("Switch"),
NodeResourcesManager.getResources().getString("TransformGroup"),
NodeResourcesManager.getResources().getString("Sphere"),
NodeResourcesManager.getResources().getString("Cube"),
};
public String[] getNodes() {
return nodeTypes;
}
/* (non-Javadoc)
* @see syn3d.base.Syn3DPlugin#canCreate(java.lang.String, syn3d.base.ActiveNode)
*/
public boolean canCreate(String node, ActiveNode parent) {
if (node==null) return false;
// TODO: express constraints directly from the underlying 3D model
// example : parent.get3DObject() instanceof XXX
// May use Xith3D / Java3D helpers for that
// example if (xith) BranchGroupNodeXith3D.canAcceptParent(parent) // static method
if (node.equals(NodeResourcesManager.getResources().getString("Scene")))
return parent instanceof RootNode;
else if (node.equals(NodeResourcesManager.getResources().getString("BranchGroup")))
return parent instanceof GroupNode;
else if (node.equals(NodeResourcesManager.getResources().getString("Switch")))
return parent instanceof GroupNode;
else if (node.equals(NodeResourcesManager.getResources().getString("TransformGroup")))
return parent instanceof GroupNode;
else if (node.equals(NodeResourcesManager.getResources().getString("Sphere")))
return parent instanceof GroupNode;
else if (node.equals(NodeResourcesManager.getResources().getString("Cube")))
return parent instanceof GroupNode;
return false;
}
/* (non-Javadoc)
* @see syn3d.base.Syn3DPlugin#create(java.lang.String, syn3d.base.ActiveNode)
*/
public ActiveNode create(String node, ActiveNode parent) {
if (node==null) return null;
if (node.equals(NodeResourcesManager.getResources().getString("Scene")))
return new SceneNodeXith3D(parent, pluginManager);
else if (node.equals(NodeResourcesManager.getResources().getString("BranchGroup")))
return new BranchGroupNodeXith3D(parent);
else if (node.equals(NodeResourcesManager.getResources().getString("TransformGroup")))
return new TransformGroupNodeXith3D(parent);
else if (node.equals(NodeResourcesManager.getResources().getString("Switch")))
return new SwitchNodeXith3D(parent);
else if (node.equals(NodeResourcesManager.getResources().getString("Sphere")))
return new SphereNodeXith3D(parent);
else if (node.equals(NodeResourcesManager.getResources().getString("Cube")))
return new CubeNodeXith3D(parent);
return null;
}
}