/* ========================
* 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-2005, by :
* Corporate:
* Astrium SAS
* Individual:
* Ronan Ogor
*
* $Id: Java3DPlugin3D.java,v 1.7 2006/07/03 10:17:13 ogor Exp $
*
* Changes
* -------
* 10 juin 2005 : Creation date (RO);
*
*/
package jsynoptic.plugins.syn3d.java3d;
import java.util.StringTokenizer;
import javax.swing.JScrollPane;
import jsynoptic.base.Plugin;
import jsynoptic.ui.Run;
import simtools.ui.NamedElementContainer;
import simtools.ui.UserProperties;
import syn3d.ui.SceneGraphEditor;
import syn3d.ui.SceneGraphModel;
import syn3d.ui.SceneGraphTree;
import syn3d.ui.java3d.SceneGraphModelJava3D;
import syn3d.base.java3d.Java3DPluginManager;
import syn3d.base.PluginManager;
import syn3d.builtin.java3d.Java3DSyn3DBuiltin;
/**
* The Plugin3D class is the starting point to add 3D scenes in Jsynoptic.
* A Java3DPlugin3D class is related to a Java3D viewer.
*
* @author Ronan OGOR
*
*/
public class Java3DPlugin3D extends Plugin{
protected SceneGraphTree sceneTree;
protected SceneGraphEditor editor;
protected PluginManager pluginManager;
protected String pluginName;
protected SceneGraphModel tm;
protected Java3DSyn3DBuiltin mainBuiltin;
public Java3DPlugin3D(){
pluginName = new String("Java 3D Viewer");
pluginManager = ((PluginManager) new Java3DPluginManager());
mainBuiltin = (Java3DSyn3DBuiltin)pluginManager.getPlugin(Java3DSyn3DBuiltin.class);
tm = ((SceneGraphModel)new SceneGraphModelJava3D());
// Others builtins related to the Java 3D plugin
UserProperties p=Run.getProperties();
String plugins=p.getProperty("syn3d.plugins.java3d");
if(plugins!=null){
StringTokenizer st=new StringTokenizer(plugins,",;");
while(st.hasMoreTokens()){
String pn=st.nextToken();
pluginManager.register(pn);
}
}
}
/* (non-Javadoc)
* @see jsynoptic.base.Plugin#newSourceComponent(simtools.ui.NamedElementContainer)
*/
public void newSourceComponent(NamedElementContainer nec) {
if(sceneTree==null){
mainBuiltin.createFromKey("Builder",tm.getRootNode());
sceneTree = new SceneGraphTree(tm);
sceneTree.setName(pluginName);
sceneTree.setAutoHighlight(true);
editor=new SceneGraphEditor(sceneTree, pluginManager);
JScrollPane sp = new JScrollPane(sceneTree);
nec.addElement(sp, pluginName);
}
}
public SceneGraphTree getSceneTree() {
return sceneTree;
}
public SceneGraphEditor getEditor() {
return editor;
}
public PluginManager getPluginManager(){
return pluginManager;
}
}