Package ptolemy.vergil.basic
Class BasicGraphController
- java.lang.Object
-
- diva.graph.AbstractGraphController
-
- ptolemy.vergil.basic.BasicGraphController
-
- All Implemented Interfaces:
GraphController
,DebugListener
,ValueListener
- Direct Known Subclasses:
EditIconGraphController
,WithIconGraphController
public abstract class BasicGraphController extends AbstractGraphController implements DebugListener, ValueListener
A base class for Ptolemy II graph controllers. This extends the base class with an association with a configuration. The configuration is central to a Ptolemy GUI, and is used by derived classes to perform various functions such as opening models or their documentation. The class also provides a strategy pattern interface for a controller to add commands to the menu or toolbar of the frame it is controlling.- Since:
- Ptolemy II 2.0
- Version:
- $Id$
- Author:
- Steve Neuendorffer and Edward A. Lee
- Pt.AcceptedRating:
- Red (johnr)
- Pt.ProposedRating:
- Red (eal)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BasicGraphController.OpenBaseClassAction
An action that will open the base class of a subclass or the class of an instance.static class
BasicGraphController.SchematicContextMenuFactory
Factory for context menus.class
BasicGraphController.UnitSolverDialogAction
An action that will create a UnitSolverDialog.
-
Field Summary
Fields Modifier and Type Field Description protected Figure
_animated
Currently animated state, if any.protected SelectionRenderer
_animationRenderer
Renderer for animation.protected static ConfigureAction
_configureAction
The configure action.protected static MenuActionFactory
_configureMenuFactory
The submenu for configure actions.protected MenuCreator
_menuCreator
The interactor for creating context sensitive menus on the graph itself.protected PtolemyMenuFactory
_menuFactory
The factory belonging to the menu creator.protected BasicGraphController.OpenBaseClassAction
_openBaseClassAction
The open base class action.protected BasicGraphController.UnitSolverDialogAction
_unitSolverDialogAction
The UnitSolverDialog action.
-
Constructor Summary
Constructors Constructor Description BasicGraphController()
Create a new basic controller.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_addHotKeys(JGraph jgraph)
Add hot keys to the actions in the given JGraph.protected boolean
_areThereActiveErrorHighlights()
Return true if there are active highlights.protected void
_createControllers()
Create the controllers for nodes in this graph.protected ChangeRequest
_getClearAllErrorHighlightsChangeRequest()
Return a change request that clears all the highlights.protected void
_initializeInteraction(NamedObjController controller)
Initialize interactions for the specified controller.void
addToMenuAndToolbar(javax.swing.JMenu menu, javax.swing.JToolBar toolbar)
Add commands to the specified menu and toolbar, as appropriate for this controller.void
clearAllErrorHighlights()
Request a change that clears all the error highlights.void
clearAnimation()
Clear any animation highlight that might currently be active.void
event(DebugEvent event)
React to an event.long
getAnimationDelay()
Get the time delay for animation.Configuration
getConfiguration()
Return the configuration that has been specified by setConfiguration(), or null if none.MenuActionFactory
getConfigureMenuFactory()
Return the configuration menu factory.BasicGraphFrame
getFrame()
Get the graph frame, or null if there is none.NodeController
getNodeController(java.lang.Object object)
Return the node controller appropriate for the given object.void
highlightError(Nameable culprit)
Highlight the specified object and all its containers to indicate that it is the source of an error.protected void
initializeInteraction()
Initialize all interaction on the graph pane.void
message(java.lang.String message)
React to a debug message.void
setAnimationDelay(long time)
Set the time delay for animation.void
setConfiguration(Configuration configuration)
Set the configuration.void
setFigure(java.lang.Object semanticObject, Figure figure)
Set the figure associated with the given semantic object, and if that semantic object is Settable, then set up a value listener so that if its value changes, then the valueChanged() method is invoked.void
setFrame(BasicGraphFrame frame)
Set the graph frame.void
valueChanged(Settable settable)
React to the fact that the specified Settable has changed.-
Methods inherited from class diva.graph.AbstractGraphController
addEdge, addEdge, addGraphViewListener, addNode, addNode, addNode, addNode, clear, clearEdge, clearNode, dispatch, drawEdge, drawNode, drawNode, getEdgeController, getFigure, getGraphModel, getGraphPane, getSelectionModel, removeEdge, removeGraphViewListener, removeNode, rerender, rerenderEdge, rerenderNode, setGraphModel, setGraphPane, setSelectionModel
-
-
-
-
Field Detail
-
_animated
protected Figure _animated
Currently animated state, if any.
-
_animationRenderer
protected SelectionRenderer _animationRenderer
Renderer for animation.
-
_configureAction
protected static ConfigureAction _configureAction
The configure action.
-
_configureMenuFactory
protected static MenuActionFactory _configureMenuFactory
The submenu for configure actions.
-
_menuCreator
protected MenuCreator _menuCreator
The interactor for creating context sensitive menus on the graph itself.
-
_menuFactory
protected PtolemyMenuFactory _menuFactory
The factory belonging to the menu creator.
-
_openBaseClassAction
protected BasicGraphController.OpenBaseClassAction _openBaseClassAction
The open base class action.
-
_unitSolverDialogAction
protected BasicGraphController.UnitSolverDialogAction _unitSolverDialogAction
The UnitSolverDialog action.
-
-
Method Detail
-
clearAllErrorHighlights
public void clearAllErrorHighlights()
Request a change that clears all the error highlights.
-
highlightError
public void highlightError(Nameable culprit)
Highlight the specified object and all its containers to indicate that it is the source of an error.- Parameters:
culprit
- The culprit.
-
addToMenuAndToolbar
public void addToMenuAndToolbar(javax.swing.JMenu menu, javax.swing.JToolBar toolbar)
Add commands to the specified menu and toolbar, as appropriate for this controller. In this base class, nothing is added.- Parameters:
menu
- The menu to add to, or null if none.toolbar
- The toolbar to add to, or null if none.
-
clearAnimation
public void clearAnimation()
Clear any animation highlight that might currently be active.
-
event
public void event(DebugEvent event)
React to an event. This base class does nothing.- Specified by:
event
in interfaceDebugListener
- Parameters:
event
- The debug event.
-
getAnimationDelay
public long getAnimationDelay()
Get the time delay for animation. After highlighting, derived classes are expected to sleep for the specified amount of time, in milliseconds.- Returns:
- The animation delay set by setAnimationDelay().
- See Also:
setAnimationDelay(long)
-
getConfiguration
public Configuration getConfiguration()
Return the configuration that has been specified by setConfiguration(), or null if none.- Returns:
- The configuration.
- See Also:
setConfiguration(Configuration)
-
getConfigureMenuFactory
public MenuActionFactory getConfigureMenuFactory()
Return the configuration menu factory.- Returns:
- The configuration menu factory.
-
getFrame
public BasicGraphFrame getFrame()
Get the graph frame, or null if there is none. This is used by some of the controllers to mark the modified bit of the frame and to update any dependents.- Returns:
- The graph frame, or null if there is none.
- See Also:
setFrame(BasicGraphFrame)
-
getNodeController
public NodeController getNodeController(java.lang.Object object)
Return the node controller appropriate for the given object. In this base class, the method checks to see whether the object is an instance of Locatable and contains a NodeControllerFactory (which is an attribute). If it does, then it invokes that factory to create a node controller. Otherwise, it returns null.- Specified by:
getNodeController
in interfaceGraphController
- Specified by:
getNodeController
in classAbstractGraphController
- Parameters:
object
- The object to get a controller for.- Returns:
- A custom node controller if there is one, and null otherwise.
-
message
public void message(java.lang.String message)
React to a debug message. This base class does nothing.- Specified by:
message
in interfaceDebugListener
- Parameters:
message
- The message.
-
setAnimationDelay
public void setAnimationDelay(long time)
Set the time delay for animation. After highlighting, derived classes are expected to sleep for the specified amount of time, in milliseconds. If this method is not called, or is called with argument 0, then no delay is introduced.- Parameters:
time
- Time to sleep, in milliseconds.- See Also:
getAnimationDelay()
-
setConfiguration
public void setConfiguration(Configuration configuration)
Set the configuration. This is used by some of the controllers when opening files or URLs. The configuration is checked for a "_getDocumentationActionDocPreference", which, if present, is an integer that is passed toGetDocumentationAction(int)
. This attribute is used to select the Kepler-specific KeplerDocumentationAttribute.- Parameters:
configuration
- The configuration.- See Also:
getConfiguration()
-
setFigure
public void setFigure(java.lang.Object semanticObject, Figure figure)
Set the figure associated with the given semantic object, and if that semantic object is Settable, then set up a value listener so that if its value changes, then the valueChanged() method is invoked. The semantic object is normally an attribute that implements the Locatable interface, and the value indicates the location of the object. A null figure clears the association.- Specified by:
setFigure
in interfaceGraphController
- Overrides:
setFigure
in classAbstractGraphController
- Parameters:
semanticObject
- The semantic object (normally a Locatable).figure
- The figure.
-
setFrame
public void setFrame(BasicGraphFrame frame)
Set the graph frame. This is used by some of the controllers to mark the modified bit of the frame and to update any dependents.- Parameters:
frame
- The graph frame, or null if there is none.- See Also:
getFrame()
-
valueChanged
public void valueChanged(Settable settable)
React to the fact that the specified Settable has changed. If the specified Settable implements the Locatable interface, then this method will move the figure and reroute any connections to it. This is done immediately if the caller is in the Swing event thread, but otherwise is deferred to the event thread.- Specified by:
valueChanged
in interfaceValueListener
- Parameters:
settable
- The object that has changed value.
-
_addHotKeys
protected void _addHotKeys(JGraph jgraph)
Add hot keys to the actions in the given JGraph.- Parameters:
jgraph
- The JGraph to which hot keys are to be added.
-
_createControllers
protected void _createControllers()
Create the controllers for nodes in this graph. In this base class, nothing is created. This is called by the constructor, so derived classes that override this must be careful not to reference local variables defined in the derived classes, because the derived classes will not have been fully constructed by the time this is called.
-
_areThereActiveErrorHighlights
protected boolean _areThereActiveErrorHighlights()
Return true if there are active highlights.- Returns:
- True if the list if error highlights is not empty.
-
_getClearAllErrorHighlightsChangeRequest
protected ChangeRequest _getClearAllErrorHighlightsChangeRequest()
Return a change request that clears all the highlights.- Returns:
- a change request that clears all the highlights.
-
_initializeInteraction
protected void _initializeInteraction(NamedObjController controller)
Initialize interactions for the specified controller. This method is called when a new controller is constructed. This base class does nothing, but derived classes may attach interactors to the specified controller.- Parameters:
controller
- The controller for which to initialize interaction.
-
initializeInteraction
protected void initializeInteraction()
Initialize all interaction on the graph pane. This method is called by the setGraphPane() method of the superclass. This initialization cannot be done in the constructor because the controller does not yet have a reference to its pane at that time. Regrettably, the canvas is not yet associated with the GraphPane, so you can't do any initialization that involves the canvas.- Specified by:
initializeInteraction
in classAbstractGraphController
-
-