ThreeB 1.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Package Functions | Package Attributes | Private Attributes
FloatSliderWithBox Class Reference
Classes related to the ImageJ Plugin

This class makes a floating point slider bar with an edit box next to it for more precision. More...

List of all members.

## Classes
class | SliderChanged
class | TextChanged
## Public Member Functions
| FloatSliderWithBox (String text_, double min_, double max_, double value_, int cols, boolean rec_)
FloatSliderWithBox | setUnits (String s)
FloatSliderWithBox | setFormat (String s)
void | addChangeListener (ChangeListener changeListener)
double | get_value_from_slider ()
double | get_value_from_text ()
## Package Functions
void | setValue (double v)
double | getValue ()
## Package Attributes
double | max
## Private Attributes
JSlider | slider
JTextField | number
JLabel | label
GridBagConstraints | completePanelConstraints_
int | steps = 1000000
double | min
String | text
String | units
String | format = "%8.3f"
double | value
boolean | reciprocal

## Detailed Description

This class makes a floating point slider bar with an edit box next to it for more precision.

Also has a reciprocal option for inverse, reciprocal scaling./

Definition at line 685 of file three_B.java.

## Constructor & Destructor Documentation

FloatSliderWithBox::FloatSliderWithBox | ( | String | text_,
|  | double | min_,
|  | double | max_,
|  | double | value_,
|  | int | cols,
|  | boolean | rec_
| ) |  | `[inline]`

Definition at line 701 of file three_B.java.

References completePanelConstraints_, label, max, min, number, reciprocal, setValue(), slider, steps, text, and value.

        {

            super( new GridBagLayout() );

            reciprocal = rec_;
            min=min_;
            max=max_;
            text=text_;
            value = value_;

            if(reciprocal)
            {
                min=1/max_;
                max=1/min_;
            }

            slider = new JSlider(0, steps);

            label = new JLabel();

            number = new JTextField(cols);

            //Assemble into a panel
            completePanelConstraints_ = new GridBagConstraints();
            completePanelConstraints_.fill = GridBagConstraints.HORIZONTAL;

            completePanelConstraints_.gridx = 0;
            completePanelConstraints_.gridy = 0;
            completePanelConstraints_.weightx=1;
            this.add( slider, completePanelConstraints_ );

            completePanelConstraints_.gridx = 2;
            completePanelConstraints_.gridy = 0;
            completePanelConstraints_.weightx=0;
            this.add(label, completePanelConstraints_ );

            completePanelConstraints_.gridx = 1;
            completePanelConstraints_.gridy = 0;
            completePanelConstraints_.weightx=0;
            //Add some space to the left to move away from slider slightly
            //And some more to the bottom to help with the way they are displayed
            completePanelConstraints_.insets = new Insets(0,5,10,0);
            this.add( number, completePanelConstraints_ );

            this.setBorder(BorderFactory.createTitledBorder(text));

            slider.addChangeListener(new SliderChanged(this));
            number.addActionListener(new TextChanged(this));
            setValue(value);

        }

## Member Function Documentation

FloatSliderWithBox FloatSliderWithBox::setUnits | ( | String | s | ) | `[inline]`

Definition at line 755 of file three_B.java.

References setValue(), units, and value.

Referenced by EControlPanel::EControlPanel().

        {
            units = s;
            setValue(value);
            return this;
        }

FloatSliderWithBox FloatSliderWithBox::setFormat | ( | String | s | ) | `[inline]`

Definition at line 762 of file three_B.java.

References format, setValue(), and value.

Referenced by EControlPanel::EControlPanel().

        {
            format = s;
            setValue(value);
            return this;
        }

void FloatSliderWithBox::addChangeListener | ( | ChangeListener | changeListener | ) | `[inline]`

Definition at line 769 of file three_B.java.

References slider.

Referenced by EControlPanel::EControlPanel().

                                                                    {
            slider.addChangeListener( changeListener );
            return;
        }

void FloatSliderWithBox::setValue | ( | double | v | ) | `[inline, package]`

Definition at line 774 of file three_B.java.

References format, label, max, min, number, reciprocal, slider, steps, units, and value.

Referenced by FloatSliderWithBox::TextChanged::actionPerformed(), FloatSliderWithBox(), setFormat(), setUnits(), and FloatSliderWithBox::SliderChanged::stateChanged().

        {
            value = v;
            if(reciprocal)
                slider.setValue((int)Math.round(steps * (1/value-min)/(max-min)));
            else
                slider.setValue((int)Math.round(steps * (value-min)/(max-min)));

            number.setText(String.format(format, value));
            label.setText(units);
        }

double FloatSliderWithBox::getValue | ( |  | ) | `[inline, package]`

Definition at line 786 of file three_B.java.

References value.

Referenced by EControlPanel::export_reconstruction_as_ij(), and EControlPanel::update_canvas().

        {
            return value;
        }

double FloatSliderWithBox::get_value_from_slider | ( |  | ) | `[inline]`

Definition at line 791 of file three_B.java.

References max, min, reciprocal, slider, and steps.

Referenced by FloatSliderWithBox::SliderChanged::stateChanged().

        {
            if(reciprocal)
                return 1/((slider.getValue() * 1.0 / steps) * (max - min) + min);
            else
                return (slider.getValue() * 1.0 / steps) * (max - min) + min;
        }

double FloatSliderWithBox::get_value_from_text | ( |  | ) | `[inline]`

Definition at line 798 of file three_B.java.

References number.

Referenced by FloatSliderWithBox::TextChanged::actionPerformed().

        {
            return Double.parseDouble(number.getText());
        }

## Member Data Documentation

JSlider FloatSliderWithBox::slider`[private]`

Definition at line 687 of file three_B.java.

Referenced by addChangeListener(), FloatSliderWithBox(), get_value_from_slider(), and setValue().

JTextField FloatSliderWithBox::number`[private]`

Definition at line 688 of file three_B.java.

Referenced by FloatSliderWithBox(), get_value_from_text(), and setValue().

JLabel FloatSliderWithBox::label`[private]`

Definition at line 689 of file three_B.java.

Referenced by FloatSliderWithBox(), and setValue().

GridBagConstraints FloatSliderWithBox::completePanelConstraints_`[private]`

Definition at line 690 of file three_B.java.

Referenced by FloatSliderWithBox().

int FloatSliderWithBox::steps = 1000000`[private]`

Definition at line 692 of file three_B.java.

Referenced by FloatSliderWithBox(), get_value_from_slider(), and setValue().

double FloatSliderWithBox::min`[private]`

Definition at line 693 of file three_B.java.

Referenced by FloatSliderWithBox(), get_value_from_slider(), and setValue().

double FloatSliderWithBox::max`[package]`

Definition at line 693 of file three_B.java.

Referenced by FloatSliderWithBox(), get_value_from_slider(), and setValue().

String FloatSliderWithBox::text`[private]`

Definition at line 694 of file three_B.java.

Referenced by FloatSliderWithBox().

String FloatSliderWithBox::units`[private]`

Definition at line 695 of file three_B.java.

Referenced by setUnits(), and setValue().

String FloatSliderWithBox::format = "%8.3f"`[private]`

Definition at line 696 of file three_B.java.

Referenced by setFormat(), and setValue().

double FloatSliderWithBox::value`[private]`

Definition at line 698 of file three_B.java.

Referenced by FloatSliderWithBox(), getValue(), setFormat(), setUnits(), and setValue().

boolean FloatSliderWithBox::reciprocal`[private]`

Definition at line 699 of file three_B.java.

Referenced by FloatSliderWithBox(), get_value_from_slider(), and setValue().

The documentation for this class was generated from the following file:

- three_B.java