use of ij.macro.Interpreter in project astroimagej by keastrid.
the class GenericDialog method parseDouble.
public double parseDouble(String s) {
if (s == null)
return Double.NaN;
double value = Tools.parseDouble(s);
if (Double.isNaN(value)) {
if (s.startsWith("&"))
s = s.substring(1);
Interpreter interp = Interpreter.getInstance();
value = interp != null ? interp.getVariable2(s) : Double.NaN;
}
return value;
}
use of ij.macro.Interpreter in project astroimagej by keastrid.
the class SaveDialog method isMacro.
boolean isMacro() {
String macroOptions = Macro.getOptions();
if (macroOptions != null) {
String path = Macro.getValue(macroOptions, title, null);
if (path == null)
path = Macro.getValue(macroOptions, "path", null);
if (path != null && path.indexOf(".") == -1 && !((new File(path)).exists())) {
// Is 'path' a macro variable?
if (path.startsWith("&"))
path = path.substring(1);
Interpreter interp = Interpreter.getInstance();
String path2 = interp != null ? interp.getStringVariable(path) : null;
if (path2 != null)
path = path2;
}
if (path != null) {
Opener o = new Opener();
dir = o.getDir(path);
name = o.getName(path);
return true;
}
}
return false;
}
use of ij.macro.Interpreter in project astroimagej by keastrid.
the class TextPanel method select.
@AstroImageJ(reason = "Add opening of astro windows", modified = true)
void select(int x, int y) {
Dimension d = tc.getSize();
if (iRowHeight == 0 || x > d.width || y > d.height)
return;
int r = (y / iRowHeight) - 1 + iFirstRow;
int lineWidth = iGridWidth;
if (iColCount == 1 && tc.fMetrics != null && r >= 0 && r < iRowCount) {
char[] chars = (char[]) vData.elementAt(r);
lineWidth = Math.max(tc.fMetrics.charsWidth(chars, 0, chars.length), iGridWidth);
}
if (r >= 0 && r < iRowCount && x < lineWidth) {
selOrigin = r;
selStart = r;
selEnd = r;
} else {
resetSelection();
selOrigin = r;
if (r >= iRowCount)
selOrigin = iRowCount - 1;
}
tc.repaint();
selLine = r;
IJ.runPlugIn("Astronomy.UpdateAstroWindows", "");
Interpreter interp = Interpreter.getInstance();
if (interp != null && title.equals("Debug"))
interp.showArrayInspector(r);
}
use of ij.macro.Interpreter in project GDSC-SMLM by aherbert.
the class MultiDialog method getValue.
/**
* Get a value from the macro options. Adapted from ij.gui.GenericDialog.
*
* @param label
* @return The value (or null)
*/
private String getValue(String label) {
String theText = Macro.getValue(macroOptions, label, null);
if (theText != null && (theText.startsWith("&") || label.toLowerCase(Locale.US).startsWith(theText))) {
// Is the value a macro variable?
if (theText.startsWith("&"))
theText = theText.substring(1);
Interpreter interp = Interpreter.getInstance();
String s = interp != null ? interp.getVariableAsString(theText) : null;
if (s != null)
theText = s;
}
return theText;
}
use of ij.macro.Interpreter in project imagej1 by imagej.
the class BatchProcessor method runMacro.
private boolean runMacro(String macro, ImagePlus imp) {
WindowManager.setTempCurrentImage(imp);
Interpreter interp = new Interpreter();
try {
outputImage = interp.runBatchMacro(macro, imp);
} catch (Throwable e) {
interp.abortMacro();
String msg = e.getMessage();
if (!(e instanceof RuntimeException && msg != null && e.getMessage().equals(Macro.MACRO_CANCELED)))
IJ.handleException(e);
return false;
} finally {
WindowManager.setTempCurrentImage(null);
}
return true;
}
Aggregations