Search in sources :

Example 11 with Interpreter

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;
}
Also used : Interpreter(ij.macro.Interpreter)

Example 12 with Interpreter

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;
}
Also used : Interpreter(ij.macro.Interpreter)

Example 13 with Interpreter

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);
}
Also used : Interpreter(ij.macro.Interpreter) AstroImageJ(ij.astro.AstroImageJ)

Example 14 with Interpreter

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;
}
Also used : Interpreter(ij.macro.Interpreter)

Example 15 with Interpreter

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;
}
Also used : Interpreter(ij.macro.Interpreter)

Aggregations

Interpreter (ij.macro.Interpreter)22 Rectangle2D (java.awt.geom.Rectangle2D)2 ImagePlus (ij.ImagePlus)1 AstroImageJ (ij.astro.AstroImageJ)1 Roi (ij.gui.Roi)1 Program (ij.macro.Program)1 Tokenizer (ij.macro.Tokenizer)1 Calibration (ij.measure.Calibration)1 BufferedImage (java.awt.image.BufferedImage)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ImageDisplay (qupath.lib.display.ImageDisplay)1 PathAnnotationObject (qupath.lib.objects.PathAnnotationObject)1 PathObject (qupath.lib.objects.PathObject)1 TMACoreObject (qupath.lib.objects.TMACoreObject)1 RegionRequest (qupath.lib.regions.RegionRequest)1 LineROI (qupath.lib.roi.LineROI)1 RectangleROI (qupath.lib.roi.RectangleROI)1 ROI (qupath.lib.roi.interfaces.ROI)1