From 87f70c2e73d811723b46431ad16c1d2bead89ca4 Mon Sep 17 00:00:00 2001 From: haesleinhuepf Date: Sat, 12 Sep 2020 21:10:06 +0200 Subject: [PATCH 1/2] sync autocomplete with website https://imagej.nih.gov/ij/developer/macro/functions.html --- .../resources/doc/ij1macro/functions.html | 409 +++++++++++++++--- 1 file changed, 356 insertions(+), 53 deletions(-) diff --git a/src/main/resources/doc/ij1macro/functions.html b/src/main/resources/doc/ij1macro/functions.html index e077e9b75..969915446 100644 --- a/src/main/resources/doc/ij1macro/functions.html +++ b/src/main/resources/doc/ij1macro/functions.html @@ -406,6 +406,26 @@

Built-in Macro Functions

Adds a popup menu, where items is a string array containing the choices and default is the default choice.
+ +Dialog.addDirectory(label, defaultPath) - +Adds a directory field and "Browse" button. The +field width is determined by the length of 'defaultPath', +with a minimum of 25 columns. Use Dialog getString +to retrieve the directory path. Requires 1.53d. +
+ +Dialog.addFile(label, defaultPath) - +Adds a file field and "Browse" button. The +field width is determined by the length of 'defaultPath', +with a minimum of 25 columns. Use Dialog getString +to retrieve the file path. Requires 1.53d. +
+ +Dialog.addImageChoice(label) - +Adds a popup menu that lists the currently open images. +Use Dialog getImageChoice() to retrieve the title of +the selected image. Requires 1.53d. +
Dialog.addHelp(url) - Adds a "Help" button that opens the specified URL in the default browser. This can be used to supply @@ -421,7 +441,6 @@

Built-in Macro Functions

the buttons appear to the right of the previous item. Note that addMessage (and addString if a width of more than 8 is specified) use the remaining width, so it must be the last item of a row. -Requires 1.51r.
Dialog.setInsets(top, left, bottom) - @@ -446,7 +465,8 @@

Built-in Macro Functions


Dialog.getString() - -Returns a string containing the contents of the next text field. +Returns a string containing the contents of the next text, +directory or file field.
Dialog.getNumber() - @@ -464,6 +484,11 @@

Built-in Macro Functions

Dialog.getRadioButton() - Returns the selected item (a string) from the next radio button group.
+ +Dialog.getImageChoice() - +Returns the title of the image selected in the next image +choice popup menu. +
@@ -911,7 +936,12 @@

Built-in Macro Functions

Fit.getEquation(index, name, formula) - -Gets the name and formula of the specified equation. +Returns the name and formula of the specified equation. +
+ + +Fit.getEquation(index, name, formula, macroCode) - +Returns the name, formula and macro code of the specified equation.
@@ -1007,58 +1037,53 @@

Built-in Macro Functions

-getDirectory(string)
-Displays a "choose directory" dialog and returns the selected directory, or returns -the path to a specified directory, such as "plugins", "home", etc. -The returned path ends with a file separator, either "\" (Windows) or "/". -Returns an empty string if the specified directory is not found or -aborts the macro if the user cancels the "choose directory" dialog box. -For examples, see the -GetDirectoryDemo and -ListFilesRecursively macros. -See also: getFileList and the File functions. - -getDir(string)
+getDirectory(string) or getDir(string)
Displays a "choose directory" dialog and returns the selected directory, or returns the path to a specified directory, such as "plugins", "home", etc. -The returned path ends with a file separator, either "\" (Windows) or "/". +The returned path ends with the file separator ("/"). Returns an empty string if the specified directory is not found or aborts the macro if the user cancels the "choose directory" dialog box. For examples, see the GetDirectoryDemo and ListFilesRecursively macros. -See also: getFileList and the File functions. +See also: getFileList and the File functions. -getDirectory("Choose a Directory") - +

+ + +getDir("Choose a Directory") - Displays a file open dialog, using the argument as a title, and returns the path to the directory selected by the user.
- -getDirectory("plugins") - -Returns the path to the plugins directory.
-getDirectory("macros") - -Returns the path to the macros directory.
+getDir("downloads") - +Returns the path to the Downloads directory.
-getDirectory("luts") - -Returns the path to the luts directory.
+getDir("file") - +Returns the path most recently used to open or save a file.
-getDirectory("image") - -Returns the path to the directory that the active image was loaded from.
+getDir("home") - +Returns the path to the Home directory.
-getDirectory("imagej") - -Returns the path to the ImageJ directory.
+getDir("image") - +Returns the path to the directory that the active image was loaded from.
-getDirectory("startup") - -Returns the path to the directory that ImageJ was launched from.
+getDir("imagej") - +Returns the path to the ImageJ directory.
-getDirectory("home") - -Returns the path to users home directory.
+getDir("luts") - +Returns the path to the luts directory.
-getDirectory("downloads") - -Returns the path to users downloads directory.
+getDir("macros") - +Returns the path to the macros directory.
-getDirectory("temp") - +getDir("plugins") - +Returns the path to the plugins directory.
+ +getDir("startup") - +Returns the path to the directory that ImageJ was launched from.
+ +getDir("temp") - Returns the path to the temporary directory (/tmp on Linux and Mac OS X).
@@ -1123,7 +1148,8 @@

Built-in Macro Functions

getInfo("window.contents"). For an example, see the ListDicomTags macros. -See also: getMetadata. +See also: getMetadata and +Property.getInfo.

@@ -1167,7 +1193,7 @@

Built-in Macro Functions

getInfo("image.title")
Returns the title of the current image. Same as -getTitle. +getTitle.

getInfo("image.subtitle")
@@ -1335,15 +1361,17 @@

Built-in Macro Functions

getMetadata("Info")
Returns the metadata (a string) from the "Info" property of the current image. With DICOM images, this is the information (tags) in the DICOM header. -See also: setMetadata. +See also: setMetadata and +Property.getInfo.

getMetadata("Label")
Returns the current slice label. The first line of the this label (up to 60 characters) is display as part of the image subtitle. -With DICOM stacks, returns the metadata from the DICOM header. -See also: setMetadata. +With DICOM stacks, returns the metadata (tags) from the DICOM header. +See also: Property.getSliceLabel and +Property.setSliceLabel.

@@ -2156,6 +2184,11 @@

Built-in Macro Functions

Returns the cosine of an angle (in radians).
+ +Math.erf(x)
+Returns an approximation of the error function. +
+ Math.exp(n)
Returns the exponential number e (i.e., 2.718...) raised to the power of n. @@ -2221,11 +2254,13 @@

Built-in Macro Functions

maxOf(n1, n2)
Returns the greater of two values. -

+See also: Math.max. +

minOf(n1, n2)
Returns the smaller of two values. +See also: Math.min.

@@ -2452,6 +2487,12 @@

Built-in Macro Functions

Activates the specified overlay selection.
+ +Overlay.activateSelectionAndWait(index)
+Activates the specified overlay selection and waits +for the display to finish updating. +
+ Overlay.moveSelection(index, x, y)
Moves the specified selection to the specified location. @@ -2462,6 +2503,26 @@

Built-in Macro Functions

Removes the specified selection from the overlay.
+ + +Overlay.indexAt(x,y)
+Returns the index of the last selection in the overlay containing the point (x,y), +or an empty string if no selection contains the point. +Requires 1.53b. +
+ + +Overlay.getBounds(index,x,y,width,height)
+Returns the bounding rectangle of the selection in the overlay specified by 'index'. +Requires 1.53b. +
+ + +Overlay.removeRois(name)
+Removes the selections named 'name' from the overlay. +Requires 1.53b. +
+ Overlay.copy
Copies the overlay on the current image to the overlay clipboard. @@ -2490,11 +2551,16 @@

Built-in Macro Functions

Sets the color used to draw labels.
+ +Overlay.useNamesAsLabels(boolean)
+Controls whether ROI names or index numbers +are used as labels. +
+ Overlay.selectable(false)
Prevents the selections in this overlay from being activated by clicking on their labels or by long clicking. -Requires 1.51r.
@@ -2517,6 +2583,14 @@

Built-in Macro Functions

Creates a new RGB image that has the overlay rendered as pixel data.
+ +Overlay.cropAndSave(dir, format)
+Saves the contents of the overlay selections as separate images, +where 'dir' is the directory path and 'format' is "tif", "png" or "jpg". +Set 'format' to "show" and the images will be displayed in a stack +and not saved. Requires 1.53d. +
+ P [ Top ]

@@ -2747,6 +2821,29 @@

Built-in Macro Functions

command. Requires 1.52h.
+ +Plot.setOptions(string)
+Sets options for the plot. Multiple options may be separated by +whitespace or commas. Note that whitespace surrounding the '=' +characters is not allowed. Currently recognized options are:
+ "addhspace=10 addvspace=5" - Increases the left and right or top and bottom + margins by the given number of pixels.
+ "xinterval=30 yinterval=90" - Sets interval between numbers, major ticks and grid lines + (default intervals are used if the custom intervals would be too dense or too sparse)
+ "xdecimals=2 ydecimals=-1" - Sets the minimum number of decimals; use negative + numbers for scientific notation.
+ "msymbol=' \\u00d7" - Sets multiplication symbol for scientific notation, + here a cross with spaces.
+For an example, run the Help>Examples>Plots>Plot Results command. +Requires 1.53a. +
+ + +Plot.replace(index, type, xValues, yValues)
+Replaces the plot object (curve, Label, etc.) with the specified index +by points or a curve as specified in Plot.add(type, xValues, yValues). +
+ Plot.useTemplate("plot name" or id)
Transfers the formatting of an open plot window to the current plot. @@ -2852,6 +2949,76 @@

Built-in Macro Functions

macros for examples.

+ + Property Functions
+Functions for reading and writing image properties, +available in ImageJ 1.53a or later. +

+ + +Property.get(key)
+Returns the image property (a string) associated with key, +or an empty string if key is not found. +
+ + +Property.getNumber(key)
+Returns the image property associated with key, +as a number, or returns NaN if key is not found +or the property cannot be converted into a number. +Requires 1.53b. +
+ + +Property.set(key, property)
+Adds a key-value pair to the property list of the current image. +key must be a string but property can be either a +string or a number. +The key-value pair is removed if property is an empty string. +Add a "ShowInfo" property (e.g. Property.set("ShowInfo","true")) and +the property list will be displayed by the Image>Show Info +command (requires 1.53b). The property list is persistent when the +image is saved in TIFF format. +
+ + +Property.getInfo()
+Returns the image "info" property string (e.g. DICOM tags or Bio-Formats metadara), +or an empty string if there is no "Info" property. +
+ + +Property.getSliceLabel
+Returns the current slice label. +The first line of the label (up to 60 characters) is displayed +as part of the image subtitle. +With DICOM stacks, returns the DICOM header metadata (tags). +
+ + +Property.setSliceLabel(string, slice)
+Sets string as the label of the specified stack slice, +were 1<=slice<=nslices. +The first 60 characters, up to the first newline, +of the label are displayed as part of the image subtitle. +Slice labels are saved in the TIFF header. +
+ + +Property.getList
+Returns the properties as a string (e.g. +"key1=value1\nkey2=value2"). +Requires 1.53b. +
+ + +Property.setList(string)
+Sets the properties from the key/value pairs in 'string'. +Requires 1.53b. +
+ +
+ R [ Top ]

@@ -2879,8 +3046,8 @@

Built-in Macro Functions

replace(string, old, new)
Returns a string that results from replacing all occurrences of -old in string with new, where old and new -are single character strings. If old or new are longer than +old in string with new, where old +is a single character string. If old is longer than one character, each substring of string that matches the regular expression @@ -3098,6 +3265,8 @@

Built-in Macro Functions

Roi.setGroup(group) - Sets the group (a positive number) of the current selection. Zero sets the group to "none". +See also: RoiManager.selectGroup +and RoiManager.setGroup. Requires 1.52t.
@@ -3108,13 +3277,33 @@

Built-in Macro Functions

Requires 1.52t.
+ +Roi.setDefaultGroup(group) - +Sets the default group (a positive number) of the current selection. +Zero sets the default group to "none". +Requires 1.52t. +
+ + +Roi.getDefaultGroup - +Returns the default group (a positive number) of the current selection, +or zero if the selection is not in a group. +Requires 1.52t. +
+ +Roi.setPosition(slice) - +Sets the selection position. +Requires 1.53b. +
+ + Roi.setPosition(channel, slice, frame) - Sets the selection position. Requires 1.52r.
- + Roi.getPosition(channel, slice, frame) - Returns the selection position. Requires 1.52r. @@ -3127,6 +3316,33 @@

Built-in Macro Functions

Requires 1.52r.
+ + +Roi.setJustification(str) - +Sets the justification ("left","center" or "right") +of the current text selection. +Requires 1.53b. +
+ + +Roi.setFontSize(size) - +Sets the font size (in points) +of the current text selection. +Requires 1.53b. +
+ + +Roi.getGroupNames - +Returns the group names as a comma-delimeted string. +Requires 1.53b. +
+ + +Roi.setGroupNames(string) - +Sets the group names from a comma-delimeted string. +Requires 1.53b. +
+ Roi.remove
Deletes the selection, if any, from the active image. @@ -3314,6 +3530,58 @@

Built-in Macro Functions

+ + Additional ROI Manager Functions
+ These functions for working with the ROI Manager are available + in ImageJ 1.52u and later. +
+ + +RoiManager.multiCrop(dir, options)
+If 'options' contains "save", saves the contents of the selected ROIs +in TIFF format as separate images, where 'dir' is the directory path. +Add " png" or " jpg" to save in PNG or JPEG format. +Add ' show' and the images will be displayed in a stack. +Requires 1.53d. +
+ + +RoiManager.getName(index)
+Returns the name of the selection with the specified index, or an empty string +if the selection does not have a name.. +
+ + +RoiManager.select(index)
+Activates the selection at the specidied index. +
+ + +RoiManager.selectGroup(group)
+Selects all ROIs in the ROI Manager that belong to group. +
+ + +RoiManager.setGroup(group)
+Sets the group of the selected ROIs. +See also: Roi.setGroup, +Roi.getGroup, +Roi.setDefaultGroup and +Roi.getDefaultGroup. +
+ + +RoiManager.setPosition
+Sets the position of the selected selections.. +
+ +
+RoiManager.size
+Returns the ROI Manager selection count. +
+ +
+ round(n)
Returns the closest integer to n. @@ -3322,14 +3590,22 @@

Built-in Macro Functions

-run("command"[, "options"])
-Executes an ImageJ menu command. The optional second argument contains values that -are automatically entered into dialog boxes (must be GenericDialog or OpenDialog). Use -the Command Recorder (Plugins>Macros>Record) to generate run() function calls. +run(command)
+Executes an ImageJ menu command. Use the Command Recorder +(Plugins>Macros>Record) to generate run() function calls. +

+ + +run(command, options)
+Executes an ImageJ menu command with arguments. The 'options' string +contains values that are automatically entered into dialog boxes +(must be GenericDialog or OpenDialog). Use the Command Recorder +(Plugins>Macros>Record) to generate run() function calls. Use string concatenation to pass a variable as an argument. With ImageJ 1.43 and later, variables can be passed without using string concatenation by adding "&" to the variable name. For examples, see the ArgumentPassingDemo macro. +Plugins can directly retrieve the 'options' string by calling Macro.getOptions().

@@ -3400,6 +3676,8 @@

Built-in Macro Functions

if the selection does not have a name. Aborts the macro if there is no selection. See also: +Roi.getName, +Roi.setName, setSelectionName and selectionType.

@@ -3410,6 +3688,7 @@

Built-in Macro Functions

5=straight line, 6=segmented line, 7=freehand line, 8=angle, 9=composite and 10=point. Returns -1 if there is no selection. For an example, see the ShowImageInfo macro. +See also: Roi.getType,

@@ -3593,6 +3872,7 @@

Built-in Macro Functions

to set the location of the next opened window. See also: getLocationAndSize, +Table.setLocationAndSize, screenWidth, screenHeight.

@@ -3622,7 +3902,8 @@

Built-in Macro Functions

image property of the current image. This metadata is displayed by Image>Show Info and saved as part of the TIFF header. -See also: getMetadata. +See also: getMetadata and +Property.getInfo.

@@ -3631,7 +3912,8 @@

Built-in Macro Functions

The first 60 characters, or up to the first newline, of the label are displayed as part of the image subtitle. The labels are saved as part of the TIFF header. -See also: getMetadata. +See also: Property.setSliceLabel and +Property.getSliceLabel.

@@ -3727,7 +4009,15 @@

Built-in Macro Functions

Enables/disables support for auto-expanding arrays (example).
- + +setOption("FlipFitsImages",boolean)
+Controls whether images are flipped vertically by the FITS reader. +
+ +setOption("InterpolateLines",boolean)
+Sets/resets the 'Interpolate line profiles' option in Edit>Options>Plots. +
+ setOption("InvertY", boolean)
Sets/resets the 'invertY' option of the active image.
@@ -3880,6 +4170,8 @@

Built-in Macro Functions

setSlice(n)
Displays the nth slice of the active stack. Does nothing if the active image is not a stack. +Use Stack.setPosition(channel,slice,frame) +to set hyperstack positions. For an example, see the MeasureStack macros. @@ -4271,6 +4563,13 @@

Built-in Macro Functions

Example.
+ +String.format(format, number) - +Returns a formatted string using the specified +format +and number. +
+ String.paste - Returns the contents of the clipboard. @@ -4439,6 +4738,10 @@

Built-in Macro Functions

Table.showRowIndexes(boolean) - Enable/disable display of row indexes.
+ +Table.saveColumnHeader(boolean) - +The column header row is not saved if the argument is 'false' (default is 'true'). +
Table.showArrays(title, array1, array2, ...) - Displays arrays in a table (same as Array.show). From 0fcee36b13cb37b092d1849cab6da7eac1dbdc89 Mon Sep 17 00:00:00 2001 From: Robert Haase Date: Sun, 27 Sep 2020 16:26:44 +0200 Subject: [PATCH 2/2] Added a semicolon Missing semicolon was spotted by LPUoO https://forum.image.sc/t/auto-code-completion-for-ij-macro/11642/147 --- src/main/resources/doc/ij1macro/functions_extd.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/doc/ij1macro/functions_extd.html b/src/main/resources/doc/ij1macro/functions_extd.html index efff78f6c..75ecddbaa 100644 --- a/src/main/resources/doc/ij1macro/functions_extd.html +++ b/src/main/resources/doc/ij1macro/functions_extd.html @@ -15,7 +15,7 @@ All commands inside an else block are executed if the expression in the earlier if block is false. -filelist = getFileList(directory)
for (i = 0; i < lengthOf(filelist); i++) {
if (endsWith(filelist[i], ".tif")) {
open(directory + File.separator + filelist[i]);
}
}
+filelist = getFileList(directory);
for (i = 0; i < lengthOf(filelist); i++) {
if (endsWith(filelist[i], ".tif")) {
open(directory + File.separator + filelist[i]);
}
}
A for loop which opens all files ending with ".tif" in a folder.