Dynamically update slider value

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamically update slider value

anowlandafez
Hi,

I'm using a slider with values between 0-100 to change an images points of interest. However, each time I have to click 'ok' and wait for the product to be shown. I'd like to be able to slide the slider and for the image to change as I move the slider (I.E dynamically change the userValue).

GenericDialog gd = new GenericDialog("Choose value");
gd.addSlider("Value:", 1, 100, 0);
gd.showDialog();
Double userValue = gd.getNextNumber();

Any way to do this?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Dynamically update slider value

Michael Schmid
Hi Amy (am I guessing your name correctly?),

looks like a task for an ExtendedPlugInFilter with Preview.

There is a programming example at
  http://rsb.info.nih.gov/ij/plugins/cross-fader/index.html

In the run(ip) method you could also change the ROI; just save the ImagePlus as a class variable in the setup method and modify the ROI of the ImagePlus instead of the ImageProcessor in the run(ip) method.
The advantage of the ExtendedPlugInFilter is that it automaticalle reverts any changes you make to the ImageProcessor (i.e. image data) when you uncheck 'Preview' or press 'Cancel'.

If you only change the ROI, not the image data, a better option would be to just implement the DialogListener interface and add your plugin as a DialogListener to the GenericDialog.
Then update whatever you like in the dialogItemChanged method. An example is
  http://imagej.nih.gov/ij/source/ij/plugin/SpecifyROI.java
which is the code for the built-in Edit>Selection>Specify command.

Michael
________________________________________________________________


On Jun 24, 2015, at 14:45, anowlandafez wrote:

> Hi,
>
> I'm using a slider with values between 0-100 to change an images points of
> interest. However, each time I have to click 'ok' and wait for the product
> to be shown. I'd like to be able to slide the slider and for the image to
> change as I move the slider (I.E dynamically change the userValue).
>
> GenericDialog gd = new GenericDialog("Choose value");
> gd.addSlider("Value:", 1, 100, 0);
> gd.showDialog();
> Double userValue = gd.getNextNumber();
>
> Any way to do this?
>
> Thanks.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Dynamically update slider value

anowlandafez
Brilliant, thanks for your help Michael on both of my questions :)