【问题标题】:ImageJ API WaitForUserDialogImageJ API 等待用户对话框
【发布时间】:2015-07-16 23:05:17
【问题描述】:

我正在尝试为 ImageJ 编写一个插件,该插件将提示用户使用菜单栏中内置的矩形选择工具按钮在图像的某个区域中选择一个矩形 ROI。这是我的代码:

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;

public class computeDOP implements PlugIn {

public void run(String arg) {
    IJ.showMessage("DOP Plugin Status","Load Image");       
    ImagePlus imp = IJ.openImage();
    imp.show();
    IJ.showMessage("DOP Plugin Status","Phantom Loaded, Select Rectangle ROI");     

    //Image ROI
    WaitForUserDialog wait = new WaitForUserDialog("Select a Rectangular ROI", "Please press OK when done.");
    wait.show();
    Roi userROI = impPhantom.getRoi();

    //Create a profile plot
    ProfilePlot pPlotPhantom = new ProfilePlot(impPhantom, true);
    double[] phanProfile = pPlotPhantom.getProfile();



}

我的问题是焦点转移到由于 WaitForUserDialog 而出现的提示对话框。然后它将不允许用户使用 ImageJ 内置的任何菜单工具。我的目标是停止插件,并等待用户在出现的对话框上单击确定。但是,我需要我的用户能够使用矩形选择工具。我是否应该寻找其他方法来停止我的插件并提示用户选择 ROI?

【问题讨论】:

    标签: javascript imagej


    【解决方案1】:

    您应该使用WaitForUserDialog#show() method 来确保插件实际上在等待用户输入,并且只有在按下 OK 后才会继续。

    【讨论】:

    • 我已经编辑了上面的代码来回复这个答案。 new 运算符也有一个错字(现已修复)。现在我的问题是代码不允许用户选择投资回报率。用户只能在弹出的对话框中点击“确定”,用户根本无法进行图像选择。这与我最初遇到的问题完全相同。
    • 我想我需要暂停整个插件,直到用户在对话框上单击“确定”,但我不知道该怎么做。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-11
    • 2014-06-19
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多