Package ptolemy.vergil.toolbox
Class PtolemyMenuFactory
- java.lang.Object
-
- ptolemy.vergil.toolbox.PtolemyMenuFactory
-
- All Implemented Interfaces:
MenuFactory
- Direct Known Subclasses:
BasicGraphController.SchematicContextMenuFactory
public class PtolemyMenuFactory extends java.lang.Object implements MenuFactory
A menu factory that contains a list of item factories. When asked to create a context menu, This class first takes the figure and finds the ptolemy object associated with it. Then it passes the ptolemy object to each menu item factory that it contains to add the menu items. Lastly, it returns the resulting menu. This seems simple, except for the fact that for different types of figures, and different visual notations, the mapping between figure and the interesting ptolemy object is different. Hence, Node and Edge Controllers will often need subclasses of this factory to get the correct ptolemy object.- Since:
- Ptolemy II 1.0
- Version:
- $Id$
- Author:
- Steve Neuendorffer
- Pt.AcceptedRating:
- Red (johnr)
- Pt.ProposedRating:
- Red (eal)
-
-
Constructor Summary
Constructors Constructor Description PtolemyMenuFactory(GraphController controller)
Create a new menu factory that contains no menu item factories.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected NamedObj
_getObjectFromFigure(Figure figure)
Return the Ptolemy object that the given figure represents.void
addMenuItemFactory(MenuItemFactory factory)
Add a menu item factory to this creator.JContextMenu
create(Figure figure)
Create an instance of the menu associated with this factory.GraphController
getController()
Return the graph controller that created this menu factory.java.util.List
menuItemFactoryList()
Return the list of menu item factories.void
removeMenuItemFactory(MenuItemFactory factory)
Remove the given menu item factory from the factory list.
-
-
-
Constructor Detail
-
PtolemyMenuFactory
public PtolemyMenuFactory(GraphController controller)
Create a new menu factory that contains no menu item factories.- Parameters:
controller
- The controller.
-
-
Method Detail
-
addMenuItemFactory
public void addMenuItemFactory(MenuItemFactory factory)
Add a menu item factory to this creator.- Parameters:
factory
- The menu item factory to add.
-
create
public JContextMenu create(Figure figure)
Create an instance of the menu associated with this factory.- Specified by:
create
in interfaceMenuFactory
- Parameters:
figure
- The figure for which to create a context menu.- Returns:
- The instance of the menu.
-
getController
public GraphController getController()
Return the graph controller that created this menu factory.- Returns:
- The controller.
-
menuItemFactoryList
public java.util.List menuItemFactoryList()
Return the list of menu item factories.- Returns:
- An unmodifiable list.
-
removeMenuItemFactory
public void removeMenuItemFactory(MenuItemFactory factory)
Remove the given menu item factory from the factory list.- Parameters:
factory
- The factory to be removed.
-
_getObjectFromFigure
protected NamedObj _getObjectFromFigure(Figure figure)
Return the Ptolemy object that the given figure represents. In this base class, we assume that the figure is attached to a a diva.graph.model object, and that object is attached to the correct ptolemy object. In many cases, this is not the case, and you will have to override this function.- Parameters:
figure
- The figure.- Returns:
- The Ptolemy object that the given figure represents.
-
-