syn3d.base
Class Syn3DPlugin

java.lang.Object
  extended by syn3d.base.Syn3DPlugin
Direct Known Subclasses:
ControlledSyn3DBuiltin, Java3DXYZResultSyn3DPlugin

public class Syn3DPlugin
extends java.lang.Object

This is the entry point to extend Syn3D. Plugins may bring in Shapes and other 3D elements for the scene graph. Together with the ActiveNode interface, each node can handle its own actions. In addition, plugins will automatically be passed events if implementing the mouse or keyboard Swing listeners (ex: MouseMotionListener). Empty methods are provided, so the plugin acts as a developer-friendly Adaptator object. Additionally, the event source has been set to the Scene Node object initiating the event, so it is easy to act on the scene. Warning: All handlers are called, in unspecified order. This allows to easily implement additional key events in your plugin, for example. Default handlers are provided by the builtin plugin. It is possible to de-activate them if necessary : use the PluginManager to find the builtin reference, and use its API.

Author:
nicolas brodu

Field Summary
protected  PluginManager pluginManager
          A reference to the pluginManager whitch manages the scene
 
Constructor Summary
Syn3DPlugin()
           
 
Method Summary
 boolean canCreate(java.lang.String node, ActiveNode parent)
          This method is used for screne graph building, and should be fast.
 ActiveNode create(java.lang.String node, ActiveNode parent)
          Node factory.
 ActiveNode createFromKey(java.lang.String key, ActiveNode parent)
          Utility wrapper method to create a node of a known type without resorting to reading the resources...
 java.lang.String[] getNodes()
          This plugin may bring its own nodes for the scene graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pluginManager

protected PluginManager pluginManager
A reference to the pluginManager whitch manages the scene

Constructor Detail

Syn3DPlugin

public Syn3DPlugin()
Method Detail

getNodes

public java.lang.String[] getNodes()
This plugin may bring its own nodes for the scene graph. It should return here the names for the node types it can create. Tip: It is possible to gather the types by categories, using "|" in the strings. ex: "Shapes|Sphere", "Shapes|Cube", "Branch|Switch", "Branch|Group"... In popup menus, entries in the same categories are gathered in the same sub-menu

Returns:
An array of node types. An empty array or null is accepted if this plugin does not bring new nodes

canCreate

public boolean canCreate(java.lang.String node,
                         ActiveNode parent)
This method is used for screne graph building, and should be fast. It determines what nodes can be added to a given node in the scene graph. This operation may be supported only for a given underlying 3D platform (Xith3D, Java3D), so check this too. Tip : check if the parent 3D object corresponds to a 3D architecture this plugin handles.

Parameters:
node - A node type, previously returned by the getNodes() method
parent - The candidate node on which the systems want to know if a new node of the given type could be added as a child.
Returns:
true if a new node of this type could be added to the parent. The new node shall not be created at this point.

create

public ActiveNode create(java.lang.String node,
                         ActiveNode parent)
Node factory. On successful return from canCreate(...), the user may select a node type handled by this plugin. This method is responsible for creating such a node, and it is also responsible for attaching the 3D object it refers to as a child to the parent node 3Dobject. Note: The 3D platform used is the same as in canCreate, of course.

Parameters:
node - A node type, previously returned by the getNodes() method
parent - The existing node on which to attach the new node as a child.
Returns:
A valid ActiveNode, attached to the given parent. null is permitted if something has changed since the moment when canCreate was called and the node cannot be created now. (no thread synchronization, so it may happen).

createFromKey

public ActiveNode createFromKey(java.lang.String key,
                                ActiveNode parent)
Utility wrapper method to create a node of a known type without resorting to reading the resources...