Package org.cytoscape.util.swing
Class MenuGravityTracker
- java.lang.Object
-
- org.cytoscape.util.swing.MenuGravityTracker
-
- All Implemented Interfaces:
GravityTracker
public final class MenuGravityTracker extends Object implements GravityTracker
This class inserts menu items and separators in a menu based on their "gravity". Items with higher gravity appear further down the menu.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>
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.
-
-
Field Summary
-
Fields inherited from interface org.cytoscape.util.swing.GravityTracker
USE_ALPHABETIC_ORDER
-
-
Constructor Summary
Constructors Constructor Description MenuGravityTracker(JMenu menu)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMenu(JMenu newSubmenu, double gravity)
Adds a new submenu into a position based on "gravity" of the new item.void
addMenuItem(JMenuItem newMenuItem, double gravity)
Adds a new menu item into a position based on "gravity" of the new item.void
addMenuSeparator(double gravity)
Adds a separator into a position based on "gravity" of the new item.JMenu
getMenu()
Returns the JPopupMenu or JMenu that this gravity tracker tracks.void
removeComponent(Component component)
Removes an item from this tracker and the corresponding menu.
-
-
-
Constructor Detail
-
MenuGravityTracker
public MenuGravityTracker(JMenu menu)
Constructor.- Parameters:
menu
- The JMenu associated with this MenuGravityTracker.
-
-
Method Detail
-
getMenu
public JMenu getMenu()
Description copied from interface:GravityTracker
Returns the JPopupMenu or JMenu that this gravity tracker tracks.- Specified by:
getMenu
in interfaceGravityTracker
- Returns:
- the JPopupMenu or JMenu that this gravity tracker tracks
-
addMenuItem
public void addMenuItem(JMenuItem newMenuItem, double gravity)
Description copied from interface:GravityTracker
Adds a new menu item into a position based on "gravity" of the new item.- Specified by:
addMenuItem
in 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
public void addMenu(JMenu newSubmenu, double gravity)
Description copied from interface:GravityTracker
Adds a new submenu into a position based on "gravity" of the new item.- Specified by:
addMenu
in 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:GravityTracker
Adds a separator into a position based on "gravity" of the new item.- Specified by:
addMenuSeparator
in interfaceGravityTracker
- Parameters:
gravity
- the weight determining the insert position
-
removeComponent
public void removeComponent(Component component)
Description copied from interface:GravityTracker
Removes an item from this tracker and the corresponding menu.- Specified by:
removeComponent
in interfaceGravityTracker
- Parameters:
component
- the item that is to be removed
-
-