NCSA Portfolio

ncsa.j3d.ui.tools
Class ToolManager

java.lang.Object
  |
  +--ncsa.j3d.ui.tools.ToolManager

public class ToolManager
extends java.lang.Object
implements ToolManagerInterface

ToolManager is responsible for managing tools. It holds them all and allows selection between them. See ToolManagerInterface to see how this class functions.

EXAMPLE:

Canvas3D canvas;

BranchGroup bg;

TransformGroup tg; //The transform group above the ViewPlatform.

initialize these variables

ToolManager tm = new ToolManager();

tm.setViewTransform(tg); tm.setBranchGroup(bg); tm.setCanvas(canvas); tm.initialize(); //Loads portfolio.properties and configures itself.

Please note that if the ToolManager is not configured properly with all the set methods indicated above, when some of the tools are loaded they could fail miserably.


Method Summary
 void addActive(PortfolioEventReceiver i)
          Adds this object into the list of active receivers.
 void addEventSource(java.lang.Object object)
          Adds an event to the toolmanager that is not based on PortfolioEvent.
 void addInactive(PortfolioEventReceiver i)
          Adds an object into the list of possible object to receive events.
 void addPortfolioEvent(PortfolioEvent event)
          Adds a Portfolio event to the group of events that are reporting to this tool manager.
 javax.media.j3d.BranchGroup getBranchGroup()
          This method allows objects to determine which BranchGroup the ToolManager is controlling.
 javax.media.j3d.Canvas3D getCanvas()
          This method allows objects to determine which Canvas3D the ToolManager is controlling.
 java.lang.String[] getToolNames()
          This returns a string listing of names of Tools.
 javax.media.j3d.TransformGroup getViewTransform()
          Allows the retrieval of the view transform.
static ToolManager instance()
           
 void loadTools()
          This is the function that is called to load the tools in.
 void makeActive(PortfolioEventReceiver i)
          Makes an object that has already been added into the list of objects that can receive events active.
 void makeInactive(PortfolioEventReceiver i)
          Makes an object inactive.
 boolean notify(java.util.EventObject e)
          This beginning of the PortfolioEvent bus.
 void remove(PortfolioEventReceiver i)
          Removes an object from the ToolManager.
 void setActiveTool(int index)
          Changes the active tool.
 void setActiveTool(ToolInterface i)
          Changes the active tool.
 void setBranchGroup(javax.media.j3d.BranchGroup bg)
          This method allows the BranchGroup to be specified.
 void setCanvas(javax.media.j3d.Canvas3D c)
          This method allows the Canvas to be specified.
 void setViewTransform(javax.media.j3d.TransformGroup t)
          Allows the viewing transform to be set so that tools can access this.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static ToolManager instance()

loadTools

public void loadTools()
This is the function that is called to load the tools in.

setViewTransform

public void setViewTransform(javax.media.j3d.TransformGroup t)
Allows the viewing transform to be set so that tools can access this.
Parameters:
t - The transform above the ViewPlatform.

getViewTransform

public javax.media.j3d.TransformGroup getViewTransform()
Allows the retrieval of the view transform.
Specified by:
getViewTransform in interface ToolManagerInterface
Returns:
TransformGroup The transform above the ViewingPlatform

setBranchGroup

public void setBranchGroup(javax.media.j3d.BranchGroup bg)
This method allows the BranchGroup to be specified. This is the branch group that will be handed off to the tools.
Parameters:
bg - The new branch group.

getBranchGroup

public javax.media.j3d.BranchGroup getBranchGroup()
This method allows objects to determine which BranchGroup the ToolManager is controlling.
Specified by:
getBranchGroup in interface ToolManagerInterface
Returns:
The BranchGroup the ToolManager is using.

setCanvas

public void setCanvas(javax.media.j3d.Canvas3D c)
This method allows the Canvas to be specified. This is the canvas that will bew handed off to the tools.
Parameters:
c - The new Canvas

getCanvas

public javax.media.j3d.Canvas3D getCanvas()
This method allows objects to determine which Canvas3D the ToolManager is controlling.
Specified by:
getCanvas in interface ToolManagerInterface
Returns:
The Canvas3D the ToolManager is using.

addPortfolioEvent

public void addPortfolioEvent(PortfolioEvent event)
Adds a Portfolio event to the group of events that are reporting to this tool manager. This automatically inserts the event into the scene graph and initializes it.
Specified by:
addPortfolioEvent in interface ToolManagerInterface
Parameters:
event - The event to add.

addEventSource

public void addEventSource(java.lang.Object object)
Adds an event to the toolmanager that is not based on PortfolioEvent.
Parameters:
object - The object that will send events to me.

setActiveTool

public void setActiveTool(ToolInterface i)
Changes the active tool. This automatically stops the current tool from receiving events, further it removes it from the display if it has a visual component.
Specified by:
setActiveTool in interface ToolManagerInterface
Parameters:
tool - The tool to make active.

setActiveTool

public void setActiveTool(int index)
Changes the active tool. This automatically stops the current tool from receiving events.
Parameters:
index - The index of the tool to make active.

addInactive

public void addInactive(PortfolioEventReceiver i)
Adds an object into the list of possible object to receive events. This does not make this object active and it won't receive events until it is made active.
Specified by:
addInactive in interface ToolManagerInterface
Parameters:
i - The event receiver to add.

addActive

public void addActive(PortfolioEventReceiver i)
Adds this object into the list of active receivers. If it is a tool it is made active and the current tool is made inactive.
Parameters:
i - The object to be added.

makeActive

public void makeActive(PortfolioEventReceiver i)
Makes an object that has already been added into the list of objects that can receive events active. If this object is a Tool, then it is made active and the current tool is made inactive.
Parameters:
i - The object to make active.

makeInactive

public void makeInactive(PortfolioEventReceiver i)
Makes an object inactive. It will no longer receive events until it is activated again.
Specified by:
makeInactive in interface ToolManagerInterface
Parameters:
i - The object to make inactive.

remove

public void remove(PortfolioEventReceiver i)
Removes an object from the ToolManager. It is removed irregardless of where it is.
Specified by:
remove in interface ToolManagerInterface
Parameters:
i - The object to remove.

notify

public boolean notify(java.util.EventObject e)
This beginning of the PortfolioEvent bus.
Parameters:
e - The object to distribute.

getToolNames

public java.lang.String[] getToolNames()
This returns a string listing of names of Tools.
Returns:
String[] The names of all the tools.

NCSA Portfolio

NCSA Portfolio, Copyright 1997-1999, National Center for Supercomputing Applications, University of Illinois Urbana-Champaign, All Rights Reserved