Module ij
Package ij

Class Menus


  • public class Menus
    extends java.lang.Object
    This class installs and updates ImageJ's menus. Note that menu labels, even in submenus, must be unique. This is because ImageJ uses a single hash table for all menu labels. If you look closely, you will see that File->Import->Text Image... and File->Save As->Text Image... do not use the same label. One of the labels has an extra space.
    See Also:
    ImageJ
    • Method Detail

      • getExamplesMenu

        public static java.awt.Menu getExamplesMenu​(java.awt.event.ActionListener listener)
      • getJarFileForMenuEntry

        public static java.lang.String getJarFileForMenuEntry​(java.lang.String menuEntry)
      • getImageJMenu

        public static java.awt.Menu getImageJMenu​(java.lang.String menuPath)
        Returns the specified ImageJ menu (e.g., "File>New") or null if it is not found.
      • getPlugins

        public static java.lang.String[] getPlugins()
        Returns a list of the plugins in the plugins menu.
      • installUserPlugin

        public void installUserPlugin​(java.lang.String className,
                                      boolean force)
      • getMenuBar

        public static java.awt.MenuBar getMenuBar()
      • getMacrosMenu

        public static java.awt.Menu getMacrosMenu()
      • getOpenRecentMenu

        public static java.awt.Menu getOpenRecentMenu()
      • getMacroCount

        public int getMacroCount()
      • getPluginCount

        public int getPluginCount()
      • updateMenus

        public static void updateMenus()
        Updates the Image/Type and Window menus.
      • getPlugInsPath

        public static java.lang.String getPlugInsPath()
        Returns the path to the user plugins directory or null if the plugins directory was not found.
      • getMacrosPath

        public static java.lang.String getMacrosPath()
        Returns the path to the macros directory or null if the macros directory was not found.
      • getCommands

        public static java.util.Hashtable getCommands()
        Returns the hashtable that associates commands with plugins.
      • getShortcuts

        public static java.util.Hashtable getShortcuts()
        Returns the hashtable that associates shortcuts with commands. The keys in the hashtable are Integer keycodes, or keycode+200 for uppercase.
      • getMacroShortcuts

        public static java.util.Hashtable getMacroShortcuts()
        Returns the hashtable that associates keyboard shortcuts with macros. The keys in the hashtable are Integer keycodes, or keycode+200 for uppercase.
      • updateWindowMenuItem

        public static void updateWindowMenuItem​(java.lang.String oldLabel,
                                                java.lang.String newLabel)
        Changes the name of an item in the Window menu.
      • updateWindowMenuItem

        public static void updateWindowMenuItem​(ImagePlus imp,
                                                java.lang.String oldLabel,
                                                java.lang.String newLabel)
        Changes the name of an item in the Window menu.
      • addOpenRecentItem

        public static void addOpenRecentItem​(java.lang.String path)
        Adds a file path to the beginning of the File/Open Recent submenu.
      • getPopupMenu

        public static java.awt.PopupMenu getPopupMenu()
      • getSaveAsMenu

        public static java.awt.Menu getSaveAsMenu()
      • installPlugin

        public static int installPlugin​(java.lang.String plugin,
                                        char menuCode,
                                        java.lang.String command,
                                        java.lang.String shortcut,
                                        ImageJ ij)
        Adds a plugin based command to the end of a specified menu.
        Parameters:
        plugin - the plugin (e.g. "Inverter_", "Inverter_("arg")")
        menuCode - PLUGINS_MENU, IMPORT_MENU, SAVE_AS_MENU or HOT_KEYS
        command - the menu item label (set to "" to uninstall)
        shortcut - the keyboard shortcut (e.g. "y", "Y", "F1")
        ij - ImageJ (the action listener)
        Returns:
        returns an error code(NORMAL_RETURN,COMMAND_IN_USE_ERROR, etc.)
      • uninstallPlugin

        public static int uninstallPlugin​(java.lang.String command)
        Deletes a command installed by Plugins/Shortcuts/Add Shortcut.
      • commandInUse

        public static boolean commandInUse​(java.lang.String command)
      • convertShortcutToCode

        public static int convertShortcutToCode​(java.lang.String shortcut)
      • shortcutInUse

        public static boolean shortcutInUse​(java.lang.String shortcut)
        Returns 'true' if this keyboard shortcut is in use.
      • setFontSize

        public static void setFontSize​(int size)
        Set the size (in points) used for the fonts in ImageJ menus. Set the size to 0 to use the Java default size.
      • getFontSize

        public static int getFontSize()
        Returns the size (in points) used for the fonts in ImageJ menus. Returns 0 if the default font size is being used or if this is a Macintosh.
      • getFont

        public static java.awt.Font getFont()
      • getFont

        public static java.awt.Font getFont​(boolean checkSize)
      • getCachedFont

        public static java.awt.Font getCachedFont()
      • savePreferences

        public static void savePreferences​(java.util.Properties prefs)
        Called once when ImageJ quits.
      • updateImageJMenus

        public static void updateImageJMenus()
      • updateFont

        public static void updateFont()
      • add

        public static void add​(java.lang.String menuPath,
                               java.lang.String plugin)
        Adds a command to the ImageJ menu bar.