ij
Class Menus

java.lang.Object
  extended by ij.Menus
All Implemented Interfaces:
KeyCode

public class Menus
extends java.lang.Object
implements KeyCode

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

Field Summary
static char ABOUT_MENU
           
static java.lang.String actionSuffix
          Suffix applied to the key used in resource file lookups for an action.
static java.lang.String booleanSuffix
          Suffix applied to the key used in resource file lookups for an boolean.
static javax.swing.JCheckBoxMenuItem color256Item
           
static javax.swing.JCheckBoxMenuItem colorRGBItem
           
static int COMMAND_IN_USE
           
static int COMMAND_NOT_FOUND
           
static char FILTERS_MENU
           
static javax.swing.JCheckBoxMenuItem gray16Item
           
static javax.swing.JCheckBoxMenuItem gray32Item
           
static javax.swing.JCheckBoxMenuItem gray8Item
           
static javax.swing.JCheckBoxMenuItem HSBStackItem
           
static char IMPORT_MENU
           
static int INVALID_SHORTCUT
           
static java.util.Locale locale
           
static boolean localeEN
           
static int MAX_OPEN_RECENT_ITEMS
           
static int NORMAL_RETURN
           
static int NOT_INSTALLED
           
static char PLUGINS_MENU
           
static javax.swing.JCheckBoxMenuItem RGBStackItem
           
static char SAVE_AS_MENU
           
static int SHORTCUT_IN_USE
           
static char SHORTCUTS_MENU
           
static java.lang.String shortcutSuffix
          Suffix applied to the key used in resource file lookups for an shortcut.
static javax.swing.JMenuItem toolbarItem
           
static char TOOLS_MENU
           
static char UTILITIES_MENU
           
static int WINDOW_MENU_ITEMS
           
 
Fields inherited from interface ij.plugin.frame.KeyCode
shortcutKeyi, shortcutKeys
 
Method Summary
static void addOpenRecentItem(java.lang.String path)
          Adds a file path to the beginning of the File/Open Recent submenu.
static boolean commandInUse(java.lang.String command)
           
static int convertShortcutToCode(java.lang.String shortcut)
           
 javax.swing.Icon createIcon(java.lang.String key)
           
static java.util.Hashtable getCommands()
          Returns the hashtable that associates commands with plugins.
static java.util.Hashtable getCommandsEN2Locale()
          Returns the hashtable that associates commands with plugins.
static java.util.Hashtable getCommandsLocale2EN()
          Returns the hashtable that associates commands with plugins.
static java.util.Hashtable getCommandsName()
          Returns the hashtable that associates commands with plugins.
static java.awt.Font getFont()
           
static int getFontSize()
          Returns the size (in points) used for the fonts in ImageJ menus.
static java.lang.String getJarFileForMenuEntry(java.lang.String menuEntry)
           
 int getMacroCount()
           
static java.util.Hashtable getMacroShortcuts()
          Returns the hashtable that associates keyboard shortcuts with macros.
static javax.swing.JMenu getMacrosMenu()
           
static java.lang.String getMacrosPath()
          Returns the path to the macros directory or null if the macros directory was not found.
static javax.swing.JMenuBar getMenuBar()
           
 int getPluginCount()
           
static java.lang.String[] getPlugins()
          Returns a list of the plugins in the plugins menu.
static java.lang.String getPlugInsPath()
          Returns the path to the user plugins directory or null if the plugins directory was not found.
static javax.swing.JPopupMenu getPopupMenu()
           
static javax.swing.JMenu getSaveAsMenu()
           
static java.util.Hashtable getShortcuts()
          Returns the hashtable that associates shortcuts with commands.
static java.util.Locale getUserLocale()
           
 void initMenus()
          init munubar
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.
 void installStartupMacroSet()
           
 void installUserPlugin(java.lang.String className, boolean force)
           
 boolean isBarID(boolean noProcess)
           
static void savePreferences(java.util.Properties prefs)
          Called once when ImageJ quits.
static void setFontSize(int size)
          Set the size (in points) used for the fonts in ImageJ menus.
static void setUserLocale(java.util.Locale userLocale)
           
static boolean shortcutInUse(java.lang.String shortcut)
           
static int uninstallPlugin(java.lang.String command)
          Deletes a command installed by installPlugin.
static void updateImageJMenus()
           
static void updateMenus()
          Updates the Image/Type and Window menus.
static void updateWindowMenuItem(java.lang.String oldLabel, java.lang.String newLabel)
          Changes the name of an item in the Window menu.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLUGINS_MENU

public static final char PLUGINS_MENU
See Also:
Constant Field Values

IMPORT_MENU

public static final char IMPORT_MENU
See Also:
Constant Field Values

SAVE_AS_MENU

public static final char SAVE_AS_MENU
See Also:
Constant Field Values

SHORTCUTS_MENU

public static final char SHORTCUTS_MENU
See Also:
Constant Field Values

ABOUT_MENU

public static final char ABOUT_MENU
See Also:
Constant Field Values

FILTERS_MENU

public static final char FILTERS_MENU
See Also:
Constant Field Values

TOOLS_MENU

public static final char TOOLS_MENU
See Also:
Constant Field Values

UTILITIES_MENU

public static final char UTILITIES_MENU
See Also:
Constant Field Values

WINDOW_MENU_ITEMS

public static final int WINDOW_MENU_ITEMS
See Also:
Constant Field Values

NORMAL_RETURN

public static final int NORMAL_RETURN
See Also:
Constant Field Values

COMMAND_IN_USE

public static final int COMMAND_IN_USE
See Also:
Constant Field Values

INVALID_SHORTCUT

public static final int INVALID_SHORTCUT
See Also:
Constant Field Values

SHORTCUT_IN_USE

public static final int SHORTCUT_IN_USE
See Also:
Constant Field Values

NOT_INSTALLED

public static final int NOT_INSTALLED
See Also:
Constant Field Values

COMMAND_NOT_FOUND

public static final int COMMAND_NOT_FOUND
See Also:
Constant Field Values

MAX_OPEN_RECENT_ITEMS

public static final int MAX_OPEN_RECENT_ITEMS
See Also:
Constant Field Values

gray8Item

public static javax.swing.JCheckBoxMenuItem gray8Item

gray16Item

public static javax.swing.JCheckBoxMenuItem gray16Item

gray32Item

public static javax.swing.JCheckBoxMenuItem gray32Item

color256Item

public static javax.swing.JCheckBoxMenuItem color256Item

colorRGBItem

public static javax.swing.JCheckBoxMenuItem colorRGBItem

RGBStackItem

public static javax.swing.JCheckBoxMenuItem RGBStackItem

HSBStackItem

public static javax.swing.JCheckBoxMenuItem HSBStackItem

toolbarItem

public static javax.swing.JMenuItem toolbarItem

locale

public static java.util.Locale locale

localeEN

public static boolean localeEN

actionSuffix

public static final java.lang.String actionSuffix
Suffix applied to the key used in resource file lookups for an action.

See Also:
Constant Field Values

shortcutSuffix

public static final java.lang.String shortcutSuffix
Suffix applied to the key used in resource file lookups for an shortcut.

See Also:
Constant Field Values

booleanSuffix

public static final java.lang.String booleanSuffix
Suffix applied to the key used in resource file lookups for an boolean.

See Also:
Constant Field Values
Method Detail

isBarID

public boolean isBarID(boolean noProcess)

initMenus

public void initMenus()
init munubar


setUserLocale

public static void setUserLocale(java.util.Locale userLocale)

getUserLocale

public static java.util.Locale getUserLocale()

getJarFileForMenuEntry

public static java.lang.String getJarFileForMenuEntry(java.lang.String menuEntry)

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 javax.swing.JMenuBar getMenuBar()

getMacrosMenu

public static javax.swing.JMenu getMacrosMenu()

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.


getCommandsName

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


getCommandsEN2Locale

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


getCommandsLocale2EN

public static java.util.Hashtable getCommandsLocale2EN()
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.


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 javax.swing.JPopupMenu getPopupMenu()

getSaveAsMenu

public static javax.swing.JMenu 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 installPlugin.


commandInUse

public static boolean commandInUse(java.lang.String command)

createIcon

public javax.swing.Icon createIcon(java.lang.String key)

convertShortcutToCode

public static int convertShortcutToCode(java.lang.String shortcut)

installStartupMacroSet

public void installStartupMacroSet()

shortcutInUse

public static boolean shortcutInUse(java.lang.String shortcut)

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()

savePreferences

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


updateImageJMenus

public static void updateImageJMenus()