Package org.cytoscape.util.swing
Class MenuGravityTracker
java.lang.Object
org.cytoscape.util.swing.MenuGravityTracker
- All Implemented Interfaces:
GravityTracker
This class inserts menu items and separators in a menu based on their "gravity".
Items with higher gravity appear further down the menu.
Cytoscape Backwards Compatibility (Final Class): This class is final and therefore can't be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.
Module: swing-util-api
To use this in your app, include the following dependency in your POM:
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>swing-util-api</artifactId>
</dependency>-
Field Summary
Fields inherited from interface org.cytoscape.util.swing.GravityTracker
USE_ALPHABETIC_ORDER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new submenu into a position based on "gravity" of the new item.voidaddMenuItem(JMenuItem newMenuItem, double gravity) Adds a new menu item into a position based on "gravity" of the new item.voidaddMenuSeparator(double gravity) Adds a separator into a position based on "gravity" of the new item.getMenu()Returns the JPopupMenu or JMenu that this gravity tracker tracks.voidremoveComponent(Component component) Removes an item from this tracker and the corresponding menu.
-
Constructor Details
-
MenuGravityTracker
-
-
Method Details
-
getMenu
Description copied from interface:GravityTrackerReturns the JPopupMenu or JMenu that this gravity tracker tracks.- Specified by:
getMenuin interfaceGravityTracker- Returns:
- the JPopupMenu or JMenu that this gravity tracker tracks
-
addMenuItem
Description copied from interface:GravityTrackerAdds a new menu item into a position based on "gravity" of the new item.- Specified by:
addMenuItemin interfaceGravityTracker- Parameters:
newMenuItem- the new item to insert into the menugravity- the weight determining the insert position (use USE_ALPHABETIC_ORDER if you want alphabetic ordering)
-
addMenu
Description copied from interface:GravityTrackerAdds a new submenu into a position based on "gravity" of the new item.- Specified by:
addMenuin interfaceGravityTracker- Parameters:
newSubmenu- the new submenu to insert into the menugravity- the weight determining the insert position
-
addMenuSeparator
public void addMenuSeparator(double gravity) Description copied from interface:GravityTrackerAdds a separator into a position based on "gravity" of the new item.- Specified by:
addMenuSeparatorin interfaceGravityTracker- Parameters:
gravity- the weight determining the insert position
-
removeComponent
Description copied from interface:GravityTrackerRemoves an item from this tracker and the corresponding menu.- Specified by:
removeComponentin interfaceGravityTracker- Parameters:
component- the item that is to be removed
-