Package com.luciad.gui.swing
Class TLcdRangeSlider
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
com.luciad.gui.swing.TLcdRangeSlider
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,SwingConstants
A component that lets the user graphically select a range by sliding a minimum and maximum knob within
a bounded interval.
The slider can display major tick marks, minor tick marks and labels. The range in between the knobs can be
displayed too.
- See Also:
-
Nested Class Summary
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
Modifier and TypeFieldDescriptionprotected ChangeEvent
Only one ChangeEvent is needed per slider instance since the event's only (read-only) state is the source property.protected double
The number of values the knobs move by when they are moved using the keyboard.protected Dictionary
protected double
The number of values between the major tick marks -- the larger marks that break up the minor tick marks.protected double
The number of values between the minor tick marks -- the smaller marks that occur between the major tick marks.protected int
protected TLcdRangeSliderModel
The data that handles the numeric maximum value, minimum value, and current-position value for the slider.protected boolean
If true, the labels are drawn.protected boolean
If true, the major ticks are drawn.protected boolean
If true, the minor ticks are drawn.protected boolean
If true, the range is drawn.protected boolean
If true, the cursor changes to a move cursor when held over the range between the minimum and maximum knob.protected boolean
If true, the knobs (and the data range they represents) resolve to the closest tick mark next to where the user positioned the knobs.Fields inherited from class javax.swing.JComponent
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
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
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
-
Constructor Summary
ConstructorDescriptionTLcdRangeSlider
(double aMin, double aMax) Constructor, takes only a minimum and maximum, all possible options are set to true, except "snap to ticks".TLcdRangeSlider
(double aMin, double aMax, int aOrientation) Constructor, takes only a minimum maximum and a orientation, all possible options are set to true, except "snap to ticks". -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChangeListener
(ChangeListener aChangeListener) Adds a listener that will be notified of changes of the model.createStandardLabels
(double aIncrement) Creates a hashtable that will draw text labels starting at the slider minimum using the aIncrement specified.createStandardLabels
(double aIncrement, double aStart) Creates a hashtable that will draw text labels starting at the aStart point specified using the aIncrement specified.boolean
Tells is the cursor changes to a move cursor when held over the range between the minimum and maximum knob.double
Returns the number of values the knobs move by when they are moved using the keyboard.double
Gets the amount of data values between major ticks.double
Returns the models range maximum value.double
Returns the models minimum value.double
Gets the range of data values between minor ticks.getModel()
Returns the model that handles the sliders fundamental properties: minimum, maximum, range minimum and range maximum.int
Returns how this slider should be rendered.boolean
Tells if labels are to be painted.boolean
Tells if major tick marks are to be painted.boolean
Tells if minor tick marks are to be painted.boolean
Tells if the range between the minimum and maximum knobs is to be painted.boolean
Tells if either the major or minor (or both) tick marks are to be painted.int
Returns the number of digits after the decimal point to which the data values are rounded.double
Returns the models range maximum value.double
Returns the models range minimum value.boolean
Returns true if the knobs (and the range they represent) resolve to the closest tick mark next to where the user positioned the knobs.boolean
Returns true if one or both of the slider knobs are being dragged.void
removeChangeListener
(ChangeListener aChangeListener) Removes a listener that will be notified of changes of the model.void
reset()
Sets the minimum and maximum knob to the models minimum and maximum.void
setChangeCursorOverRange
(boolean aChangeCursorOverRange) Determines whether the cursor changes to a move cursor when held over the range between the minimum and maximum knob.void
setEnabled
(boolean enabled) void
setKeyStep
(double aKeyStep) Sets the number of values the knobs move by when they are moved using the keyboard.void
setLabelTable
(Dictionary labels) void
setMajorTickSpacing
(double aMajorTickSpacing) Sets the spacing between major ticks.void
setMaximum
(double aMaximum) Sets the models maximum value.void
setMinimum
(double aMinimum) Sets the models minimum value.void
setMinorTickSpacing
(double aMinorTickSpacing) Sets the spacing between minor ticks.void
setModel
(TLcdRangeSliderModel aRangeSliderModel) Sets the model that handles the sliders fundamental properties: minimum, maximum, range minimum and range maximum.void
setOrientation
(int aOrientation) Sets how the slider should be rendered, vertically or horizontally.void
setPaintLabels
(boolean aPaintLabels) Tells if labels are to be painted.void
setPaintMajorTicks
(boolean aPaintMajorTicks) Determines whether major tick marks are painted on the slider.void
setPaintMinorTicks
(boolean aPaintMinorTicks) Determines whether minor tick marks are painted on the slider.void
setPaintTicks
(boolean aPaintTicks) Determines whether tick marks (both major and minor) are painted on the slider.void
setPrecision
(int aPrecision) Determines the number of digits after the decimal point.void
setRange
(double aMin, double aMax) Sets the models range minimum and maximum value.void
setRangeMaximum
(double aRangeMaximum) Sets the models range maximum value.void
setRangeMinimum
(double aRangeMinimum) Sets the models range minimum value.void
setRangeVisble
(boolean aRangeVisible) Determines whether the range is painted on the slidervoid
setSnapToTicks
(boolean aSnapToTicks) Specifying true makes the knobs (and the range they represent) resolve to the closest tick mark next to where the user positioned the knobs.void
setValueIsAdjusting
(boolean aValueIsAdjusting) Sets whether the model should anticipate on subsequent changes.protected void
Resets the UI property to a value from the current look and feel.void
updateUI()
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
fRangeSliderModel
The data that handles the numeric maximum value, minimum value, and current-position value for the slider. -
fChangeEvent
Only one ChangeEvent is needed per slider instance since the event's only (read-only) state is the source property. -
fSlideCursorFlag
protected boolean fSlideCursorFlagIf true, the cursor changes to a move cursor when held over the range between the minimum and maximum knob. -
fShowMajorTicks
protected boolean fShowMajorTicksIf true, the major ticks are drawn. -
fShowMinorTicks
protected boolean fShowMinorTicksIf true, the minor ticks are drawn. -
fShowRange
protected boolean fShowRangeIf true, the range is drawn. -
fShowLabels
protected boolean fShowLabelsIf true, the labels are drawn. -
fMajorTickSpacing
protected double fMajorTickSpacingThe number of values between the major tick marks -- the larger marks that break up the minor tick marks. -
fMinorTickSpacing
protected double fMinorTickSpacingThe number of values between the minor tick marks -- the smaller marks that occur between the major tick marks. -
fSnapToTicks
protected boolean fSnapToTicksIf true, the knobs (and the data range they represents) resolve to the closest tick mark next to where the user positioned the knobs. -
fOrientation
protected int fOrientation -
fKeyStep
protected double fKeyStepThe number of values the knobs move by when they are moved using the keyboard. -
fLabelTable
-
-
Constructor Details
-
TLcdRangeSlider
public TLcdRangeSlider(double aMin, double aMax) Constructor, takes only a minimum and maximum, all possible options are set to true, except "snap to ticks". The default orientation HORIZONTAL is used.- Parameters:
aMin
- Description of ParameteraMax
- Description of Parameter
-
TLcdRangeSlider
public TLcdRangeSlider(double aMin, double aMax, int aOrientation) Constructor, takes only a minimum maximum and a orientation, all possible options are set to true, except "snap to ticks".- Parameters:
aMin
- the sliders minimum.aMax
- the sliders maximum.aOrientation
- Description of Parameter
-
-
Method Details
-
setModel
Sets the model that handles the sliders fundamental properties: minimum, maximum, range minimum and range maximum.- Parameters:
aRangeSliderModel
- contains the properties of the slider: minimum, maximum, range minimum and range maximum.
-
setRangeVisble
public void setRangeVisble(boolean aRangeVisible) Determines whether the range is painted on the slider- Parameters:
aRangeVisible
- true to render the range on the slider.
-
setMajorTickSpacing
public void setMajorTickSpacing(double aMajorTickSpacing) Sets the spacing between major ticks. This spacing is the amount of values between major ticks.- Parameters:
aMajorTickSpacing
- the spacing between major ticks.
-
setMinorTickSpacing
public void setMinorTickSpacing(double aMinorTickSpacing) Sets the spacing between minor ticks. This spacing is the amount of values between minor ticks.- Parameters:
aMinorTickSpacing
- the spacing in data values between minor ticks.- See Also:
-
getModel
Returns the model that handles the sliders fundamental properties: minimum, maximum, range minimum and range maximum.- Returns:
- the model that handles the sliders fundamental properties: minimum, maximum, range minimum and range maximum.
-
getOrientation
public int getOrientation()Returns how this slider should be rendered.- Returns:
- either VERTICAL or HORIZONTAL.
-
setOrientation
public void setOrientation(int aOrientation) Sets how the slider should be rendered, vertically or horizontally.- Parameters:
aOrientation
- sliders orientation, either VERTICAL or HORIZONTAL.
-
getSnapToTicks
public boolean getSnapToTicks()Returns true if the knobs (and the range they represent) resolve to the closest tick mark next to where the user positioned the knobs.- Returns:
- true to let the knobs snap to the closest tick mark.
-
setSnapToTicks
public void setSnapToTicks(boolean aSnapToTicks) Specifying true makes the knobs (and the range they represent) resolve to the closest tick mark next to where the user positioned the knobs.- Parameters:
aSnapToTicks
- true to make knobs (and the range they represent) snap to the closest tick mark.
-
getPaintMajorTicks
public boolean getPaintMajorTicks()Tells if major tick marks are to be painted.- Returns:
- true to have the major tick marks painted, false otherwise.
-
getPaintMinorTicks
public boolean getPaintMinorTicks()Tells if minor tick marks are to be painted.- Returns:
- true to have the minor tick marks painted, false otherwise.
-
getPaintRange
public boolean getPaintRange()Tells if the range between the minimum and maximum knobs is to be painted.- Returns:
- true to have the range between the minimum and maximum nob rendered.
false
otherwise.
-
getPaintTicks
public boolean getPaintTicks()Tells if either the major or minor (or both) tick marks are to be painted.- Returns:
- true when either minor of major ticks will be rendered, false otherwise.
-
setPaintTicks
public void setPaintTicks(boolean aPaintTicks) Determines whether tick marks (both major and minor) are painted on the slider.- Parameters:
aPaintTicks
- true to render all ticks, major and minor, false to render no ticks at all.
-
setPaintMinorTicks
public void setPaintMinorTicks(boolean aPaintMinorTicks) Determines whether minor tick marks are painted on the slider.- Parameters:
aPaintMinorTicks
- true to render minor ticks.
-
setPaintMajorTicks
public void setPaintMajorTicks(boolean aPaintMajorTicks) Determines whether major tick marks are painted on the slider.- Parameters:
aPaintMajorTicks
- true to render major ticks.
-
setPaintLabels
public void setPaintLabels(boolean aPaintLabels) Tells if labels are to be painted. Note that the label table should also be set.- Parameters:
aPaintLabels
- true if the labels should be painted, false otherwise.- See Also:
-
getPaintLabels
public boolean getPaintLabels()Tells if labels are to be painted.- Returns:
- true if the labels should be rendered.
-
setEnabled
public void setEnabled(boolean enabled) - Overrides:
setEnabled
in classJComponent
-
getChangeCursorOverRange
public boolean getChangeCursorOverRange()Tells is the cursor changes to a move cursor when held over the range between the minimum and maximum knob.- Returns:
- true to have the cursor change over the range, false otherwise.
-
setChangeCursorOverRange
public void setChangeCursorOverRange(boolean aChangeCursorOverRange) Determines whether the cursor changes to a move cursor when held over the range between the minimum and maximum knob.- Parameters:
aChangeCursorOverRange
- true to make the cursor change when held over the range between the minimum and maximum knob.
-
getMinorTickSpacing
public double getMinorTickSpacing()Gets the range of data values between minor ticks.- Returns:
- the range of data values between minor ticks.
-
getMajorTickSpacing
public double getMajorTickSpacing()Gets the amount of data values between major ticks.- Returns:
- the range of data values between minor ticks.
-
getPrecision
public int getPrecision()Returns the number of digits after the decimal point to which the data values are rounded.- Returns:
- the number of digits after the decimal point to which the data values are rounded.
-
setPrecision
public void setPrecision(int aPrecision) Determines the number of digits after the decimal point. Data values are rounded to this precision.- Parameters:
aPrecision
- the number of digits after the decimal point that are to be kept.
-
getValueIsAdjusting
public boolean getValueIsAdjusting()Returns true if one or both of the slider knobs are being dragged.- Returns:
- the value of the models valueIsAdjusting property
-
setValueIsAdjusting
public void setValueIsAdjusting(boolean aValueIsAdjusting) Sets whether the model should anticipate on subsequent changes.- Parameters:
aValueIsAdjusting
- true if the model will change frequently subsequently.false
otherwise.
-
reset
public void reset()Sets the minimum and maximum knob to the models minimum and maximum. -
setRangeMinimum
public void setRangeMinimum(double aRangeMinimum) Sets the models range minimum value.- Parameters:
aRangeMinimum
- the minimum of the range this slider should cover.
-
setRangeMaximum
public void setRangeMaximum(double aRangeMaximum) Sets the models range maximum value.- Parameters:
aRangeMaximum
- the maximum of the range this slider should cover.
-
setMinimum
public void setMinimum(double aMinimum) Sets the models minimum value.- Parameters:
aMinimum
- the minimum the range slider can cover.
-
setMaximum
public void setMaximum(double aMaximum) Sets the models maximum value.- Parameters:
aMaximum
- the maximum the range slider can cover.
-
setRange
public void setRange(double aMin, double aMax) Sets the models range minimum and maximum value.- Parameters:
aMin
- the new minimum of the range.aMax
- the new maximum of the range.
-
getRangeMinimum
public double getRangeMinimum()Returns the models range minimum value.- Returns:
- the minimum value of the current range.
-
getRangeMaximum
public double getRangeMaximum()Returns the models range maximum value.- Returns:
- the maximum value of the current range.
-
getMinimum
public double getMinimum()Returns the models minimum value.- Returns:
- the minimum value the range slider can take into account.
-
getMaximum
public double getMaximum()Returns the models range maximum value.- Returns:
- the maximum value the range slider can take into account.
-
addChangeListener
Adds a listener that will be notified of changes of the model.- Parameters:
aChangeListener
- a listener that should be notified of changes in the model.
-
removeChangeListener
Removes a listener that will be notified of changes of the model.- Parameters:
aChangeListener
- a listener that should no longer be notified of changes in the model.
-
getKeyStep
public double getKeyStep()Returns the number of values the knobs move by when they are moved using the keyboard.- Returns:
- the number of values the knobs move by when they are moved using the keyboard.
-
setKeyStep
public void setKeyStep(double aKeyStep) Sets the number of values the knobs move by when they are moved using the keyboard.- Parameters:
aKeyStep
- the number of values the knobs move by when they are moved using the keyboard.
-
getLabelTable
-
setLabelTable
-
updateLabelUIs
protected void updateLabelUIs()Resets the UI property to a value from the current look and feel.- See Also:
-
updateUI
public void updateUI()- Overrides:
updateUI
in classJComponent
-
getUIClassID
- Overrides:
getUIClassID
in classJComponent
-
createStandardLabels
Creates a hashtable that will draw text labels starting at the slider minimum using the aIncrement specified. If you callcreateStandardLabels( 10 )
and the slider minimum is zero, then it will make labels for the values 0, 10, 20, 30, and so on.- Parameters:
aIncrement
- the step in data space between 2 values for which a label is created.- Returns:
- a hashtable that can be used as label table for this range slider, with the first label assigned to the minimum of the slider and all subsequent labels at a distance apart equal to the increment.
- See Also:
-
createStandardLabels
Creates a hashtable that will draw text labels starting at the aStart point specified using the aIncrement specified. If you callcreateStandardLabels( 10, 2 )
, then it will make labels for the values 2, 12, 22, 32, and so on.- Parameters:
aIncrement
- the step in data space between 2 values for which a label is created.aStart
- the data value for which the first label should be created.- Returns:
- a hashtable that can be used as label table for this range slider, with the first label assigned to the aStart value passed and all subsequent labels at a distance apart equal to the aIncrement.
- Throws:
IllegalArgumentException
- if slider label aStart point out of range or if label aIncrement is less than or equal to zero- See Also:
-