ptolemy.vergil.basic
Class WithIconGraphController

java.lang.Object
  extended by diva.graph.AbstractGraphController
      extended by ptolemy.vergil.basic.BasicGraphController
          extended by ptolemy.vergil.basic.WithIconGraphController
All Implemented Interfaces:
GraphController, DebugListener, ValueListener
Direct Known Subclasses:
RunnableGraphController

public abstract class WithIconGraphController
extends BasicGraphController

A base class for Ptolemy II graph controllers for objects that can have icons. This adds to the base class the context menu items "Edit Custom Icon" and "Remove Custom Icon". This also adds a port controller.

Since:
Ptolemy II 4.0
Version:
$Id: WithIconGraphController.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
Accepted Rating:
Red (johnr)
Proposed Rating:
Red (eal)

Nested Class Summary
 class WithIconGraphController.NewPortAction
          An action to create a new port.
 
Nested classes/interfaces inherited from class ptolemy.vergil.basic.BasicGraphController
BasicGraphController.OpenBaseClassAction, BasicGraphController.SchematicContextMenuFactory, BasicGraphController.UnitSolverDialogAction
 
Field Summary
protected static EditIconAction _editIconAction
          The edit custom icon action.
private static double _PORT_OFFSET
          Offset of ports from the visible border.
protected  NamedObjController _portController
          The port controller.
protected static RemoveIconAction _removeIconAction
          The remove custom icon action.
 
Fields inherited from class ptolemy.vergil.basic.BasicGraphController
_animated, _animationRenderer, _configureAction, _configureMenuFactory, _menuCreator, _menuFactory, _openBaseClassAction, _unitSolverDialogAction
 
Constructor Summary
WithIconGraphController()
          Create a new controller.
 
Method Summary
protected  void _createControllers()
          Create the controllers for nodes in this graph.
private static double[] _offsetFigure(double x, double y, double xOffset, double yOffset, GraphPane pane, BasicGraphFrame frame)
          Offset a figure if another figure is already at that location.
static double[] getNewPortLocation(GraphPane pane, BasicGraphFrame frame, IOPort _prototype)
          Get a location for a port that hasn't got a location yet.
protected  void initializeInteraction()
          Initialize all interaction on the graph pane.
 void setConfiguration(Configuration configuration)
          Set the configuration.
 
Methods inherited from class ptolemy.vergil.basic.BasicGraphController
_addHotKeys, _initializeInteraction, addToMenuAndToolbar, clearAnimation, event, getAnimationDelay, getConfiguration, getConfigureMenuFactory, getFrame, getNodeController, message, setAnimationDelay, setFigure, setFrame, valueChanged
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_editIconAction

protected static final EditIconAction _editIconAction
The edit custom icon action.


_portController

protected NamedObjController _portController
The port controller.


_removeIconAction

protected static final RemoveIconAction _removeIconAction
The remove custom icon action.


_PORT_OFFSET

private static double _PORT_OFFSET
Offset of ports from the visible border.

Constructor Detail

WithIconGraphController

public WithIconGraphController()
Create a new controller.

Method Detail

getNewPortLocation

public static double[] getNewPortLocation(GraphPane pane,
                                          BasicGraphFrame frame,
                                          IOPort _prototype)
Get a location for a port that hasn't got a location yet.

Parameters:
pane - The GraphPane.
frame - The BasicGraphFrame.
_prototype - The port.
Returns:
The location.

setConfiguration

public void setConfiguration(Configuration configuration)
Set the configuration. This is used by some of the controllers when opening files or URLs.

Overrides:
setConfiguration in class BasicGraphController
Parameters:
configuration - The configuration.
See Also:
BasicGraphController.getConfiguration()

_createControllers

protected void _createControllers()
Create the controllers for nodes in this graph. In this base class, a port controller with PARTIAL access 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.

Overrides:
_createControllers in class BasicGraphController

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.

Overrides:
initializeInteraction in class BasicGraphController

_offsetFigure

private static double[] _offsetFigure(double x,
                                      double y,
                                      double xOffset,
                                      double yOffset,
                                      GraphPane pane,
                                      BasicGraphFrame frame)
Offset a figure if another figure is already at that location.

Parameters:
x - The x value of the proposed location.
y - The y value of the proposed location.
xOffset - The x offset to be used if a figure is found.
yOffset - The x offset to be used if a figure is found.
pane - The GraphPane.
frame - The BasicGraphFrame.
Returns:
An array of two doubles (x and y) that represents either the original location or an offset location that does not obscure an object of class figure.