|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JSlider
jview.JTunableSlider
public class JTunableSlider
A slider that can change the extend of its accessible values by keeping the central value fixed and either increasing or decreasing the range. This is useful, if one wants to penetrate deeper and deeper into a parameter.
You consturct such a slider with a central value and a initial half-span
(mandatory). Each refinement changes the span (and possibly the central
value) by an specifiable amount, defaulting to DEFREFINEMENT.
Different to the standard slider, you specify the number of ticks and the
number of labels you want to see on the slider. Internally, this numbers are
used to define the (integer) range of the underlying slider. Calling the
set...TickSpacing methods still work, but might produce interesting results.
Two buttons for increaseing/decreasing the accessible slider range are
available, but displaying them must be done externally. If the user clicks on
either button, or calls shrink or expand, the range of the
slider changes.
| Nested Class Summary | |
|---|---|
static class |
JTunableSlider.Show
Test class, shows an adjustable slider and prints out the values. |
| Nested classes/interfaces inherited from class javax.swing.JSlider |
|---|
JSlider.AccessibleJSlider |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
private double |
central
The current central value. |
private static int |
DEFLABELCOUNT
Default number of labels. |
private static double |
DEFREFINEMENT
Default change in range on shrink/expand. |
private static int |
DEFTICKCOUNT
Default number of ticks. |
private JButton |
expand
The expand button. |
private PropertySupplying |
info
My properties. |
static String |
KEY_LABELCOUNT
The number of labels to display per half-intervall. |
static String |
KEY_REFINEMENT
The change in the sliders range by a call to shrink. |
static String |
KEY_TICKCOUNT
The number of ticks to display per half-intervall. |
private double |
range
The current slider half-range. |
private JButton |
shrink
The shrink button. |
| Fields inherited from class javax.swing.JSlider |
|---|
changeEvent, changeListener, majorTickSpacing, minorTickSpacing, orientation, sliderModel, snapToTicks |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.SwingConstants |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
JTunableSlider(double mid,
double span)
Constructs a new tunable slider, all values defaulting. |
|
JTunableSlider(double mid,
double span,
Map<String,String> p)
Constructs a new tunable slider, all non-default values specified in the provided lookup table. |
|
JTunableSlider(double mid,
double span,
PropertySupplying info)
Constructs a new tunable slider, all non-default values specified in the provided lookup table. |
|
| Method Summary | |
|---|---|
private void |
adjustLabels()
Adjust the labels displayed to the true values covered in the slider. |
private double |
convertSliderPosition(int slider)
Converts an integer position on the slider to the correct double value. |
private void |
createButtons(int orientation)
We create the shrink and expand button, depending on the slider orientation. |
private void |
createSlider()
Creates the (super) slider out of the properties specified earlier. |
void |
expand(double nucen)
Expands the tunable range, but enlarges the accuracy of the slider positioning. |
JComponent |
getBox()
Convenience method: get the slider and the shrink and expand buttons in a properly laid-out box. |
double |
getCentralValue()
Returns the central value. |
PropertySupplying |
getComposedProperties()
Returns my properties. |
double |
getDoubleValue()
We cannot overload getValue, because this returns an int. |
void |
setCentralValue(double nucen)
Sets the central value keeps the range. |
void |
setCentralValue(double nucen,
double nuran)
Sets the central value plus the range. |
void |
setComposedProperties(PropertySupplying prop)
Sets the composed properties. |
void |
setDoubleValue(double knob)
The setter method, adjust the knob. |
void |
setDoubleValue(double knob,
boolean suppress)
The setter method, adjust the knob. |
void |
setOrientation(int orientation)
We set the orientation and change the layout of our buttons. |
void |
setRange(double nuran)
|
void |
shrink(double nucen)
On setting the orientation, we also /** Shrinks the tunable range, but enlarges the accuracy of the slider positioning. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String KEY_REFINEMENT
shrink.
public static final String KEY_TICKCOUNT
public static final String KEY_LABELCOUNT
private static final double DEFREFINEMENT
private static final int DEFTICKCOUNT
private static final int DEFLABELCOUNT
private PropertySupplying info
private double central
private double range
private JButton shrink
private JButton expand
| Constructor Detail |
|---|
public JTunableSlider(double mid,
double span)
public JTunableSlider(double mid,
double span,
Map<String,String> p)
public JTunableSlider(double mid,
double span,
PropertySupplying info)
| Method Detail |
|---|
public void setOrientation(int orientation)
setOrientation in class JSliderpublic void setComposedProperties(PropertySupplying prop)
setComposedProperties in interface PropertyAwarepublic PropertySupplying getComposedProperties()
getComposedProperties in interface PropertyComposedpublic void shrink(double nucen)
public void expand(double nucen)
public double getCentralValue()
public void setRange(double nuran)
public void setCentralValue(double nucen)
public void setCentralValue(double nucen,
double nuran)
public double getDoubleValue()
public void setDoubleValue(double knob)
public void setDoubleValue(double knob,
boolean suppress)
public JComponent getBox()
private double convertSliderPosition(int slider)
private void createSlider()
private void createButtons(int orientation)
private void adjustLabels()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||