DESY ACOP Beans Home

com.cosylab.gui.components
Class Slider

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.cosylab.gui.components.Slider
All Implemented Interfaces:
StateOriginator, TickParameters, PopupManageable, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
SliderDisplayer

public class Slider
extends javax.swing.JPanel
implements TickParameters, PopupManageable, StateOriginator

Slider is a GUI component for displaying double value. Slider defines limits within which the value may be set and fire update events when this value is changed. For precise control, textual entry and button controls are also available.

When displaying values slider can show two different values. The front thumb displays the value that was set by the user. According to the set mode currently set on the Slider (setSetMode(SliderSetMode)) slider then notifies listeners of the value change. The second value is displayed by a grey shadow. This value can be controlled by the setReadback(double) method and can only be changed manually (through this method call).

Version:
$id$
Author:
Ales Pucelj
See Also:
Serialized Form

Nested Class Summary
static class Slider.Button
          Button identifiers for any of the buttons used in the Slider.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int SET_MANUAL
          Deprecated. use SliderSetMode.SET_MANUAL instead.
static int SET_ON_CHANGE
          Deprecated. use SliderSetMode.SET_ON_CHANGE instead.
static int SET_ON_RELEASE
          Deprecated. use SliderSetMode.SET_ON_RELEASE instead.
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Slider()
          Creates a new Slider object.
 
Method Summary
 void addSetListener(SetListener listener)
          Adds set listener.
 void decrementBit()
          Decrements value for a single bit.
 void decrementLarge()
          Decrements value for the large step.
 void decrementSmall()
          Decrements value for the small step.
protected  void fireSetPerformed(double newValue)
          Fires event that value has changed.
 java.lang.String formatNumber(double value)
          Formats the input value to a specific print format.
 long getAutoSynchronizeDelay()
          Returns the time in milliseconds that specify the delay of the autoSynchronization.
 double getBitStep()
          Returns the value of bit step.
 javax.swing.Icon getButtonIcon(Slider.Button b)
          Returns the Icon of a desired button.
 java.lang.String getButtonText(Slider.Button b)
          Returns the text of a desired button.
 java.lang.String getButtonTooltip(Slider.Button b)
          Returns the tooltip of a desired button.
 int getContinuousModeDelayTime()
          Returns the initial delay time after button press to first auto increment/decrement
 int getContinuousModeRepeatTime()
          Returns the continuousModeEnabled
 AbstractCustomizerPanel getCustomizer()
          Returns the Customizer instance for this component.
 java.lang.String getFieldFormat()
          Returns format of the editable field.
 java.lang.String getFormat()
          Deprecated. use getTicksFormat() and getFieldFormat()
protected  InfoBar getInfoBar()
           
 double getLargeStep()
          Returns the value of largeStep.
 double[] getMajorTickLabels()
          Returns the values which have labeles painted next to the tick.
 double[] getMajorTicks()
          Returns the values which are painted together with majot ticks.
 double getMaximum()
          Returns currently set maxium value.
 double getMinimum()
          Returns currently set minimum value.
 double getMinorTicksStep()
          Returns the distance between two minor ticks in same units as value.
 int getMode()
          Deprecated. use getSetMode()
protected  NavigationBar getNavigationBar()
           
 PopupManager getPopupManager()
          Returns popup manager, which manages popup menu.
 double getReadback()
          Returns current readback position.
 java.lang.String getRestoreButtonTitle()
          Returns the title of the restore button.
 SliderSetMode getSetMode()
          Returns the set mode.
protected  javax.swing.JSlider getSlider()
           
protected  CosySliderUI getSliderUI()
          Create this slider UI.
 double getSmallStep()
          Returns the value of the small step.
 State getState()
          Will be called by the StateKeeper in the process of the application state saving.
 double getStoredValue()
          Returns the stored value.
 java.lang.String getTicksFormat()
          Returns the formatter used for the slider ticks on the scale.
 java.lang.String getTitle()
          Returns the title of the Slider.
 java.awt.Font getTitleFont()
          Returns the font used to display the title.
 boolean getTitleVisible()
          Returns true if title is visible.
 java.lang.String getToolTipText()
           
 java.lang.String getUnits()
          Returns string representing units that are displayed next to value entry field.
 java.awt.Font getUnitsFont()
          Returns the font used to display units.
 double getValue()
          Returns current value the slider is displaying.
 double getValuePrecision()
          Returns the tolerance for current value set via slider.
 void incrementBit()
          Increments value for a single bit.
 void incrementLarge()
          Peforms a large value increment.
 void incrementSmall()
          Performs a small value increment.
 boolean isAutoSynchronize()
          Returns the state of autoSynchronization feature (enabled / disabled).
 boolean isBitStepRelative()
          Returns true if bitStep is relative, else false.
 boolean isButtonVisible(Slider.Button b)
          Returns the visibility of a button.
 boolean isContinuousControlVisible()
          Returns true if contunyous mode checkbox is visible.
 boolean isContinuousModeEnabled()
          Returns continuousModeEnabled
 boolean isDragEnabled()
          Returns true if drag is enabled.
 boolean isDropEnabled()
          Returns true if drop is enabled.
 boolean isEditable()
          Returns whether this slider is settable.
 boolean isLargeStepRelative()
          Returns true if largeStep is relative, else false.
 boolean isPopupEnabled()
          Returns whether the user can trigger the component's popup menu through mouse click.
 boolean isSmallStepRelative()
          Returns true if smallStep is relative, else false.
 boolean isSnapToTicks()
          Returns true if snap to ticks is turned on.
 boolean isStorageButtonsVisible()
          Returns the visibility flag of the store and restore buttons.
 boolean isStoredValueLabelVisible()
          Returns true if the stored value label is set to be visible.
 boolean isSuspended()
          Returns true if slider is suspended
 boolean isSyncButtonVisible()
          Returns the visibility flag of the sync button.
 boolean isUnitsVisible()
          Returns true if units are displayed next to value entry field.
static void main(java.lang.String[] args)
          Run test applet.
 int measureTick(double position, java.lang.String text)
          Returns size of tick label in pixels.
 void removeSetListener(SetListener listener)
          Removes set listener.
 void resetSteps()
          Resets sliders steps to default values
 void restoreValue()
          Restores the stored value.
 void resume()
          Resumes suspended slider.
 void setAutoSynchronize(boolean autoSynchronize)
          Turns the autoSynchronization on/off.
 void setAutoSynchronizeDelay(long autoSynchronizeDelay)
          Sets the autoSynchronization in miliseconds.
 void setBackground(java.awt.Color bg)
           
 void setBitStep(double value)
          Sets the value of a bit step.
 void setBitStepRelative(boolean value)
          Sets bitStep to be relative if true (example: bitStep=20 means that bitStep will change for 20% of sliders current range(min,max)).
 void setButtonIcon(Slider.Button b, javax.swing.Icon icon)
          Sets a Icon to a desired button.
 void setButtonText(Slider.Button b, java.lang.String text)
          Sets a text to a desired button.
 void setButtonTooltip(Slider.Button b, java.lang.String tooltip)
          Sets a tooltip to a desired button.
 void setButtonVisible(Slider.Button b, boolean visible)
          Toggles the visibility of the specified button.
 void setContinuousControlVisible(boolean continuousControlVisible)
          Sets visibility of control ofr continuous mode.
 void setContinuousModeDelayTime(int continuousModeDelayTime)
          Sets the initial delay time in milliseconds betwean button pressed and hold for increment/decrement and continuous mode is fired.
 void setContinuousModeEnabled(boolean continuousModeEnabled)
          Sets the continuousModeEnabled and updates combobox on InfoBar to appropriate index
 void setContinuousModeRepeatTime(int continuousModeRepeatTime)
          Sets the continuousModeRepeatTime time in milliseconds between individual repetitions of contunuous increment/decrement.
 void setDragEnabled(boolean enabled)
          Enables/disables mouse dragging.
 void setDropEnabled(boolean enabled)
          Enable/disable the mouse drop.
 void setEditable(boolean settable)
          Sets whether this slider is settable.
 void setEnabled(boolean enabled)
           
 void setFieldFormat(java.lang.String s)
          Sets format for editable field.
 void setForeground(java.awt.Color fg)
           
 void setFormat(java.lang.String s)
          Deprecated. use setTicksFormat(String) and setFieldFormat(String)
 void setLargeStep(double value)
          Sets the value of large step
 void setLargeStepRelative(boolean value)
          Sets largeStep to be relative if true (example: largeStep=20 means that largeStep will change for 20% of sliders current range(min,max)).
 void setMajorTickLabels(double[] labelledTicks)
          Explicitely sets which major ticks will have value labels painted.
 void setMajorTicks(double[] ticks)
          Explicitely sets which values on the slider scale should be painted with major ticks.
 void setManual()
          If in SliderSetMode.SET_MANUAL method will notify listeners that set was performed.
 void setMaximum(double maximum)
          Sets new maximum value.
 void setMinimum(double minimum)
          Sets new minimum value.
 void setMinorTicksStep(double step)
          Sets the distance between two minor ticks in same units as value.
 void setMode(int newMode)
          Deprecated. use Slider#setSetMode(com.cosylab.gui.components.Slider.SetMode)
 void setPopupEnabled(boolean b)
          Enables or disables the popup capabilities of the component.
 void setReadback(double value)
          Sets the readback indicator position.
 void setRestoreButtonTitle(java.lang.String title)
          Sets the title of the restore button.
 void setSetMode(SliderSetMode mode)
          Sets the slider set mode.
 void setSmallStep(double value)
          Sets the small step.
 void setSmallStepRelative(boolean value)
          Sets smallStep to be relative if true (example: smallStep=20 means that smallStep will change for 20% of sliders current range(min,max)).
 void setSnapToTicks(boolean snapToTicks)
          Sets the snap to ticks property.
 void setState(State state)
          Will be called by the StateKeepr when it reads State object which belongs to this component.
 void setStorageButtonsVisible(boolean visible)
          Sets the store and restore buttons visibile/invisible.
 void setStoredValue(double storedValue)
          Stores new value.
 void setStoredValueLabelVisible(boolean visible)
          Sets the stored value label to be visible.
 void setSyncButtonVisible(boolean visible)
          Sets the sync button visibile/invisible.
 void setTicksFormat(java.lang.String ticksFormat)
          Sets the string format for the ticks of this slider.
 void setTitle(java.lang.String title)
          Sets the title of the slider.
 void setTitleFont(java.awt.Font font)
          Sets the font used to display the title of the slider.
 void setTitleVisible(boolean titleVisible)
          Sets the visibility of the title.
 void setToolTipText(java.lang.String tooltip)
           
 void setUnits(java.lang.String units)
          Sets string representing units displayed next to value entry field.
 void setUnitsFont(java.awt.Font font)
          Sets the font used to display the units.
 void setUnitsVisible(boolean b)
          Sets whether units are displayed next to value entry field.
 void setValue(double value)
          Sets the new value that this slider will display.
 void setValuePrecision(double precision)
          Sets the tolerance at which the thumb is considered to be synchronized with the trailer.
 void storeValue()
          Stores the current setpoint value.
 void suspend()
          Suspends displayer, minimal GUI action is taken, no data value events fired and slider is disabled.
 void synchronize()
          Synchronized front thumb value with the shadow.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, 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, transferFocusBackward, 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, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SET_MANUAL

@Deprecated
public static final int SET_MANUAL
Deprecated. use SliderSetMode.SET_MANUAL instead.
Set only when demanded

See Also:
Constant Field Values

SET_ON_RELEASE

@Deprecated
public static final int SET_ON_RELEASE
Deprecated. use SliderSetMode.SET_ON_RELEASE instead.
Set when dragging stops

See Also:
Constant Field Values

SET_ON_CHANGE

@Deprecated
public static final int SET_ON_CHANGE
Deprecated. use SliderSetMode.SET_ON_CHANGE instead.
Set when value changes

See Also:
Constant Field Values
Constructor Detail

Slider

public Slider()
Creates a new Slider object.

Method Detail

resetSteps

public void resetSteps()
Resets sliders steps to default values


addSetListener

public void addSetListener(SetListener listener)
Adds set listener. SetListener receives events when the thumb was dragged by the mouse.

Parameters:
listener - SetListener

removeSetListener

public void removeSetListener(SetListener listener)
Removes set listener.

Parameters:
listener - SetListener

fireSetPerformed

protected void fireSetPerformed(double newValue)
Fires event that value has changed.

Parameters:
newValue - double

getInfoBar

protected InfoBar getInfoBar()

getNavigationBar

protected NavigationBar getNavigationBar()

getSlider

protected javax.swing.JSlider getSlider()

getSliderUI

protected CosySliderUI getSliderUI()
Create this slider UI.

Returns:
the ui

setMinimum

public void setMinimum(double minimum)
Sets new minimum value.

Parameters:
minimum - new minimum value.

setMaximum

public void setMaximum(double maximum)
Sets new maximum value.

Parameters:
maximum - new maximum value.

setValue

public void setValue(double value)
Sets the new value that this slider will display. This method will set the front thumb value.

Parameters:
value - new value.

getMinimum

public double getMinimum()
Returns currently set minimum value.

Returns:
double minimum value.

getMaximum

public double getMaximum()
Returns currently set maxium value.

Returns:
double maximum value.

getValue

public double getValue()
Returns current value the slider is displaying.

Returns:
double Current value.

setUnits

public void setUnits(java.lang.String units)
Sets string representing units displayed next to value entry field.

Parameters:
units - new value for units, may be null.

getUnits

public java.lang.String getUnits()
Returns string representing units that are displayed next to value entry field.

Returns:
String units string.

setUnitsVisible

public void setUnitsVisible(boolean b)
Sets whether units are displayed next to value entry field.

Parameters:
b - wehter units are displayed.

isUnitsVisible

public boolean isUnitsVisible()
Returns true if units are displayed next to value entry field.

Returns:
boolean unitsVisible.

setReadback

public void setReadback(double value)
Sets the readback indicator position. This determines the position of trailer shadow that is displayed to indicate last readback.
This method has no effect if slider is not settable.

Parameters:
value - double new readback position.

getReadback

public double getReadback()
Returns current readback position. This is the position of the trailer shadow thad indicates last readback.
If slider is not settable the method will return the value of the front thumb.

Returns:
double the readback value

setFormat

@Deprecated
public void setFormat(java.lang.String s)
Deprecated. use setTicksFormat(String) and setFieldFormat(String)

Sets format for navigator and ticks.

Parameters:
s - new C-Style format.

getFormat

@Deprecated
public java.lang.String getFormat()
Deprecated. use getTicksFormat() and getFieldFormat()

Returns the format used for number labels on the slider. This method in fact returns the format of the number field.

Returns:
the C-style format

setFieldFormat

public void setFieldFormat(java.lang.String s)
Sets format for editable field.

Parameters:
s - new C-Style format.

getFieldFormat

public java.lang.String getFieldFormat()
Returns format of the editable field.

Returns:
C-Style format.

setTicksFormat

public void setTicksFormat(java.lang.String ticksFormat)
Sets the string format for the ticks of this slider. This format will affect only the strings in the slider scale but not the ticks in the naviagtion bar.

Parameters:
ticksFormat - the ticks format

getTicksFormat

public java.lang.String getTicksFormat()
Returns the formatter used for the slider ticks on the scale.

Returns:
the ticks format

getTitle

public java.lang.String getTitle()
Returns the title of the Slider.

Returns:
title.

setTitle

public void setTitle(java.lang.String title)
Sets the title of the slider.

Parameters:
title - new title

setTitleVisible

public void setTitleVisible(boolean titleVisible)
Sets the visibility of the title.

Parameters:
titleVisible - true if title should be visible

getTitleVisible

public boolean getTitleVisible()
Returns true if title is visible.

Returns:
true if title is visible

incrementSmall

public void incrementSmall()
Performs a small value increment.

See Also:
setSmallStep(double)

incrementLarge

public void incrementLarge()
Peforms a large value increment.

See Also:
setLargeStep(double)

incrementBit

public void incrementBit()
Increments value for a single bit.

See Also:
setBitStep(double)

decrementBit

public void decrementBit()
Decrements value for a single bit.

See Also:
setBitStep(double)

decrementSmall

public void decrementSmall()
Decrements value for the small step.

See Also:
setSmallStep(double)

decrementLarge

public void decrementLarge()
Decrements value for the large step.

See Also:
setLargeStep(double)

setBitStep

public void setBitStep(double value)
Sets the value of a bit step.

Parameters:
value - new bit step

getBitStep

public double getBitStep()
Returns the value of bit step.

Returns:
bitStep the bit step

getSmallStep

public double getSmallStep()
Returns the value of the small step.

Returns:
current small step.

setSmallStep

public void setSmallStep(double value)
Sets the small step.

Parameters:
value - new small step

setLargeStep

public void setLargeStep(double value)
Sets the value of large step

Parameters:
value - new large step

getLargeStep

public double getLargeStep()
Returns the value of largeStep.

Returns:
current large step

isBitStepRelative

public boolean isBitStepRelative()
Returns true if bitStep is relative, else false.

Returns:

setBitStepRelative

public void setBitStepRelative(boolean value)
Sets bitStep to be relative if true (example: bitStep=20 means that bitStep will change for 20% of sliders current range(min,max)).

Parameters:
value - true is realtive

isSmallStepRelative

public boolean isSmallStepRelative()
Returns true if smallStep is relative, else false.

Returns:

setSmallStepRelative

public void setSmallStepRelative(boolean value)
Sets smallStep to be relative if true (example: smallStep=20 means that smallStep will change for 20% of sliders current range(min,max)).

Parameters:
value - true if relative

isLargeStepRelative

public boolean isLargeStepRelative()
Returns true if largeStep is relative, else false.

Returns:

setLargeStepRelative

public void setLargeStepRelative(boolean value)
Sets largeStep to be relative if true (example: largeStep=20 means that largeStep will change for 20% of sliders current range(min,max)).

Parameters:
value - true if relative

getMode

@Deprecated
public int getMode()
Deprecated. use getSetMode()

Return set mode.

Returns:
int

setMode

@Deprecated
public void setMode(int newMode)
Deprecated. use Slider#setSetMode(com.cosylab.gui.components.Slider.SetMode)

Sets the set mode.

Parameters:
newMode - int

setSetMode

public void setSetMode(SliderSetMode mode)
Sets the slider set mode.

Parameters:
mode -
See Also:
SliderSetMode

getSetMode

public SliderSetMode getSetMode()
Returns the set mode.

Returns:

measureTick

public int measureTick(double position,
                       java.lang.String text)
Description copied from interface: TickParameters
Returns size of tick label in pixels. Size is determined as distance between maximum extent of the label along the tick axis.

Specified by:
measureTick in interface TickParameters
Parameters:
position - relative position of the tick on 0..1.
text - label to display, may be empty string or null.
Returns:
size of tick in pixels.

setEditable

public void setEditable(boolean settable)
Sets whether this slider is settable. If editable, user can change values, otherwise UI is disabled.

Parameters:
settable - true/false

isEditable

public boolean isEditable()
Returns whether this slider is settable.

Returns:
true/false

getPopupManager

public PopupManager getPopupManager()
Description copied from interface: PopupManageable
Returns popup manager, which manages popup menu.

Specified by:
getPopupManager in interface PopupManageable
Returns:
returns popup manager, which manages popup menu

getCustomizer

public AbstractCustomizerPanel getCustomizer()
Returns the Customizer instance for this component.

Returns:
the Customizer instance for this component.

synchronize

public void synchronize()
Synchronized front thumb value with the shadow. Value is synchronized to the readback.


setManual

public void setManual()
If in SliderSetMode.SET_MANUAL method will notify listeners that set was performed. If in any other setMode, the call will have no effect.


getState

public State getState()
Description copied from interface: StateOriginator
Will be called by the StateKeeper in the process of the application state saving. The component which implements this interface will tipycally use StateFactory to create a State object and fill it with needed values. For example a component can use this snippet.
 
 public State getState() {
        State s = StateFactory.createState();
        s.putDouble("Min", getMinimum());
        s.putDouble("Max", getMaximum());
        s.putString("Format", getFormat());
        s.putString("Units", getUnits());
        return s;
 }
 
 

Specified by:
getState in interface StateOriginator
Returns:
state object

setState

public void setState(State state)
Description copied from interface: StateOriginator
Will be called by the StateKeepr when it reads State object which belongs to this component.

Specified by:
setState in interface StateOriginator
Parameters:
state - object previously created by this component

isPopupEnabled

public boolean isPopupEnabled()
Returns whether the user can trigger the component's popup menu through mouse click.

Returns:
true if popup is enabled

setPopupEnabled

public void setPopupEnabled(boolean b)
Enables or disables the popup capabilities of the component.

Parameters:
b - the component should bring up popup dialog on mouse click.

getToolTipText

public java.lang.String getToolTipText()
Overrides:
getToolTipText in class javax.swing.JComponent

suspend

public void suspend()
Suspends displayer, minimal GUI action is taken, no data value events fired and slider is disabled. Call resume() as many times as suspend was called.


resume

public void resume()
Resumes suspended slider. Call resume() as many times as suspend was called.

See Also:
suspend();

isSuspended

public boolean isSuspended()
Returns true if slider is suspended

Returns:
true if suspended
See Also:
suspend()

setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class javax.swing.JComponent

isAutoSynchronize

public boolean isAutoSynchronize()
Returns the state of autoSynchronization feature (enabled / disabled).

Returns:

setAutoSynchronize

public void setAutoSynchronize(boolean autoSynchronize)
Turns the autoSynchronization on/off. If autosynchronization is on slider will automatically synchronize the value with readback after the specified delay if no activity was present during that time.

Parameters:
autoSynchronize -
See Also:
setAutoSynchronizeDelay(long)

getAutoSynchronizeDelay

public long getAutoSynchronizeDelay()
Returns the time in milliseconds that specify the delay of the autoSynchronization.

Returns:

setAutoSynchronizeDelay

public void setAutoSynchronizeDelay(long autoSynchronizeDelay)
Sets the autoSynchronization in miliseconds.

Parameters:
autoSynchronizeDelay -

setDragEnabled

public void setDragEnabled(boolean enabled)
Enables/disables mouse dragging. Dragging can only be enabled if this component uses CosyTransferHandler.

Parameters:
enabled -

isDragEnabled

public boolean isDragEnabled()
Returns true if drag is enabled.

Returns:

setDropEnabled

public void setDropEnabled(boolean enabled)
Enable/disable the mouse drop. Drop can only be enabled if this component uses CosyTransferHandler.

Parameters:
enabled -

isDropEnabled

public boolean isDropEnabled()
Returns true if drop is enabled.

Returns:

setBackground

public void setBackground(java.awt.Color bg)
Overrides:
setBackground in class javax.swing.JComponent

setForeground

public void setForeground(java.awt.Color fg)
Overrides:
setForeground in class javax.swing.JComponent

formatNumber

public java.lang.String formatNumber(double value)
Description copied from interface: TickParameters
Formats the input value to a specific print format. If return value is null use internal format specified by the caller of this method.

Specified by:
formatNumber in interface TickParameters
Parameters:
value - double to be formatted
Returns:
formatted value

setButtonText

public void setButtonText(Slider.Button b,
                          java.lang.String text)
Sets a text to a desired button. Text can only be set for navigation buttons and not for 'SYNC', 'STORE' and 'RESTORE'.

Parameters:
b - Button to which a text we want to set.
text - String containing a text for a Button.

setButtonIcon

public void setButtonIcon(Slider.Button b,
                          javax.swing.Icon icon)
Sets a Icon to a desired button. Icon can only be set for navigation buttons and not for 'SYNC', 'STORE' and 'RESTORE'.

Parameters:
b - Button to which a text we want to set.
icon - Icon containing a text for a Button.

getButtonText

public java.lang.String getButtonText(Slider.Button b)
Returns the text of a desired button.

Parameters:
b - Button of which a text we want to get.
Returns:
String containing the text for a Button if the text is set.

getButtonIcon

public javax.swing.Icon getButtonIcon(Slider.Button b)
Returns the Icon of a desired button.

Parameters:
b - Button of which an Icon we want to get.
Returns:
String containing the Icon for a Button if the Icon is set.

setButtonTooltip

public void setButtonTooltip(Slider.Button b,
                             java.lang.String tooltip)
Sets a tooltip to a desired button. Tooltips can only be set for navigation buttons and not for 'SYNC', 'STORE' and 'RESTORE'.

Parameters:
b - Button to which a tooltip we want to set.
tooltip - String containing a tooltip for a Button.

getButtonTooltip

public java.lang.String getButtonTooltip(Slider.Button b)
Returns the tooltip of a desired button.

Parameters:
b - Button of which a tooltip we want to get.
Returns:
String containing a tooltip for a Button if a tooltip is set.

setButtonVisible

public void setButtonVisible(Slider.Button b,
                             boolean visible)
Toggles the visibility of the specified button.

Parameters:
b - button to be set visible/invisible
visible - true if button should be visible

isButtonVisible

public boolean isButtonVisible(Slider.Button b)
Returns the visibility of a button.

Parameters:
b - button
Returns:
true if button b is visible

setStorageButtonsVisible

public void setStorageButtonsVisible(boolean visible)
Sets the store and restore buttons visibile/invisible.

Parameters:
visible - visiblity of storage buttons

isStoredValueLabelVisible

public boolean isStoredValueLabelVisible()
Returns true if the stored value label is set to be visible. Label can be actually shown only when storage buttons are visible.

Parameters:
visible - visiblity of stored value label
See Also:
isStorageButtonsVisible()

setStoredValueLabelVisible

public void setStoredValueLabelVisible(boolean visible)
Sets the stored value label to be visible. Label can be only wisible, when storage buttons are visible.

Parameters:
visible - visiblity of storage buttons
See Also:
setStorageButtonsVisible(boolean)

isStorageButtonsVisible

public boolean isStorageButtonsVisible()
Returns the visibility flag of the store and restore buttons.

Returns:
true if buttons are visible

setSyncButtonVisible

public void setSyncButtonVisible(boolean visible)
Sets the sync button visibile/invisible.

Parameters:
visible - visiblity of storage buttons

isSyncButtonVisible

public boolean isSyncButtonVisible()
Returns the visibility flag of the sync button.

Returns:
true if button is visible

setValuePrecision

public void setValuePrecision(double precision)
Sets the tolerance at which the thumb is considered to be synchronized with the trailer.

Parameters:
precision -
See Also:
CosySliderUI.setTolerance(double)

getValuePrecision

public double getValuePrecision()
Returns the tolerance for current value set via slider.

Returns:
precision Double precision value
See Also:
CosySliderUI.getTolerance()

setTitleFont

public void setTitleFont(java.awt.Font font)
Sets the font used to display the title of the slider.

Parameters:
font - new font

getTitleFont

public java.awt.Font getTitleFont()
Returns the font used to display the title.

Returns:

setUnitsFont

public void setUnitsFont(java.awt.Font font)
Sets the font used to display the units.

Parameters:
font - new font

getUnitsFont

public java.awt.Font getUnitsFont()
Returns the font used to display units.

Returns:

getMajorTicks

public double[] getMajorTicks()
Returns the values which are painted together with majot ticks.

Returns:

getMajorTickLabels

public double[] getMajorTickLabels()
Returns the values which have labeles painted next to the tick. Only major ticks can have labels.

Returns:

getMinorTicksStep

public double getMinorTicksStep()
Returns the distance between two minor ticks in same units as value.

Returns:

setMajorTicks

public void setMajorTicks(double[] ticks)
Explicitely sets which values on the slider scale should be painted with major ticks.

Parameters:
ticks -

setMinorTicksStep

public void setMinorTicksStep(double step)
Sets the distance between two minor ticks in same units as value.

Parameters:
ticks -

setMajorTickLabels

public void setMajorTickLabels(double[] labelledTicks)
Explicitely sets which major ticks will have value labels painted. If any of the labels in this array is not a major tick, that value will be ignored.

Parameters:
labelledTicks -

getStoredValue

public double getStoredValue()
Returns the stored value. If no value was stored Double.NaN is returned.

Returns:
stored value

setStoredValue

public void setStoredValue(double storedValue)
Stores new value. The stored value can be restored at any later time provided that is has not been override by a different value.

Parameters:
storedValue - new stored value
See Also:
restoreValue();

storeValue

public void storeValue()
Stores the current setpoint value.


restoreValue

public void restoreValue()
Restores the stored value. Value is set to the slider. This method has the same effect as setValue(double) where the parameter is getStoredValue().


setRestoreButtonTitle

public void setRestoreButtonTitle(java.lang.String title)
Sets the title of the restore button.

Parameters:
title - new title

getRestoreButtonTitle

public java.lang.String getRestoreButtonTitle()
Returns the title of the restore button.

Returns:
the title

getContinuousModeDelayTime

public int getContinuousModeDelayTime()
Returns the initial delay time after button press to first auto increment/decrement

Returns:
the continuousModeDelayTime

setContinuousModeDelayTime

public void setContinuousModeDelayTime(int continuousModeDelayTime)
Sets the initial delay time in milliseconds betwean button pressed and hold for increment/decrement and continuous mode is fired.

Parameters:
the - continuousModeDelayTime in milliseconds

isContinuousModeEnabled

public boolean isContinuousModeEnabled()
Returns continuousModeEnabled

Returns:
the continuousModeDelayTime

setContinuousModeEnabled

public void setContinuousModeEnabled(boolean continuousModeEnabled)
Sets the continuousModeEnabled and updates combobox on InfoBar to appropriate index

Parameters:
the - continuousModeEnabled

getContinuousModeRepeatTime

public int getContinuousModeRepeatTime()
Returns the continuousModeEnabled

Returns:
the continuousModeEnabled

setContinuousModeRepeatTime

public void setContinuousModeRepeatTime(int continuousModeRepeatTime)
Sets the continuousModeRepeatTime time in milliseconds between individual repetitions of contunuous increment/decrement.

Parameters:
the - continuousModeRepeatTime in milliseconds

setContinuousControlVisible

public void setContinuousControlVisible(boolean continuousControlVisible)
Sets visibility of control ofr continuous mode.

Parameters:
the - continuousControlVisible

isContinuousControlVisible

public boolean isContinuousControlVisible()
Returns true if contunyous mode checkbox is visible.

Returns:
the isShowContinuousMode

setToolTipText

public void setToolTipText(java.lang.String tooltip)
Overrides:
setToolTipText in class javax.swing.JComponent

setSnapToTicks

public void setSnapToTicks(boolean snapToTicks)
Sets the snap to ticks property. If true the slider thumb can be moved on discrete values defined by the slider ticks.

Parameters:
snapToTicks - true if thumb should snap to ticks

isSnapToTicks

public boolean isSnapToTicks()
Returns true if snap to ticks is turned on.

Returns:
true if snap is turned on
See Also:
setSnapToTicks(boolean)

main

public static void main(java.lang.String[] args)
Run test applet.

Parameters:
args - command line parameters


Copyright © 2010. All Rights Reserved.