Login  Register

Re: Dynamically update slider value

Posted by Michael Schmid on Jun 24, 2015; 6:24pm
URL: http://imagej.273.s1.nabble.com/Dynamically-update-slider-value-tp5013264p5013267.html

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