Plugins Menu



Introduction

Plugins and macros are loadable code modules that extend the capabilities of SalsaJ. Plugins are written in the Java programming language and compiled to .class files. Macros, written in SalsaJ's Java-like macro language, are stored in .txt files. Plugins run faster and are more flexible but macros are easier to write and debug. Plugins and macros in the plugins folder, with an underscore in their name, are listed at the bottom of this menu. Plugins and macros in subfolders of the plugins folder are listed in submenus. Use Shortcuts/Create Shortcut to assign a keyboard shortcut to a plugin or a macro.

Use the Record command to record a series of commands and to convert them to a macro. Use the New command to create a new macro or plugin and Edit to make changes to an existing one. More than 100 plugins are available on the ImageJ Web site as well as more than 80 macros. A tutorial for plugin writers is available at http://mtd.fh-hagenberg.at/depot/imaging/imagej/. Information about macros is available on the ImageJ Web site.

Internal Plugins
Most commands in SalsaJ are implemented as plugins but these internal plugins are located in the salsaj.jar file, not in the plugins folder. salsaj.jar also contains the properties file (IJ_Props.txt) that SalsaJ uses to install internal plugins in menus. A JAR file (Java ARchive) is formatted the same as a ZIP file, so you can use a ZIP utility to look at the contents of salsaj.jar.

You can convert an internal plugin to a user plugin by copying the source to the plugins folder, adding an underscore to the file name and class name, and changing the package statement to an import statement. For example, to change the RoiManager (analyse/Tools/ROI Manager) to a user plugin:

  1. Copy ij/plugin/frame/RoiManager.java to the plugins folder.
  2. Change the file name to Roi_Manager.java.
  3. Open Roi_Manager.java using Plugins/Edit and change all instances (4) of "RoiManager" to "Roi_Manager".
  4. Change the first line from "package ij.plugin.frame;" to "import ij.plugin.frame.*;".
  5. Run the new plugin using the editor's File/Compile and Run command.
There will be a new Roi Manager command in the Plugins menu the next time you restart SalsaJJ.

Changing Location of Plugins Directory
The "plugins.dir" property specifies the location of the parent of the plugins directory. This property can be set from either the command line or from within a Java program that starts SalsaJ. For example, if you run SalsaJ with the command

java -Dplugins.dir=/Users/wayne -cp ij.jar ij.ImageJ
it will look for the plugins folder in the /Users/wayne/ directory. This property can also be set in a program that launches SalsaJ:
System.getProperties().setProperty("plugins.dir", "/users/wayne");
new ImageJ(null);

Macros>
This submenu contains commands for installing, running and recording macros, as well as any macro commands added by Plugins/Macros/Install. Macros contained in a file named "StartupMacros.txt", in the macros folder, are automatically added to this submenu when SalsaJ starts up.

Install...
Adds one or more macros contained in a file to the bottom of this submenu. To install a set of macros, and at the same time view their source code, open the macro file with File/Open and use the editor's Macros/Install Macros command. Macros in the file ImageJ/macros/StartupMacros.txt are automatically installed when SalsaJ starts up.

Run...
Loads and runs a macro without opening it in the SalsaJ editor. To run a macro, and at the same time view its source code, open it with File/Open and use the editor's File/Run Macro command.

Record...
Opens the SalsaJ command recorder. To create a macro, open the recorder, use one or more SalsaJ commands, then click "Create". When the recorder is open, each menu command you use generates a macro run() function call. The run() function has one or two string arguments. The first is the command name. The optional second argument contains dialog box parameters.

Create a rectangular, oval or line selection and the recorder will generate a makeRectangle(), makeOval() or makeLine() function call. Click on "Auto" or "Set" in the Image/Adjust/Threshold window to generate a setThresold() call, and on "Reset" to generate a resetThresold() call. Select an image from the Window menu to generate a selectWindow() call. Click in the Image/colour/colour Picker window to generate setForegroundcolour() and setBackgroundcolour() calls.

Shortcuts>
This submenu contains commands for creating keyboard shortcuts and for installing and removing plugins.

Create Shortcut...
Assigns a keyboard shortcut to an SalsaJ menu command and lists the shortcut in the Shortcuts submenu.

Select the command from the popup menu and enter the shortcut in the text field. A shortcut can be a lower or uppercase letter or "F1" through "F12". Use Plugins/Utilities/List Shortcuts to get a list of shortcuts that are already being used.

Install Plugin...
Installs a plugin in a user-specified submenu. Plugins with a showAbout() method are also automatically added to the Help/About Plugins submenu.

Use the first popup menu to select the plugin and the second to select the submenu it is to installed in. The command must be different from any existing SalsaJ command. Shortcut (optional) must be a single letter or "F1" through "F12". Argument (optional) is the string that will passed to the plugin's run method.

Remove...
Removes commands added to the Shortcuts submenu by Create Shortcuts. Also removes commands added by Install Plugin and removes plugins installed in the Plugins menu. The menus are not updated until SalsaJ is restarted.

Utilites>

Control Panel...
This command opens a window containing SalsaJ commands in a hierarchical tree structure. Click on a leaf node to launch the corresponding SalsaJ command (or plugin). Double-click on a tree branch node (folder) to expand or collapse it. Click and drag on a tree branch node (folder) to display its descendants in a separate (child) window. In a child window, click on "Show Parent"to re-open the parent window. The Control Panel was contributed to the imageJ project by Cezar M. Tigaret.

Control Panel

Monitor Memory...
Displays a continuously updated graph of SalsaJ's memory utilisation, which can be useful for detecting memory leaks. Ideally you should be able to open a several images, process them, close them, and the amount of memory used will be the same as when you started. Clicking on SalsaJ's status bar, which forces the Java garbage collector run, may help reclaim unused memory. Start the memory monitor with the alt key down to have it use a 640x480 window that simulates how a frame grabber plugin would work.

Capture Screen
Copies the the screen to an RGB image and displays that image a new window. Pressing control-shift-g will capture the screen while a modal dialog box is active if the dialog is based on SalsaJ's GenericDialog class.

New...
Opens a new text window containing a prototype (as Java source code) for one of the three types of plugins supported by SalsaJ.

PlugIn: Opens, captures or generates images. Implements the PlugIn interface. The prototype displays "Hello world!" in the SalsaJ window. Another example is the Step Maker plugin at http://rsb.info.nih.gov/ij/plugins/steps.html.

PlugInFilter: Processes the active image. Implements the PlugInFilter interface. The prototype inverts the active image twice. Another example is the Image Inverter plugin at http://rsb.info.nih.gov/ij/plugins/inverter.html.

PlugInFrame: Displays a nonimage window containing controls such as buttons and sliders. Extends the PlugInFrame class. The prototype opens a window containing a text area. Another example is the IP Demo plugin at http://rsb.info.nih.gov/ij/plugins/ip-demo.html.

The text window created by this command has two menus: File and Edit. Use Compile and Run in the File menu to compile and run the plugin. The Edit menu does not contain Cut/Copy/Paste but the keyboard shortcuts for these function can be used. Note that the name you choose for the plugin must include at least one underscore.

Edit...
Opens a text window that allows you to edit, compile and run plugins. Like the Compile and Run command, it requires that SalsaJ be running on a Java Virtual Machine that includes the javac compiler.

Compile and Run...
Compiles and runs a plugin. Requires that SalsaJ be running on a Java Virtual Machine that includes the javac compiler. Javac is included with the Windows and Linux versions of SalsaJ that come bundled with a Java runtime. It is also included with Mac OS X Java. Users of Sun's Java 2 SDK (Software Development Kit) for Windows, Linux and Solaris must add tools.jar to the command line that runs SalsaJ. 

Here is an example Windows command line for running SalsaJ using the Java 2 SDK (aka JDK):

java -mx100m -cp salsaj.jar;C:\jdk1.4\lib\tools.jar ij.ImageJ
It assumes the Java 2 SDK is installed in C:\jdk1.4. On a Unix system, the command would look something like this:
java -mx100m -cp salsaj.jar:\usr\local\jdk1.4\lib\tools.jar ij.ImageJ
The -mx100 options specifies that SalsaJ can use up to 100MB of RAM. To avoid virtual memory thrashing, this value should not be set to more than 2/3 of available RAM (e.g. -mx170m on a 256MB machine).

On Windows, you can create a double-clickable shortcut that uses Java 2 to run SalsaJ:

  1. Right-click on the desktop and select New->Shortcut from the menu
  2. Enter     
         javaw -mx100m -cp salsaj.jar;C:\jdk1.4\lib\tools.jar ij.ImageJ
    as the "Command line"; click "Next"
  3. Enter a name for the shortcut (e.g. "SalsaJ"); click "Finish"
  4. Right-click of the newly created shortcut and select Properties from the menu
  5. Click on the Shortcut tab
  6. Enter the path to the SalsaJ folder (normally C:\SalsaJ) in "Start in"; click "OK"
"javaw" is a variation of the java command that runs Java applications without a DOS window.