here.
dialog.
> Thank you. I'm testing with two dimensions X and Y but can not get the
> slider1 value and set to slider2...
>
> import ij.*;
> import ij.gui.GenericDialog;
> import ij.gui.DialogListener;
> import ij.ImagePlus;
> import ij.process.*;
> import ij.plugin.PlugIn;
> import ij.gui.*;
> import java.awt.*;
>
> public class Dialog_Test implements PlugIn, DialogListener {
> private static GenericDialog gd;
> String text;
>
> public void run(String arg) {
> showDialog();
> IJ.log("Text: "+text);
> }
>
> void showDialog() {
> gd = new GenericDialog("Test Dialog");
> gd.addSlider("X", 0, 100, 0);
> gd.addSlider("Y", 0, 200, 0);
> gd.addDialogListener(this);
> gd.showDialog();
> }
>
>
> public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
>
> final double Valor_X = gd.getNextNumber();
> final double Valor_Y = gd.getNextNumber();
> IJ.log("Slider 1 value: "+gd.getSliders().get(0));
>
> // I want to set Slider 1 value to Slicder2...
>
>
> return true;
> }
>
>
> }
>
>
> How can I set the slider 1 value to slider 2?
>
> Thank you and best regards!
>
> 2014-12-02 11:35 GMT+01:00 Jan Eglinger <
[hidden email]>:
>
>> Hi Xavier,
>>
>>
>> On 01.12.14 17:54, Xavier Colomé wrote:
>>
>>> Hello, I'm testing with dialogs and I want to create three sliders that
>>> interact with each other. The sum of the three slider must total 100%. By
>>> example:
>>>
>>> X [----*-----] [5]
>>> Y [--*-------] [3]
>>> Z [-*--------] [2]
>>>
>>> By example, if I move one of te three slider to 100% then we can not move
>>> the other two slider above 0%
>>>
>>> By example, this is a not permited configuration:
>>>
>>> X [---*------] [4]
>>> Y [------*---] [7]
>>> Z [-*--------] [2]
>>>
>>> Is it possible?
>>>
>>>
>> You can use the ij.gui.DialogListener class [1] for this. Your plugin
>> should implement `DialogListener` and include a `dialogItemChanged` method
>> that set the slider values according to your constraints.
>>
>> Below I paste the code of a python script that has three sliders (X,Y,Z)
>> whose values always sum up to 100. Just paste it into Fiji's script editor
>> and press "Run". It has limited functionality (the Z slider cannot be
>> adjusted on its own), but you might get the idea.
>>
>> Hope that helps,
>> Jan
>>
>> [1]:
http://javadoc.imagej.net/ImageJ1/index.html?ij/gui/>> DialogListener.html
>>
>>
>> ********* Python script to demonstrate slider listeners ***********
>>
>> from ij import IJ
>> from ij.gui import DialogListener
>> from ij.gui import GenericDialog
>>
>> class MyDL (DialogListener):
>> def dialogItemChanged(self, dialog, event):
>> x = dialog.getNextNumber()
>> y = dialog.getNextNumber()
>> z = dialog.getNextNumber()
>> sliders = dialog.getSliders()
>> numFields = dialog.getNumericFields()
>> zSlider = sliders.get(2)
>> zField = numFields.get(2)
>> zSlider.setValue((int)(100-(x+y)))
>> zField.setText(IJ.d2s(100-(x+y), 0))
>> return 1
>>
>> gd = GenericDialog("Slider Listener")
>> gd.addSlider("X", 0, 100, 50)
>> gd.addSlider("Y", 0, 100, 20)
>> gd.addSlider("Z", 0, 100, 30)
>> gd.addDialogListener(MyDL())
>> gd.showDialog()
>>
>>
>>
>>
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>