ptolemy.vergil.basic
Class WithIconGraphController.NewPortAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by ptolemy.vergil.toolbox.FigureAction
          extended by ptolemy.vergil.basic.WithIconGraphController.NewPortAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
Enclosing class:
WithIconGraphController

public class WithIconGraphController.NewPortAction
extends FigureAction

An action to create a new port.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.vergil.toolbox.FigureAction
FigureAction.SourceType
 
Field Summary
private  IOPort _prototype
           
 
Fields inherited from class ptolemy.vergil.toolbox.FigureAction
CANVAS_TYPE, CONTEXTMENU_TYPE, HOTKEY_TYPE, MENUBAR_TYPE, PASTE_OFFSET, TOOLBAR_TYPE
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
WithIconGraphController.NewPortAction(IOPort prototype, java.lang.String description, int mnemonicKey)
          Create a new port that has the same input, output, and multiport properties as the specified port.
WithIconGraphController.NewPortAction(IOPort prototype, java.lang.String description, int mnemonicKey, java.lang.String[][] iconRoles)
          Create a new port that has the same input, output, and multiport properties as the specified port and has icons associated with being unselected, rollover, rollover selected, and selected.
 
Method Summary
protected  double[] _offsetFigure(double x, double y, double xOffset, double yOffset)
          Offset a figure if another figure is already at that location.
 void actionPerformed(java.awt.event.ActionEvent e)
          Create a new port.
 
Methods inherited from class ptolemy.vergil.toolbox.FigureAction
getFigure, getFrame, getSourceType, getTarget, getX, getY, offsetFigure
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_prototype

private IOPort _prototype
Constructor Detail

WithIconGraphController.NewPortAction

public WithIconGraphController.NewPortAction(IOPort prototype,
                                             java.lang.String description,
                                             int mnemonicKey)
Create a new port that has the same input, output, and multiport properties as the specified port. If the specified port is null, then a new port that is neither an input, an output, nor a multiport will be created.

Parameters:
prototype - Prototype port.
description - The description used for menu entries and tooltips.
mnemonicKey - The KeyEvent field for the mnemonic key to use in the menu.

WithIconGraphController.NewPortAction

public WithIconGraphController.NewPortAction(IOPort prototype,
                                             java.lang.String description,
                                             int mnemonicKey,
                                             java.lang.String[][] iconRoles)
Create a new port that has the same input, output, and multiport properties as the specified port and has icons associated with being unselected, rollover, rollover selected, and selected. If the specified port is null, then a new port that is neither an input, an output, nor a multiport will be created.

Parameters:
prototype - Prototype port.
description - The description used for menu entries and tooltips.
mnemonicKey - The KeyEvent field for the mnemonic key to use in the menu.
iconRoles - A matrix of Strings, where each element consists of two Strings, the absolute URL of the icon and the key that represents the role of the icon. The keys are usually static fields from this class, such as GUIUtilities.LARGE_ICON, GUIUtilities.ROLLOVER_ICON, GUIUtilities.ROLLOVER_SELECTED_ICON or GUIUtilities.SELECTED_ICON. If this parameter is null, then the icon comes from the calling getNodeRenderer() on the WithIconGraphController._portController.
See Also:
GUIUtilities.addIcons(Action, String[][])
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Create a new port.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Overrides:
actionPerformed in class FigureAction
Parameters:
e - The event.

_offsetFigure

protected double[] _offsetFigure(double x,
                                 double y,
                                 double xOffset,
                                 double yOffset)
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.
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.