ImageJ插件:状态栏和进度条不更新

时间:2016-07-31 02:00:52

标签: imagej

我正在为ImageJ编写一个插件。我试图使用命令

显示进度
<script>
    // The following manages the sliders so that vertical swiping (scrolling) never inadvertently changes a slider value
    $(function() {
        var timerId;
        $.event.special.tap.tapholdThreshold = 250;  // default is 750, but that seems too long for this scenario

        $(".input-container")
            .on('taphold', tapholdHandler)
            .on('touchmove', moveHandler)
            .on('touchend', endHandler)
        ;
        $('.input-container input')
            .prop('disabled', false).removeClass('ui-state-disabled')  // allow the user to edit the displayed value
            .on('change', function() {
                $(this).slider('refresh');
                $(this).prop('disabled', false).removeClass('ui-state-disabled');  // override the above line's disabling of the text field
                $(this).blur();
            })
        ;

        function tapholdHandler(event) {
            $(event.currentTarget).find('input').slider('enable').slider('refresh');
        }

        function moveHandler(event) {
            if (timerId)
                clearTimeout(timerId);  // as long as the user is interacting with the slider, don't revert it to disabled
            $(document.elementFromPoint(event.originalEvent.targetTouches[0].clientX, event.originalEvent.targetTouches[0].clientY)).trigger('vmousedown');
        }

        function endHandler(event) {
            $(document.elementFromPoint(event.originalEvent.changedTouches[0].clientX, event.originalEvent.changedTouches[0].clientY)).trigger('vmousedown').trigger('vmouseup');  // the purpose of this is to move the slider knob even if the user's touch didn't move
            timerId = setTimeout(function() {  // give the above induced event time to run the associated handler
                    $(event.currentTarget).find('input').slider('disable').slider('refresh');
                    $(event.currentTarget).find('input').prop('disabled', false).removeClass('ui-state-disabled');  // allow the user to edit the displayed value
            }, 2000);
        }
    });
</script>

IJ.showStatus(String message)

插件运行完成,但没有显示任何状态更新。有没有办法强制显示?我已经尝试强制重绘并在showStatus调用之后等待

IJ.showProgress(int currentIndex, int finalIndex)

但这没效果

1 个答案:

答案 0 :(得分:2)

由于按钮按下,调用了耗时的计算。这捆绑了UI线程。

我能够通过创建一个新线程来运行计算来解决问题。

相关问题