Skip to content

Commit

Permalink
2024.10.17 (1.54m12; Headless recording)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Oct 17, 2024
1 parent 49a6eb9 commit 6542086
Show file tree
Hide file tree
Showing 56 changed files with 107 additions and 101 deletions.
2 changes: 1 addition & 1 deletion ij/Executer.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void run() {
}
}
try {
if (Recorder.record) {
if (IJ.recording()) {
Recorder.setCommand(command);
runCommand(command);
Recorder.saveCommand();
Expand Down
8 changes: 6 additions & 2 deletions ij/IJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -1283,11 +1283,11 @@ else if (d.yesPressed()) {
error(msg);
return PlugInFilter.DONE;
}
if (Recorder.record)
if (IJ.recording())
Recorder.recordOption("stack");
return flags | PlugInFilter.DOES_STACKS;
}
if (Recorder.record)
if (IJ.recording())
Recorder.recordOption("slice");
}
return flags;
Expand Down Expand Up @@ -2574,4 +2574,8 @@ public static void protectStatusBar(boolean protect) {
statusBarThread = null;
}

public static boolean recording() {
return (!GraphicsEnvironment.isHeadless()&&Recorder.record);
}

}
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class ImageJ extends Frame implements ActionListener,

/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
public static final String VERSION = "1.54m";
public static final String BUILD = "9";
public static final String BUILD = "12";
public static Color backgroundColor = new Color(237,237,237);
/** SansSerif, 12-point, plain font. */
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);
Expand Down
4 changes: 2 additions & 2 deletions ij/ImagePlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ public ImageProcessor getProcessor() {
ip.setCalibrationTable(cal.getCTable());
else
ip.setCalibrationTable(null);
if (Recorder.record) {
if (IJ.recording()) {
Recorder recorder = Recorder.getInstance();
if (recorder!=null) recorder.imageUpdated(this);
}
Expand Down Expand Up @@ -2050,7 +2050,7 @@ public void setRoi(Roi newRoi, boolean updateDisplay) {
deleteRoi();
return;
}
if (Recorder.record) {
if (IJ.recording()) {
Recorder recorder = Recorder.getInstance();
if (recorder!=null) recorder.imageUpdated(this);
}
Expand Down
4 changes: 2 additions & 2 deletions ij/WindowManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void setCurrentWindow(ImageWindow win) {
activations.remove(win);
activations.add(win);
Menus.updateMenus();
if (Recorder.record && !IJ.isMacro())
if (IJ.recording() && !IJ.isMacro())
Recorder.record("selectImage", win.getImagePlus().getTitle());
}

Expand Down Expand Up @@ -574,7 +574,7 @@ synchronized static void activateWindow(String menuItemLabel, MenuItem item) {
else
((Dialog)win).toFront();
((CheckboxMenuItem)item).setState(false);
if (Recorder.record && !IJ.isMacro())
if (IJ.recording() && !IJ.isMacro())
Recorder.record("selectWindow", title);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion ij/gui/EllipseRoi.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void makePolygonRelative() {

protected void handleMouseUp(int screenX, int screenY) {
if (state==CONSTRUCTING) {
if (Recorder.record) {
if (IJ.recording()) {
double x1 = xpf[handle[2]]+x;
double y1 = ypf[handle[2]]+y;
double x2 = xpf[handle[0]]+x;
Expand Down
16 changes: 8 additions & 8 deletions ij/gui/GenericDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void addNumericField(String label, double defaultValue, int digits, int c
panel.add(new Label(" "+units));
add(panel, c);
}
if (Recorder.record || macro)
if (IJ.recording() || macro)
saveLabel(tf, label);
}

Expand Down Expand Up @@ -307,7 +307,7 @@ public void addStringField(String label, String defaultText, int columns) {
defaultStrings.addElement(defaultText);
tf.setDropTarget(null);
new DropTarget(tf, new TextDropTarget(tf));
if (Recorder.record || macro)
if (IJ.recording() || macro)
saveLabel(tf, label);
}

Expand Down Expand Up @@ -348,7 +348,7 @@ public void addDirectoryField(String label, String defaultPath, int columns) {
panel.add(button);
layout.setConstraints(panel, constraints);
add(panel);
if (Recorder.record || macro)
if (IJ.recording() || macro)
saveLabel(panel, label);
}

Expand Down Expand Up @@ -380,7 +380,7 @@ public void addFileField(String label, String defaultPath, int columns) {
panel.add(button);
layout.setConstraints(panel, constraints);
add(panel);
if (Recorder.record || macro)
if (IJ.recording() || macro)
saveLabel(panel, label);
}

Expand Down Expand Up @@ -668,7 +668,7 @@ public void addCheckboxGroup(int rows, int columns, String[] labels, boolean[] d
checkbox.addElement(cb);
cb.setState(defaultValues[i1]);
cb.addItemListener(this);
if (Recorder.record || macro)
if (IJ.recording() || macro)
saveLabel(cb, labels[i1]);
if (IJ.isLinux()) {
Panel panel2 = new Panel();
Expand Down Expand Up @@ -724,7 +724,7 @@ public void addRadioButtonGroup(String label, String[] items, int rows, int colu
c.anchor = GridBagConstraints.WEST;
c.insets = new Insets(insets.top, insets.left, 0, 0);
add(panel, c);
if (Recorder.record || macro)
if (IJ.recording() || macro)
saveLabel(cg, label);
}

Expand Down Expand Up @@ -771,7 +771,7 @@ public void addChoice(String label, String[] items, String defaultItem) {
choice.addElement(thisChoice);
int index = thisChoice.getSelectedIndex();
defaultChoiceIndexes.addElement(Integer.valueOf(index));
if (Recorder.record || macro)
if (IJ.recording() || macro)
saveLabel(thisChoice, label);
}

Expand Down Expand Up @@ -1021,7 +1021,7 @@ public void mouseWheelMoved(MouseWheelEvent e) {
c.insets.left = 0;
c.insets.bottom -= 3;
add(panel, c);
if (Recorder.record || macro)
if (IJ.recording() || macro)
saveLabel(tf, label);
}

Expand Down
6 changes: 3 additions & 3 deletions ij/gui/ImageCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -1100,13 +1100,13 @@ public void setDrawingColor(int ox, int oy, boolean setBackground) {

private void setForegroundColor(Color c) {
Toolbar.setForegroundColor(c);
if (Recorder.record)
if (IJ.recording())
Recorder.record("setForegroundColor", c.getRed(), c.getGreen(), c.getBlue());
}

private void setBackgroundColor(Color c) {
Toolbar.setBackgroundColor(c);
if (Recorder.record)
if (IJ.recording())
Recorder.record("setBackgroundColor", c.getRed(), c.getGreen(), c.getBlue());
}

Expand Down Expand Up @@ -1219,7 +1219,7 @@ else if (!e.isAltDown()) {
if (Prefs.smoothWand)
mode = mode + " smooth";
int npoints = IJ.doWand(imp, ox, oy, tolerance, mode);
if (Recorder.record && npoints>0) {
if (IJ.recording() && npoints>0) {
if (Recorder.scriptMode())
Recorder.recordCall("IJ.doWand(imp, "+ox+", "+oy+", "+tolerance+", \""+mode+"\");");
else {
Expand Down
2 changes: 1 addition & 1 deletion ij/gui/Line.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected void handleMouseUp(int screenX, int screenY) {
state = NORMAL;
if (imp==null) return;
imp.draw(clipX-5, clipY-5, clipWidth+10, clipHeight+10);
if (Recorder.record) {
if (IJ.recording()) {
String method = (this instanceof Arrow)?"makeArrow":"makeLine";
Recorder.record(method, x1, y1, x2, y2);
}
Expand Down
2 changes: 1 addition & 1 deletion ij/gui/PlotContentsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ else if (dialogType == ADD_FIT)
lastFitFunction = fitFunctionChoice.getSelectedItem();
IJ.log(curveFitterStatusString);
}
if (Recorder.record && !Recorder.scriptMode()) {
if (IJ.recording() && !Recorder.scriptMode()) {
if (dialogType == ADD_FROM_PLOT) {
Recorder.recordString("Plot.addFromPlot(\""+plotChoice.getSelectedItem()+"\", "+objectChoice.getSelectedIndex()+");\n");
} else if (dialogType == ADD_FROM_TABLE) {
Expand Down
4 changes: 2 additions & 2 deletions ij/gui/PlotDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void showDialog(Frame parent) {
plot.restorePlotObjects();
plot.update();
} else {
if (Recorder.record)
if (IJ.recording())
record();
String xAxisLabel = plot.getLabel('x');
if ((dialogType == AXIS_OPTIONS || dialogType == X_AXIS) && xAxisLabel != null && xAxisLabel.length() > 0)
Expand Down Expand Up @@ -513,7 +513,7 @@ private void doHighResolutionDialog(Frame parent) {
* but the user interface will show the high-res plot as foreground window */
EventQueue.invokeLater(new Runnable() {public void run() {IJ.selectWindow(hiresImp.getID());}});

if (Recorder.record) {
if (IJ.recording()) {
if (Recorder.scriptMode()) {
Recorder.recordCall("plot.makeHighResolution(\""+title+"\","+hiResFactor+","+hiResAntiAliased+",true);");
} else {
Expand Down
2 changes: 1 addition & 1 deletion ij/gui/PointRoi.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public PointRoi(int sx, int sy, ImagePlus imp) {
setCounter(Toolbar.getMultiPointMode()?defaultCounter:0);
incrementCounter(imp);
enlargeArrays(50);
if (Recorder.record) {
if (IJ.recording()) {
String add = Prefs.pointAddToOverlay?" add":"";
String options = sizes[convertSizeToIndex(size)]+" "+Colors.colorToString(getColor())+" "+types[type]+add;
options = options.toLowerCase();
Expand Down
2 changes: 1 addition & 1 deletion ij/gui/PolygonRoi.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ void finishPolygon() {
if (imp!=null && !(type==TRACED_ROI))
imp.draw(x-5, y-5, width+10, height+10);
oldX=x; oldY=y; oldWidth=width; oldHeight=height;
if (Recorder.record && userCreated && (type==POLYGON||type==POLYLINE||type==ANGLE
if (IJ.recording() && userCreated && (type==POLYGON||type==POLYLINE||type==ANGLE
||(type==POINT&&Recorder.scriptMode()&&nPoints==3)))
Recorder.recordRoi(getPolygon(), type);
if (type!=POINT) modifyRoi();
Expand Down
2 changes: 1 addition & 1 deletion ij/gui/Roi.java
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,7 @@ protected void handleMouseUp(int screenX, int screenY) {
state = NORMAL;
if (imp==null) return;
imp.draw(clipX-5, clipY-5, clipWidth+10, clipHeight+10);
if (Recorder.record) {
if (IJ.recording()) {
String method;
if (type==OVAL)
Recorder.record("makeOval", x, y, width, height);
Expand Down
2 changes: 1 addition & 1 deletion ij/gui/RotatedRectRoi.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void makePolygonRelative() {
protected void handleMouseUp(int screenX, int screenY) {
nPoints = 4;
state = NORMAL;
if (Recorder.record) {
if (IJ.recording()) {
double[] p = getParams();
if (Recorder.scriptMode())
Recorder.recordCall("imp.setRoi(new RotatedRectRoi("+(int)p[0]+","+(int)p[1]+","+(int)p[2]+","+(int)p[3]+","+(int)p[4]+"));");
Expand Down
2 changes: 1 addition & 1 deletion ij/gui/Toolbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ private void setTool2(int tool) {
if (null==g) return;
g.dispose();
showMessage(current);
if (Recorder.record) {
if (IJ.recording()) {
String name = getName(current);
if (name!=null && name.equals("dropper")) disableRecording=true;
if (name!=null && !disableRecording) {
Expand Down
2 changes: 1 addition & 1 deletion ij/io/DirectoryChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void getDirectoryUsingFileDialog(String title) {
public String getDirectory() {
if (IJ.debugMode)
IJ.log("DirectoryChooser.getDirectory: "+directory);
if (Recorder.record && !IJ.isMacOSX())
if (IJ.recording() && !IJ.isMacOSX())
Recorder.recordPath(title, directory);
return directory;
}
Expand Down
2 changes: 1 addition & 1 deletion ij/io/OpenDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public String getDirectory() {
/** Returns the selected file name. */
public String getFileName() {
if (name!=null) {
if (Recorder.record && recordPath && dir!=null)
if (IJ.recording() && recordPath && dir!=null)
Recorder.recordPath(title, dir+name);
lastName = name;
}
Expand Down
2 changes: 1 addition & 1 deletion ij/io/SaveDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public String getDirectory() {
/** Returns the selected file name. */
public String getFileName() {
if (name!=null) {
if (Recorder.record && dir!=null)
if (IJ.recording() && dir!=null)
Recorder.recordPath(title, dir+name);
OpenDialog.setLastName(name);
}
Expand Down
2 changes: 1 addition & 1 deletion ij/macro/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3953,7 +3953,7 @@ void floodFill() {
else
ff.fill8(x, y);
updateAndDraw();
if (Recorder.record && pgm.hasVars)
if (IJ.recording() && pgm.hasVars)
Recorder.record("floodFill", x, y);
}

Expand Down
2 changes: 1 addition & 1 deletion ij/measure/ResultsTableMacros.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void showDialog() {
}
if (runCount==0)
applyMacro();
if (Recorder.record) {
if (IJ.recording()) {
String macro = getMacroCode();
macro = macro.replaceAll("\n", " ");
if (Recorder.scriptMode()) {
Expand Down
2 changes: 1 addition & 1 deletion ij/plugin/Animator.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ void setSlice() {
t = (int) gd.getNextNumber();
imp.setPosition(c, z, t);
}
if (Recorder.record) {
if (IJ.recording()) {
String method = Recorder.scriptMode()?"imp":"Stack";
Recorder.recordString(method+".setPosition("+c+","+z+","+t+");\n");
Recorder.disableCommandRecording();
Expand Down
2 changes: 1 addition & 1 deletion ij/plugin/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void closeImage(ImagePlus imp) {
return;
}
imp.close();
if (Recorder.record && !IJ.isMacro()) {
if (IJ.recording() && !IJ.isMacro()) {
if (Recorder.scriptMode())
Recorder.recordCall("imp.close();");
else
Expand Down
2 changes: 1 addition & 1 deletion ij/plugin/Coordinates.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void run(String arg) {
}
ImageWindow win = imp.getWindow();
imp.repaintWindow();
if (Recorder.record) {
if (IJ.recording()) {
if (Recorder.scriptMode()) {
if (xUnitChanged)
Recorder.recordCall("imp.getCalibration().setXUnit(\""+xUnit2+"\");", true);
Expand Down
8 changes: 4 additions & 4 deletions ij/plugin/Duplicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public ImagePlus run(ImagePlus imp) {
Overlay overlay = imp.getOverlay();
if (overlay!=null && !imp.getHideOverlay())
imp2.setOverlay(overlay.crop(rect));
if (Recorder.record) {
if (IJ.recording()) {
if (imp.getRoi()==null || ignoreSelection)
Recorder.recordCall("imp = imp.duplicate();");
else
Expand Down Expand Up @@ -392,7 +392,7 @@ public ImagePlus run(ImagePlus imp, int firstSlice, int lastSlice) {
overlay2.crop(firstSlice, lastSlice);
imp2.setOverlay(overlay2);
}
if (Recorder.record)
if (IJ.recording())
Recorder.recordCall("imp = imp.crop(\""+firstSlice+"-"+lastSlice+"\");");
return imp2;
}
Expand Down Expand Up @@ -465,7 +465,7 @@ public ImagePlus run(ImagePlus imp, int firstC, int lastC, int firstZ, int lastZ
overlay2.crop(firstC, lastC, firstZ, lastZ, firstT, lastT);
imp2.setOverlay(overlay2);
}
if (Recorder.record)
if (IJ.recording())
Recorder.recordCall("imp = new Duplicator().run(imp, "+firstC+", "+lastC+", "+firstZ+", "+lastZ+", "+firstT+", "+lastT+");");
return imp2;
}
Expand Down Expand Up @@ -529,7 +529,7 @@ String showDialog(ImagePlus imp, String dialogTitle, String prompt) {
if (!ignoreNextSelection) staticIgnoreSelection=ignoreSelection;
}
ignoreNextSelection = false;
if (Recorder.record && titleField!=null && titleField.getText().equals(sliceLabel))
if (IJ.recording() && titleField!=null && titleField.getText().equals(sliceLabel))
Recorder.recordOption("use");
return title;
}
Expand Down
2 changes: 1 addition & 1 deletion ij/plugin/FFT.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void run(String arg) {
doForwardTransform(fht);
}
IJ.showProgress(1.0);
if (Recorder.record) {
if (IJ.recording()) {
if (inverse)
Recorder.recordCall("imp = FFT.inverse(imp);");
else
Expand Down
2 changes: 1 addition & 1 deletion ij/plugin/FolderOpener.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ else if (label2!=null && !label2.equals(""))
image = imp2;
}
IJ.showProgress(1.0);
if (Recorder.record) {
if (IJ.recording()) {
String options = openAsVirtualStack&&!openAsSeparateImages?"virtual":"";
if (bitDepth!=defaultBitDepth)
options = options + " bitdepth=" + bitDepth;
Expand Down
Loading

0 comments on commit 6542086

Please sign in to comment.