ij
Class Menus

java.lang.Object
  extended by ij.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

Field Summary
static char ABOUT_MENU
           
static int COMMAND_IN_USE
           
static int COMMAND_NOT_FOUND
           
static char FILTERS_MENU
           
(package private) static int HSB_STACK
           
static char IMPORT_MENU
           
static int INVALID_SHORTCUT
           
(package private) static boolean jnlp
           
static int MAX_OPEN_RECENT_ITEMS
           
(package private)  int nMacros
           
static int NORMAL_RETURN
           
static int NOT_INSTALLED
           
(package private)  int nPlugins
           
(package private) static java.awt.Menu openRecentMenu
           
static char PLUGINS_MENU
           
(package private) static int RGB_STACK
           
static char SAVE_AS_MENU
           
static int SHORTCUT_IN_USE
           
static char SHORTCUTS_MENU
           
(package private) static java.awt.Menu submenu
           
(package private) static java.lang.String submenuName
           
static char TOOLS_MENU
           
static char UTILITIES_MENU
           
(package private) static java.awt.Menu window
           
static int WINDOW_MENU_ITEMS
           
(package private) static int windowMenuItems2
           
 
Constructor Summary
Menus(ImageJ ijInstance, java.applet.Applet appletInstance)
           
 
Method Summary
(package private)  java.awt.CheckboxMenuItem addCheckboxItem(java.awt.Menu menu, java.lang.String label, java.lang.String className)
           
(package private)  void addItem(java.awt.Menu menu, java.lang.String label, int shortcut, boolean shift)
           
(package private)  void addItemSorted(java.awt.Menu menu, java.awt.MenuItem item, int startingIndex)
           
(package private)  void addJarErrorHeading(java.lang.String jar)
           
(package private)  void addLuts(java.awt.Menu submenu)
           
 java.lang.String addMenuBar()
           
static void addOpenRecentItem(java.lang.String path)
          Adds a file path to the beginning of the File/Open Recent submenu.
(package private)  void addOpenRecentSubMenu(java.awt.Menu menu)
           
(package private)  void addOrdered(java.awt.Menu menu, java.awt.MenuItem item)
          Inserts 'item' into 'menu' in alphanumeric order.
(package private)  void addPluginItem(java.awt.Menu submenu, java.lang.String s)
           
(package private)  void addPlugInItem(java.awt.Menu menu, java.lang.String label, java.lang.String className, int shortcut, boolean shift)
           
(package private)  void addPluginsMenu()
           
(package private)  void addSeparator(java.awt.Menu menu)
           
(package private)  java.awt.Menu addSubMenu(java.awt.Menu menu, java.lang.String name)
           
(package private) static void addWindowMenuItem(ImagePlus imp)
          Adds one image to the end of the Window menu.
(package private)  java.io.InputStream autoGenerateConfigFile(java.lang.String jar)
          Creates a configuration file for JAR/ZIP files that do not have one.
(package private)  void checkForDuplicate(java.lang.String command)
           
(package private) static void checkSubdirectory(java.lang.String path, java.lang.String dir, java.util.Vector v)
          Looks for plugins and jar files in a subdirectory of the plugins directory.
static boolean commandInUse(java.lang.String command)
           
static int convertShortcutToCode(java.lang.String shortcut)
           
static java.util.Hashtable getCommands()
          Returns the hashtable that associates commands with plugins.
(package private)  java.io.InputStream getConfigurationFile(java.lang.String jar)
          Opens the configuration file ("plugins.txt") from a JAR file and returns it as an InputStream.
static java.awt.Font getFont()
           
static int getFontSize()
          Returns the size (in points) used for the fonts in ImageJ menus.
static java.util.Hashtable getMacroShortcuts()
          Returns the hashtable that associates keyboard shortcuts with macros.
static java.awt.Menu getMacrosMenu()
           
static java.lang.String getMacrosPath()
          Returns the path to the macros directory or null if the macros directory was not found.
static java.awt.MenuBar getMenuBar()
           
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.
(package private)  java.awt.Menu getPluginsSubmenu(java.lang.String submenuName)
           
static java.awt.PopupMenu getPopupMenu()
           
static java.util.Hashtable getShortcuts()
          Returns the hashtable that associates shortcuts with commands.
(package private)  java.lang.String[] getStrippedPlugins(java.lang.String[] plugins)
          Returns a list of the plugins with directory names removed.
(package private)  java.lang.String getSubmenuName(java.lang.String jarPath)
           
(package private) static void insertWindowMenuItem(java.awt.Frame win)
          Inserts one item (a non-image window) into the Window menu.
(package private)  void installJarPlugin(java.lang.String jar, java.lang.String s)
          Install a plugin located in a JAR file.
(package private)  void installJarPlugins()
          Install plugins located in JAR files.
(package private)  void installMacro(java.lang.String name)
          Installs a macro in the Plugins menu, or submenu, with with underscores in the file name replaced by spaces.
(package private)  void installMacros()
          Installs macro files that are located in the plugins folder and have a "_" in their name.
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.
(package private)  void installPlugins()
          Install plugins using "pluginxx=" keys in IJ_Prefs.txt.
(package private)  void installPopupMenu(ImageJ ij)
           
(package private)  void installStartupMacroSet()
           
(package private)  void installUserPlugin(java.lang.String className)
          Installs a plugin in the Plugins menu using the class name, with underscores replaced by spaces, as the command.
(package private) static boolean isColorLut(ImagePlus imp)
           
(package private) static void removeWindowMenuItem(int index)
          Removes the specified item from the Window menu.
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 boolean shortcutInUse(java.lang.String shortcut)
           
static int uninstallPlugin(java.lang.String command)
          Deletes a command installed by installPlugin.
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.
(package private) static boolean validShortcut(java.lang.String shortcut)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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

window

static java.awt.Menu window

openRecentMenu

static java.awt.Menu openRecentMenu

nPlugins

int nPlugins

nMacros

int nMacros

windowMenuItems2

static int windowMenuItems2

jnlp

static boolean jnlp

submenuName

static java.lang.String submenuName

submenu

static java.awt.Menu submenu

RGB_STACK

static final int RGB_STACK
See Also:
Constant Field Values

HSB_STACK

static final int HSB_STACK
See Also:
Constant Field Values
Constructor Detail

Menus

public Menus(ImageJ ijInstance,
             java.applet.Applet appletInstance)
Method Detail

addMenuBar

public java.lang.String addMenuBar()

addOpenRecentSubMenu

void addOpenRecentSubMenu(java.awt.Menu menu)

addItem

void addItem(java.awt.Menu menu,
             java.lang.String label,
             int shortcut,
             boolean shift)

addPlugInItem

void addPlugInItem(java.awt.Menu menu,
                   java.lang.String label,
                   java.lang.String className,
                   int shortcut,
                   boolean shift)

addCheckboxItem

java.awt.CheckboxMenuItem addCheckboxItem(java.awt.Menu menu,
                                          java.lang.String label,
                                          java.lang.String className)

addSubMenu

java.awt.Menu addSubMenu(java.awt.Menu menu,
                         java.lang.String name)

addLuts

void addLuts(java.awt.Menu submenu)

addPluginItem

void addPluginItem(java.awt.Menu submenu,
                   java.lang.String s)

checkForDuplicate

void checkForDuplicate(java.lang.String command)

addPluginsMenu

void addPluginsMenu()

installPlugins

void installPlugins()
Install plugins using "pluginxx=" keys in IJ_Prefs.txt. Plugins not listed in IJ_Prefs are added to the end of the Plugins menu.


installMacros

void installMacros()
Installs macro files that are located in the plugins folder and have a "_" in their name.


installMacro

void installMacro(java.lang.String name)
Installs a macro in the Plugins menu, or submenu, with with underscores in the file name replaced by spaces.


addOrdered

void addOrdered(java.awt.Menu menu,
                java.awt.MenuItem item)
Inserts 'item' into 'menu' in alphanumeric order.


installJarPlugins

void installJarPlugins()
Install plugins located in JAR files.


installJarPlugin

void installJarPlugin(java.lang.String jar,
                      java.lang.String s)
Install a plugin located in a JAR file.


addJarErrorHeading

void addJarErrorHeading(java.lang.String jar)

getPluginsSubmenu

java.awt.Menu getPluginsSubmenu(java.lang.String submenuName)

getSubmenuName

java.lang.String getSubmenuName(java.lang.String jarPath)

addItemSorted

void addItemSorted(java.awt.Menu menu,
                   java.awt.MenuItem item,
                   int startingIndex)

addSeparator

void addSeparator(java.awt.Menu menu)

getConfigurationFile

java.io.InputStream getConfigurationFile(java.lang.String jar)
Opens the configuration file ("plugins.txt") from a JAR file and returns it as an InputStream.


autoGenerateConfigFile

java.io.InputStream autoGenerateConfigFile(java.lang.String jar)
Creates a configuration file for JAR/ZIP files that do not have one.


getStrippedPlugins

java.lang.String[] getStrippedPlugins(java.lang.String[] plugins)
Returns a list of the plugins with directory names removed.


getPlugins

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


checkSubdirectory

static void checkSubdirectory(java.lang.String path,
                              java.lang.String dir,
                              java.util.Vector v)
Looks for plugins and jar files in a subdirectory of the plugins directory.


installUserPlugin

void installUserPlugin(java.lang.String className)
Installs a plugin in the Plugins menu using the class name, with underscores replaced by spaces, as the command.


installPopupMenu

void installPopupMenu(ImageJ ij)

getMenuBar

public static java.awt.MenuBar getMenuBar()

getMacrosMenu

public static java.awt.Menu getMacrosMenu()

updateMenus

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


isColorLut

static boolean isColorLut(ImagePlus imp)

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.


insertWindowMenuItem

static void insertWindowMenuItem(java.awt.Frame win)
Inserts one item (a non-image window) into the Window menu.


addWindowMenuItem

static void addWindowMenuItem(ImagePlus imp)
Adds one image to the end of the Window menu.


removeWindowMenuItem

static void removeWindowMenuItem(int index)
Removes the specified item from the Window menu.


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 java.awt.PopupMenu getPopupMenu()

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)

convertShortcutToCode

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

installStartupMacroSet

void installStartupMacroSet()

validShortcut

static boolean validShortcut(java.lang.String shortcut)

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.