Cytoscape 3.0.1 API

org.cytoscape.application.swing
Class AbstractCyAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.cytoscape.application.swing.AbstractCyAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action, MenuListener, PopupMenuListener, CyAction

public abstract class AbstractCyAction
extends AbstractAction
implements CyAction

An abstract implementation of the CyAction interface. Instead of using this class directly you should (strongly) consider implementing a TaskFactory/Task pair. Doing so will allow your action to be used outside of a Swing specific application (which the CyAction interface binds you to)!

See Also:
Serialized Form
Cytoscape Backwards Compatibility (Abstract Class): This class is abstract and meant to be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.

Field Summary
protected  KeyStroke acceleratorKeyStroke
          The accelerator keystroke, if set.
protected  boolean acceleratorSet
          Indicates whether accelerator keys have been set for the action.
protected  boolean inMenuBar
          Indicates whether the action is in a menu.
protected  boolean inToolBar
          Indicates whether the action is in the toolbar.
protected  float menuGravity
          The float value placing the action within the menu.
protected  String name
          The name of the action.
protected  String preferredMenu
          The name describing the preferred menu for the action.
protected  float toolbarGravity
          The float value placing the action within the toolbar.
protected  boolean useCheckBoxMenuItem
          Indicates whether to use a checkbox menu item.
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
AbstractCyAction(Map<String,String> configProps, CyApplicationManager applicationManager, CyNetworkViewManager networkViewManager)
          Creates a new AbstractCyAction object.
AbstractCyAction(Map<String,String> configProps, CyApplicationManager applicationManager, CyNetworkViewManager networkViewManager, TaskFactory factory)
          Creates a new AbstractCyAction object.
AbstractCyAction(Map<String,String> configProps, TaskFactory predicate)
          Creates a new AbstractCyAction object.
AbstractCyAction(String name)
          Creates a new AbstractCyAction object that is always enabled.
AbstractCyAction(String name, CyApplicationManager applicationManager, String enableFor, CyNetworkViewManager networkViewManager)
          Creates a new AbstractCyAction object that is enabled for the specific "enableFor" state.
 
Method Summary
 KeyStroke getAcceleratorKeyStroke()
          Returns the accelerator KeyStroke defined for this action.
 float getMenuGravity()
          Returns the gravity used to place the menu item for this action.
 String getName()
          Returns the name of the action.
 String getPreferredMenu()
          This method returns a Menu specification string.
 float getToolbarGravity()
          Returns the gravity used to place this action in the toolbar.
 boolean isInMenuBar()
          By default all CytoscapeActions wish to be included in the menu bar at the 'preferredMenuName' location is specified and the 'Tools' menu not.
 boolean isInToolBar()
          By default no CytoscapeActions will be included in the toolbar.
 void menuCanceled(MenuEvent e)
          This method can be used at your discretion, but otherwise does nothing.
 void menuDeselected(MenuEvent e)
          This method can be used at your discretion, but otherwise does nothing.
 void menuSelected(MenuEvent e)
          This method can be overridden by individual actions to set the state of menu items based on whatever unique circumstances that menu option cares about.
 void popupMenuCanceled(PopupMenuEvent e)
          This method can be used at your discretion, but otherwise does nothing.
 void popupMenuWillBecomeInvisible(PopupMenuEvent e)
          This method can be used at your discretion, but otherwise does nothing.
 void popupMenuWillBecomeVisible(PopupMenuEvent e)
          This method can be overridden by individual actions to set the state of menu items based on whatever unique circumstances that menu option cares about.
 void setAcceleratorKeyStroke(KeyStroke ks)
          Sets the accelerator KeyStroke for this action.
 void setMenuGravity(float gravity)
          Sets the gravity used to order this action in the menu bar.
 void setName(String name)
          Sets the name of the action.
 void setPreferredMenu(String newPreferredMenu)
          Sets the preferredMenuString.
 void setToolbarGravity(float gravity)
          Sets the gravity used to order this action in the toolbar.
 void updateEnableState()
          Triggers the enable state of the action to be updated based on the enableFor state of the action and the state of the system.
 boolean useCheckBoxMenuItem()
          Returns whether or not a checkbox menu item should be used.
 
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
 
Methods inherited from interface javax.swing.Action
addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Field Detail

preferredMenu

protected String preferredMenu
The name describing the preferred menu for the action.


menuGravity

protected float menuGravity
The float value placing the action within the menu. Value of 0.0 is the beginning and 100.0 means end of menu.


toolbarGravity

protected float toolbarGravity
The float value placing the action within the toolbar. Value of 0.0 is the beginning and 100.0 means end of menu.


acceleratorSet

protected boolean acceleratorSet
Indicates whether accelerator keys have been set for the action.


acceleratorKeyStroke

protected KeyStroke acceleratorKeyStroke
The accelerator keystroke, if set.


useCheckBoxMenuItem

protected boolean useCheckBoxMenuItem
Indicates whether to use a checkbox menu item.


inToolBar

protected boolean inToolBar
Indicates whether the action is in the toolbar.


inMenuBar

protected boolean inMenuBar
Indicates whether the action is in a menu.


name

protected String name
The name of the action.

Constructor Detail

AbstractCyAction

public AbstractCyAction(String name)
Creates a new AbstractCyAction object that is always enabled.

Parameters:
name - The name of the action.

AbstractCyAction

public AbstractCyAction(String name,
                        CyApplicationManager applicationManager,
                        String enableFor,
                        CyNetworkViewManager networkViewManager)
Creates a new AbstractCyAction object that is enabled for the specific "enableFor" state.

Parameters:
name - The name of the action.
applicationManager - The application manager providing context for this action.
enableFor - A string declaring which states this action should be enabled for.
networkViewManager - The network view manager that provides context for this action.

AbstractCyAction

public AbstractCyAction(Map<String,String> configProps,
                        CyApplicationManager applicationManager,
                        CyNetworkViewManager networkViewManager)
Creates a new AbstractCyAction object.

Parameters:
configProps - A String-String Map of configuration metadata. This will usually be the Map provided by the OSGi service configuration. Available configuration keys include:
  • title - (The title of the menu.)
  • preferredMenu - (The preferred menu for the action.)
  • largeIconURL - (The icon to be used for the toolbar.)
  • smallIconURL - (The icon to be used for the menu.)
  • tooltip - (The toolbar or menu tooltip.)
  • inToolBar - (Whether the action should be in the toolbar.)
  • inMenuBar - (Whether the action should be in a menu.)
  • enableFor - (System state that the action should be enabled for. See ActionEnableSupport for more detail.)
  • accelerator - (Accelerator key bindings.)
  • menuGravity - (Float value between 0.0 [top] and 100.0 [bottom] placing the action in the menu.)
  • toolBarGravity - (Float value between 0.0 [top] and 100.0 [bottom] placing the action in the toolbar.)
applicationManager - The application manager providing context for this action.

AbstractCyAction

public AbstractCyAction(Map<String,String> configProps,
                        TaskFactory predicate)
Creates a new AbstractCyAction object.

Parameters:
configProps - A String-String Map of configuration metadata. This will usually be the Map provided by the OSGi service configuration. Available configuration keys include:
  • title - (The title of the menu.)
  • preferredMenu - (The preferred menu for the action.)
  • largeIconURL - (The icon to be used for the toolbar.)
  • smallIconURL - (The icon to be used for the menu.)
  • tooltip - (The toolbar or menu tooltip.)
  • inToolBar - (Whether the action should be in the toolbar.)
  • inMenuBar - (Whether the action should be in a menu.)
  • enableFor - (Ingored in this constructor and TaskFactoryPredicate is used instead!)
  • accelerator - (Accelerator key bindings.)
  • menuGravity - (Float value between 0.0 [top] and 100.0 [bottom] placing the action in the menu.)
  • toolBarGravity - (Float value between 0.0 [top] and 100.0 [bottom] placing the action in the toolbar.)
predicate - The task factory predicate that indicates whether or not this action should be enabled.

AbstractCyAction

public AbstractCyAction(Map<String,String> configProps,
                        CyApplicationManager applicationManager,
                        CyNetworkViewManager networkViewManager,
                        TaskFactory factory)
Creates a new AbstractCyAction object.

Parameters:
configProps - A String-String Map of configuration metadata. This will usually be the Map provided by the OSGi service configuration. Available configuration keys include:
  • title - (The title of the menu.)
  • preferredMenu - (The preferred menu for the action.)
  • largeIconURL - (The icon to be used for the toolbar.)
  • smallIconURL - (The icon to be used for the menu.)
  • tooltip - (The toolbar or menu tooltip.)
  • inToolBar - (Whether the action should be in the toolbar.)
  • inMenuBar - (Whether the action should be in a menu.)
  • enableFor - (Will only use this value if the TaskFactory is not a TaskFactoryPredicate! See ActionEnableSupport for more detail.)
  • accelerator - (Accelerator key bindings.)
  • menuGravity - (Float value between 0.0 [top] and 100.0 [bottom] placing the action in the menu.)
  • toolBarGravity - (Float value between 0.0 [top] and 100.0 [bottom] placing the action in the toolbar.)
applicationManager - The application manager providing context for this action.
factory - The task factory that may or may not be a TaskFactoryPredicate. If it is a predicate, it will be used to indicate whether or not this action should be enabled. This TaskFactory is not used by the AbstractCyAction in any other way. Any execution of tasks from this TaskFactory must be handled by a subclass.
Method Detail

setName

public void setName(String name)
Sets the name of the action.

Parameters:
name - The name of the action.

getName

public String getName()
Returns the name of the action.

Specified by:
getName in interface CyAction
Returns:
the name of the action.

isInMenuBar

public boolean isInMenuBar()
By default all CytoscapeActions wish to be included in the menu bar at the 'preferredMenuName' location is specified and the 'Tools' menu not.

Specified by:
isInMenuBar in interface CyAction
Returns:
true if this CyAction should be included in menu bar.

isInToolBar

public boolean isInToolBar()
By default no CytoscapeActions will be included in the toolbar.

Specified by:
isInToolBar in interface CyAction
Returns:
true if this Action should be included in the toolbar.

setMenuGravity

public void setMenuGravity(float gravity)
Sets the gravity used to order this action in the menu bar.

Parameters:
gravity - The gravity for ordering menu bar actions.

getMenuGravity

public float getMenuGravity()
Returns the gravity used to place the menu item for this action. Gravity is a numeric value associated with each menu item. MenuItems in the same menu pull-down are sorted in ascending order based on their gravity values.

Specified by:
getMenuGravity in interface CyAction
Returns:
The gravity used to place the menu item for this action.

setToolbarGravity

public void setToolbarGravity(float gravity)
Sets the gravity used to order this action in the toolbar.

Parameters:
gravity - The gravity for ordering toolbar actions.

getToolbarGravity

public float getToolbarGravity()
Returns the gravity used to place this action in the toolbar. Gravity is a numeric value associated with each menu item. MenuItems in the same menu pull-down are sorted in ascending order based on their gravity values.

Specified by:
getToolbarGravity in interface CyAction
Returns:
The gravity used to place this action in the toolbar.

setAcceleratorKeyStroke

public void setAcceleratorKeyStroke(KeyStroke ks)
Sets the accelerator KeyStroke for this action.

Parameters:
ks - The KeyStroke to be used as an accelerator for this action. This parameter may be null, in which case no accelerator is defined.

getAcceleratorKeyStroke

public KeyStroke getAcceleratorKeyStroke()
Returns the accelerator KeyStroke defined for this action. Will return null if no accelerator is set.

Specified by:
getAcceleratorKeyStroke in interface CyAction
Returns:
the accelerator KeyStroke defined for this action. Will return null if no accelerator is set.

getPreferredMenu

public String getPreferredMenu()
This method returns a Menu specification string. Submenus are preceded by dots in this string, so the result "File.Import" specifies the submenu "Import" of the menu "File". If the result is null, the menu will be placed in a default location.

Specified by:
getPreferredMenu in interface CyAction
Returns:
the string identifying the preferred menu.

setPreferredMenu

public void setPreferredMenu(String newPreferredMenu)
Sets the preferredMenuString. See the getPreferredMenu() description for formatting description.

Parameters:
newPreferredMenu - The string describing the preferred menu name.

useCheckBoxMenuItem

public boolean useCheckBoxMenuItem()
Returns whether or not a checkbox menu item should be used.

Specified by:
useCheckBoxMenuItem in interface CyAction
Returns:
whether or not a checkbox menu item should be used.

menuCanceled

public void menuCanceled(MenuEvent e)
This method can be used at your discretion, but otherwise does nothing.

Specified by:
menuCanceled in interface MenuListener
Parameters:
e - The triggering event.

menuDeselected

public void menuDeselected(MenuEvent e)
This method can be used at your discretion, but otherwise does nothing.

Specified by:
menuDeselected in interface MenuListener
Parameters:
e - The triggering event.

menuSelected

public void menuSelected(MenuEvent e)
This method can be overridden by individual actions to set the state of menu items based on whatever unique circumstances that menu option cares about. By default it sets the state of the menu based on the "enableFor" property found in the properties used to construct the action. The valid options for "enableFor" are "network", "networkAndView", and "selectedNetworkObjs".

Specified by:
menuSelected in interface MenuListener
Parameters:
e - The triggering event.

popupMenuWillBecomeVisible

public void popupMenuWillBecomeVisible(PopupMenuEvent e)
This method can be overridden by individual actions to set the state of menu items based on whatever unique circumstances that menu option cares about. By default it sets the state of the menu based on the "enableFor" property found in the properties used to construct the action. The valid options for "enableFor" are "network", "networkAndView", and "selectedNetworkObjs".

Specified by:
popupMenuWillBecomeVisible in interface PopupMenuListener
Parameters:
e - The triggering event.

popupMenuWillBecomeInvisible

public void popupMenuWillBecomeInvisible(PopupMenuEvent e)
This method can be used at your discretion, but otherwise does nothing.

Specified by:
popupMenuWillBecomeInvisible in interface PopupMenuListener
Parameters:
e - The triggering event.

popupMenuCanceled

public void popupMenuCanceled(PopupMenuEvent e)
This method can be used at your discretion, but otherwise does nothing.

Specified by:
popupMenuCanceled in interface PopupMenuListener
Parameters:
e - The triggering event.

updateEnableState

public void updateEnableState()
Triggers the enable state of the action to be updated based on the enableFor state of the action and the state of the system.

Specified by:
updateEnableState in interface CyAction

Cytoscape 3.0.1 API

Copyright 2011 Cytoscape Consortium. All rights reserved.