Package gov.nih.mipav.view
Class ViewMenuBuilder
java.lang.Object
gov.nih.mipav.view.ViewMenuBuilder
This class provides a number of helper methods for building and manipulating menus.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classClass for listening to dragging events within a menu.private classDOCUMENT ME!classQuickList class uses Preferences to build a list of the most recently opened images. the frame is passed in for purposes of ActionListener The QuickList is stored as JMenuItems in a Vector that can be retrieved. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ButtonGroupprivate JMenuLink to the file menu so that quicklist can be rebuilt and added.private ActionListenerThe class which wants to listen to the menu items generated.private Vector<ViewMenuBuilder.MipavMenuItem> Holder of all the menu items.private final ViewMenuBuilder.MenuDragOpMenu dragging listenerprivate ViewMenuBuilder.QuickListList that holds the last X number of recently opened images.private intIndex for rebuilding quicklist. -
Constructor Summary
ConstructorsConstructorDescriptionSets frame to add menus to, and initializes menu item vector. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidAttaches a MenuDragMouseListener tocompand all of its sub-components (if comp is a JMenu/JMenuItem.buildCheckBoxMenuItem(String text, String cmd, boolean selected) Builds a JCheckBox with the given parameters and adds it to the Vector of menu items.static JCheckBoxMenuItembuildCheckBoxMenuItem(String text, String cmd, ActionListener listener, boolean selected) Static method for building JCheckBoxes with the given parameters.static JMenuItembuildHTMLMenuItem(String text, String cmd, int mnemonic, ActionListener listener, String iconName, boolean iconPadding) DOCUMENT ME!static JMenuStatic method for building a JMenu.buildMenuItem(CustomUIBuilder.UIParams params, boolean useIconPadding) Build a menu item using a pre-made UIParamsstatic JMenuItembuildMenuItem(CustomUIBuilder.UIParams params, ActionListener listener, boolean iconPadding) Creates a Menu Item using pre-packaged UIParamsstatic JMenuItembuildMenuItem(String text, String cmd, int mnemonic, ActionListener listener, String iconName, boolean iconPadding) DOCUMENT ME!buildMenuItem(String text, String cmd, int mnemonic, String iconName, boolean useIconPadding) DOCUMENT ME!Builds the quicklist for the first time.buildRadioButtonMenuItem(String text, String cmd, boolean selected) buildRadioButtonMenuItem(String text, String cmd, boolean selected, ButtonGroup group) voidfinalize()Clean up memory used by the menu builder.getMenuItem(String menuItemName) DOCUMENT ME!booleanisMenuItemEnabled(String name) Provides a method of checking the state of specified menu.booleanisMenuItemSelected(String name) Provides a method of checking the state of specified menu.makeMenu(Object parentMenu, boolean iconPadding, JComponent[] menuComponent) Makes a menu out of the menu components, usingparentMenuas the base for this menu.makeMenu(Object parentMenu, char mnemonic, boolean iconPadding, Vector<JComponent> menuComponent) makeMenu(Object parentMenu, char mnemonic, boolean iconPadding, JComponent[] menuComponent) Makes a menu out of the menu components, usingparentMenuas the base for this menu and adding a mnemonic.voidsetMenuItemEnabled(String name, boolean state) Provides a method of setting the state of specified menu.voidsetMenuItemSelected(String name, boolean val) Provides a method for changing the status of a checkbox menu item.voidUpdates the most recently opened images list (called when images are opened etc).
-
Field Details
-
fileMenu
Link to the file menu so that quicklist can be rebuilt and added. -
listener
The class which wants to listen to the menu items generated. -
quickList
List that holds the last X number of recently opened images. -
quicklistIndex
private int quicklistIndexIndex for rebuilding quicklist. -
op
Menu dragging listener -
buttonGroup
-
-
Constructor Details
-
ViewMenuBuilder
Sets frame to add menus to, and initializes menu item vector.- Parameters:
al- class which wants notification of interations with the generated menu items
-
-
Method Details
-
buildCheckBoxMenuItem
public static JCheckBoxMenuItem buildCheckBoxMenuItem(String text, String cmd, ActionListener listener, boolean selected) Static method for building JCheckBoxes with the given parameters.- Parameters:
text- String text to display on the boxcmd- String the action commandlistener- ActionListener the action listener for the boxselected- boolean whether the box should be selected by default- Returns:
- JCheckBoxMenuItem the jcheckbox that is built
-
buildHTMLMenuItem
public static JMenuItem buildHTMLMenuItem(String text, String cmd, int mnemonic, ActionListener listener, String iconName, boolean iconPadding) DOCUMENT ME!- Parameters:
text- DOCUMENT ME!cmd- DOCUMENT ME!mnemonic- DOCUMENT ME!listener- DOCUMENT ME!iconName- DOCUMENT ME!iconPadding- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
buildMenu
Static method for building a JMenu.- Parameters:
text- String the name of the menu to be displayedmnemonic- int mnemonic for the menuiconPadding- boolean an empty icon (transparent) is used to properly pad the text- Returns:
- JMenu the menu that is built
-
buildMenuItem
public static JMenuItem buildMenuItem(CustomUIBuilder.UIParams params, ActionListener listener, boolean iconPadding) Creates a Menu Item using pre-packaged UIParams- Parameters:
params- UI Paramslistener- Action listenericonPadding- whether to use icon padding- Returns:
- the jmenuitem
-
buildMenuItem
public static JMenuItem buildMenuItem(String text, String cmd, int mnemonic, ActionListener listener, String iconName, boolean iconPadding) DOCUMENT ME!- Parameters:
text- DOCUMENT ME!cmd- DOCUMENT ME!mnemonic- DOCUMENT ME!listener- DOCUMENT ME!iconName- DOCUMENT ME!iconPadding- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
buildRadioButtonMenuItem
-
buildRadioButtonMenuItem
public JRadioButtonMenuItem buildRadioButtonMenuItem(String text, String cmd, boolean selected, ButtonGroup group) -
buildCheckBoxMenuItem
Builds a JCheckBox with the given parameters and adds it to the Vector of menu items.- Parameters:
text- String Checkbox textcmd- String actioncommandselected- boolean whether the box is selected by default- Returns:
- JCheckBoxMenuItem
-
buildMenuItem
Build a menu item using a pre-made UIParams- Parameters:
params- the UIParams (from CustomUIBuilder)useIconPadding- use icon padding- Returns:
-
buildMenuItem
public JMenuItem buildMenuItem(String text, String cmd, int mnemonic, String iconName, boolean useIconPadding) DOCUMENT ME!- Parameters:
text- Stringcmd- Stringmnemonic- inticonName- StringuseIconPadding- boolean- Returns:
- JMenuItem
-
buildQuickList
Builds the quicklist for the first time.- Returns:
- QuickList
-
finalize
public void finalize()Clean up memory used by the menu builder. -
getMenuItem
DOCUMENT ME!- Parameters:
menuItemName- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
isMenuItemEnabled
Provides a method of checking the state of specified menu.- Parameters:
name- The name of the item whose state needs to be checked.- Returns:
- Whether or not the item is enabled.
-
isMenuItemSelected
Provides a method of checking the state of specified menu.- Parameters:
name- The name of the item whose state needs to be checked.- Returns:
- Whether or not the item is selected.
-
makeMenu
Makes a menu out of the menu components, usingparentMenuas the base for this menu.- Parameters:
parentMenu- The parent menu, must be of typeStringor aJMenu, cannot be null.iconPadding- Array of menu items, must be of typeJMenu,JMenuItem,JCheckBoxMenuItem, orJSeparator.menuComponent- Parent frame, used to add as an item listener to the checkbox menu items.- Returns:
- The newly created menu.
-
makeMenu
public JMenu makeMenu(Object parentMenu, char mnemonic, boolean iconPadding, JComponent[] menuComponent) Makes a menu out of the menu components, usingparentMenuas the base for this menu and adding a mnemonic.- Parameters:
parentMenu- The parent menu, must be of typeStringor aJMenu, cannot be null.mnemonic- Mnemonic key for the parent menu name.iconPadding- Array of menu items, must be of typeJMenu,JMenuItem,JCheckBoxMenuItem, orJSeparator.menuComponent- Parent frame, used to add as an item listener to the checkbox menu items.- Returns:
- The newly created menu.
-
makeMenu
public JMenu makeMenu(Object parentMenu, char mnemonic, boolean iconPadding, Vector<JComponent> menuComponent) -
setMenuItemEnabled
Provides a method of setting the state of specified menu.- Parameters:
name- The name of the item whose state needs to be set.state-truesets the menu item active;falsesets the menu item inactive.
-
setMenuItemSelected
Provides a method for changing the status of a checkbox menu item.- Parameters:
val- whether the checkbox should be selected.
-
updateQuickList
public void updateQuickList()Updates the most recently opened images list (called when images are opened etc). -
addMenuDragListener
Attaches a MenuDragMouseListener tocompand all of its sub-components (if comp is a JMenu/JMenuItem.
-