/* ========================
* 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: Java3DSyn3DBuiltin.java,v 1.2 2005/10/17 15:15:15 ogor Exp $
*
* Changes
* -------
* 19-Mar-2004 : Creation date (NB);
*
*/
package syn3d.builtin.java3d;
import syn3d.base.ActiveNode;
import syn3d.builtin.ControlledSyn3DBuiltin;
import syn3d.nodes.BuilderNode;
import syn3d.nodes.GroupNode;
import syn3d.nodes.NodeResourcesManager;
import syn3d.nodes.RootNode;
import syn3d.nodes.java3d.BranchGroupNodeJava3D;
import syn3d.nodes.java3d.BuilderNodeJava3D;
import syn3d.nodes.java3d.CubeNodeJava3D;
import syn3d.nodes.java3d.LoaderNodeJava3D;
import syn3d.nodes.java3d.SceneNodeJava3D;
import syn3d.nodes.java3d.SphereNodeJava3D;
import syn3d.nodes.java3d.SwitchNodeJava3D;
import syn3d.nodes.java3d.TransformGroupNodeJava3D;
import syn3d.nodes.java3d.LoaderHandlerJava3D;
/**
* This plugin provides all basic types for a Java3D scene graph
*
* @author Nicolas Brodu
*/
public class Java3DSyn3DBuiltin extends ControlledSyn3DBuiltin {
protected static String[] nodeTypes = {
NodeResourcesManager.getResources().getString("Loader"),
NodeResourcesManager.getResources().getString("Scene"),
NodeResourcesManager.getResources().getString("BranchGroup"),
NodeResourcesManager.getResources().getString("Switch"),
NodeResourcesManager.getResources().getString("TransformGroup"),
NodeResourcesManager.getResources().getString("Sphere"),
NodeResourcesManager.getResources().getString("Cube"),
NodeResourcesManager.getResources().getString("Builder"),
};
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("Builder")))
return parent instanceof RootNode;
if (node.equals(NodeResourcesManager.getResources().getString("Scene")))
return parent instanceof BuilderNode;
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;
else if (node.equals(NodeResourcesManager.getResources().getString("Loader")))
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("Builder")))
return new BuilderNodeJava3D(parent, pluginManager);
if (node.equals(NodeResourcesManager.getResources().getString("Scene")))
return new SceneNodeJava3D(parent, pluginManager);
else if (node.equals(NodeResourcesManager.getResources().getString("BranchGroup")))
return new BranchGroupNodeJava3D(parent);
else if (node.equals(NodeResourcesManager.getResources().getString("TransformGroup")))
return new TransformGroupNodeJava3D(parent);
else if (node.equals(NodeResourcesManager.getResources().getString("Switch")))
return new SwitchNodeJava3D(parent);
else if (node.equals(NodeResourcesManager.getResources().getString("Sphere")))
return new SphereNodeJava3D(parent);
else if (node.equals(NodeResourcesManager.getResources().getString("Cube")))
return new CubeNodeJava3D(parent);
else if (node.equals(NodeResourcesManager.getResources().getString("Loader"))) {
LoaderHandlerJava3D h = new LoaderHandlerJava3D();
if (h.select() && h.load())
return new LoaderNodeJava3D(parent,h);
else
return null;
}
return null;
}
}