Class ViewMenuBuilder

java.lang.Object
gov.nih.mipav.view.ViewMenuBuilder

public class ViewMenuBuilder extends Object
This class provides a number of helper methods for building and manipulating menus.
  • Field Details

    • fileMenu

      private JMenu fileMenu
      Link to the file menu so that quicklist can be rebuilt and added.
    • listener

      private ActionListener listener
      The class which wants to listen to the menu items generated.
    • quickList

      private ViewMenuBuilder.QuickList quickList
      List that holds the last X number of recently opened images.
    • quicklistIndex

      private int quicklistIndex
      Index for rebuilding quicklist.
    • op

      private final ViewMenuBuilder.MenuDragOp op
      Menu dragging listener
    • buttonGroup

      private ButtonGroup buttonGroup
  • Constructor Details

    • ViewMenuBuilder

      public ViewMenuBuilder(ActionListener al)
      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 box
      cmd - String the action command
      listener - ActionListener the action listener for the box
      selected - 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

      public static JMenu buildMenu(String text, int mnemonic, boolean iconPadding)
      Static method for building a JMenu.
      Parameters:
      text - String the name of the menu to be displayed
      mnemonic - int mnemonic for the menu
      iconPadding - 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 Params
      listener - Action listener
      iconPadding - 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

      public JRadioButtonMenuItem buildRadioButtonMenuItem(String text, String cmd, boolean selected)
    • buildRadioButtonMenuItem

      public JRadioButtonMenuItem buildRadioButtonMenuItem(String text, String cmd, boolean selected, ButtonGroup group)
    • buildCheckBoxMenuItem

      public JCheckBoxMenuItem buildCheckBoxMenuItem(String text, String cmd, boolean selected)
      Builds a JCheckBox with the given parameters and adds it to the Vector of menu items.
      Parameters:
      text - String Checkbox text
      cmd - String actioncommand
      selected - boolean whether the box is selected by default
      Returns:
      JCheckBoxMenuItem
    • buildMenuItem

      public JMenuItem buildMenuItem(CustomUIBuilder.UIParams params, boolean useIconPadding)
      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 - String
      cmd - String
      mnemonic - int
      iconName - String
      useIconPadding - boolean
      Returns:
      JMenuItem
    • buildQuickList

      public ViewMenuBuilder.QuickList buildQuickList()
      Builds the quicklist for the first time.
      Returns:
      QuickList
    • finalize

      public void finalize()
      Clean up memory used by the menu builder.
      Overrides:
      finalize in class Object
    • getMenuItem

      public JMenuItem getMenuItem(String menuItemName)
      DOCUMENT ME!
      Parameters:
      menuItemName - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • isMenuItemEnabled

      public boolean isMenuItemEnabled(String name)
      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

      public boolean isMenuItemSelected(String name)
      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

      public JMenu makeMenu(Object parentMenu, boolean iconPadding, JComponent[] menuComponent)
      Makes a menu out of the menu components, using parentMenu as the base for this menu.
      Parameters:
      parentMenu - The parent menu, must be of type String or a JMenu, cannot be null.
      iconPadding - Array of menu items, must be of typeJMenu, JMenuItem, JCheckBoxMenuItem, or JSeparator.
      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, using parentMenu as the base for this menu and adding a mnemonic.
      Parameters:
      parentMenu - The parent menu, must be of type String or a JMenu, cannot be null.
      mnemonic - Mnemonic key for the parent menu name.
      iconPadding - Array of menu items, must be of typeJMenu, JMenuItem, JCheckBoxMenuItem, or JSeparator.
      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

      public void setMenuItemEnabled(String name, boolean state)
      Provides a method of setting the state of specified menu.
      Parameters:
      name - The name of the item whose state needs to be set.
      state - true sets the menu item active; false sets the menu item inactive.
    • setMenuItemSelected

      public void setMenuItemSelected(String name, boolean val)
      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

      private void addMenuDragListener(Component comp, MenuDragMouseListener op)
      Attaches a MenuDragMouseListener to comp and all of its sub-components (if comp is a JMenu/JMenuItem.