com.tensegrity.gui.swt.graph
Class TENSlider

java.lang.Object
  extended bycom.tensegrity.gui.swt.graph.TENSlider

public class TENSlider
extends java.lang.Object

This class is a simple wrapper around the SWT widget Slider. It provides extra useful methods like:

This class implements an internal selection listener used in order to retrieve the Slider's drag orientation and to know whether or not a Drag is being performed at a given time. This is required because while the Slider informs the user that a drag is being performed, there is no easy mean to know the direction of the drag.

Version:
$Id: TENSlider.java,v 1.20 2005/07/20 14:16:37 SebastienGuyon Exp $
Author:
S�bastien Guyon

Field Summary
static int DRAG_ORIENTATION_DECREMENT
          The drag orientation is from bottom to top for vertical sliders, or right to left for horizontal sliders.
static int DRAG_ORIENTATION_INCREMENT
          The drag orientation is from top to bottom for vertical sliders, or left to right for horizontal sliders.
static int DRAG_ORIENTATION_NONE
          The drag orientation could not be defined.
 
Constructor Summary
TENSlider(org.eclipse.swt.widgets.Composite parent, int style)
           Initializes the local Slider instance this class is a wrapper of and adds a selection listener to it.
TENSlider(org.eclipse.swt.widgets.Composite parent, int style, int selection, int extent, int min, int max)
           TODO SGu (12.07.2005): Comment constructor
 
Method Summary
 void addListener(int arg0, org.eclipse.swt.widgets.Listener arg1)
           See Widget.addListener(int, org.eclipse.swt.widgets.Listener)
 void addSelectionListener(org.eclipse.swt.events.SelectionListener arg0)
          Adds the passed selection listener to the internal Slider instance.
 void dispose()
           Disposes allocated resources.
 int getDragDecrementValue()
           Useful when the slider's thumb is being dragged, this method returns the drag decrement value.
 int getDragIncrementValue()
           Useful when the slider's thumb is being dragged, this method returns the drag increment value.
 int getDragOrientation()
           Useful when the slider's thumb is being dragged, this method returns the drag orientation.
 int getIncrement()
          Returns the local Slider instance's Increment value.
 int getMaximum()
          Returns the maximum as understood by the view.
 int getMinimum()
          Returns the minimum as understood by the view - this value can be negative (contrary to the slider ones which cannot)
 int getPageIncrement()
          Returns the local Slider instance's Page Increment value.
 int getSelection()
           The selection on this TENSlider (can be negative).
 int getSwtSliderThumb()
          Returns the local slider instance's thumb value.
 boolean isCurrentlyPerformingDrag()
          Returns true if the slider's thumb is being dragged.
 void refreshSliderSelection()
           
 void removeListener(int eventType, org.eclipse.swt.widgets.Listener listener)
          Removes the listener from the collection of listeners who will be notifed when an event of the given type occurs.
 void removeSelectionListener(org.eclipse.swt.events.SelectionListener arg0)
          Removes the passed SelectionListener.
 boolean selectionChanged()
           TODO SGu (07.07.2005): Comment method
 void setEnabled(boolean enabled)
          Enables the receiver if the argument is true, and disables it otherwise.
 void setLayoutData(java.lang.Object arg0)
           See Control.setLayoutData(java.lang.Object)
 void setMinAndMax(int min, int max)
           Because of the offset if the minimum is set to a negative value we need to set the minimum first, then the maximum.
 void setRangeProperties(int newValue, int newExtent, int newMin, int newMax, int newIncrement, int newPageIncrement, boolean adjusting)
           TODO SGu (12.07.2005): Comment method
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DRAG_ORIENTATION_NONE

public static final int DRAG_ORIENTATION_NONE
The drag orientation could not be defined.

See Also:
Constant Field Values

DRAG_ORIENTATION_INCREMENT

public static final int DRAG_ORIENTATION_INCREMENT
The drag orientation is from top to bottom for vertical sliders, or left to right for horizontal sliders.

See Also:
Constant Field Values

DRAG_ORIENTATION_DECREMENT

public static final int DRAG_ORIENTATION_DECREMENT
The drag orientation is from bottom to top for vertical sliders, or right to left for horizontal sliders.

See Also:
Constant Field Values
Constructor Detail

TENSlider

public TENSlider(org.eclipse.swt.widgets.Composite parent,
                 int style)

Initializes the local Slider instance this class is a wrapper of and adds a selection listener to it. Properties are set using the following default values:

Parameters:
parent - a composite control which will be the parent of the new instance (cannot be null)
style - the style of control to construct

TENSlider

public TENSlider(org.eclipse.swt.widgets.Composite parent,
                 int style,
                 int selection,
                 int extent,
                 int min,
                 int max)

TODO SGu (12.07.2005): Comment constructor

Parameters:
parent - a composite control which will be the parent of the new instance (cannot be null)
style - the style of control to construct
selection - the slider value
extent - the amount by which the value can "jump"
min - the minimum value
max - the maximum value
Method Detail

getDragOrientation

public final int getDragOrientation()

Useful when the slider's thumb is being dragged, this method returns the drag orientation.

Returns:
One of DRAG_ORIENTATION_NONE,DRAG_ORIENTATION_INCREMENT or DRAG_ORIENTATION_DECREMENT

getDragIncrementValue

public final int getDragIncrementValue()

Useful when the slider's thumb is being dragged, this method returns the drag increment value.

Returns:
the drag increment value.

getDragDecrementValue

public final int getDragDecrementValue()

Useful when the slider's thumb is being dragged, this method returns the drag decrement value.

Returns:
the drag Decrement value.

addSelectionListener

public void addSelectionListener(org.eclipse.swt.events.SelectionListener arg0)
Adds the passed selection listener to the internal Slider instance.

Parameters:
arg0 - the SelectionListener to set
See Also:
Slider.addSelectionListener(org.eclipse.swt.events.SelectionListener)

getIncrement

public int getIncrement()
Returns the local Slider instance's Increment value.

Returns:
the local Slider instance's Increment value.
See Also:
Slider.getIncrement()

getMaximum

public int getMaximum()
Returns the maximum as understood by the view. THIS IS NOT the maximum of the local Slider instance !!.

Returns:
this TENSlider instance maximum value. Matches the scrollbar maximum given by the view.
See Also:
Slider.getMaximum()

getMinimum

public int getMinimum()
Returns the minimum as understood by the view - this value can be negative (contrary to the slider ones which cannot)

Returns:
this TENSlider instance minimum value. Matches the scrollbar minimum given by the view.
See Also:
Slider.getMinimum()

getPageIncrement

public int getPageIncrement()
Returns the local Slider instance's Page Increment value.

Returns:
the local Slider instance's Page Increment value.
See Also:
Slider.getPageIncrement()

getSelection

public int getSelection()

The selection on this TENSlider (can be negative). Attention. THIS IS NOT the selection on the local Slider instance.

Returns:
the selection on this TENSlider (can be negative). Attention. THIS IS NOT the selection on the local Slider instance.

getSwtSliderThumb

public int getSwtSliderThumb()
Returns the local slider instance's thumb value.

Returns:
the local slider instance's thumb value.
See Also:
Slider.getThumb()

removeSelectionListener

public void removeSelectionListener(org.eclipse.swt.events.SelectionListener arg0)
Removes the passed SelectionListener.

Parameters:
arg0 - the SelectionListener to remove
See Also:
Slider.removeSelectionListener(org.eclipse.swt.events.SelectionListener)

removeListener

public void removeListener(int eventType,
                           org.eclipse.swt.widgets.Listener listener)
Removes the listener from the collection of listeners who will be notifed when an event of the given type occurs.

Parameters:
eventType - the type of event to listen for
listener - the listener which should no longer be notified when the event occurs

setMinAndMax

public void setMinAndMax(int min,
                         int max)

Because of the offset if the minimum is set to a negative value we need to set the minimum first, then the maximum. Hence this method which forces it.

Parameters:
min - the slider's minimum value. Should be the dame as the CompositeView's scrollbar minimum value.
max - the slider's maximum value. Should be the dame as the CompositeView's scrollbar maximum value.

setEnabled

public void setEnabled(boolean enabled)
Enables the receiver if the argument is true, and disables it otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

Parameters:
enabled - the new enabled state

setLayoutData

public void setLayoutData(java.lang.Object arg0)

See Control.setLayoutData(java.lang.Object)

Parameters:
arg0 - the new layout data for the receiver.

addListener

public void addListener(int arg0,
                        org.eclipse.swt.widgets.Listener arg1)

See Widget.addListener(int, org.eclipse.swt.widgets.Listener)

Parameters:
arg0 - the type of event to listen for
arg1 - the listener which should be notified when the event occurs

refreshSliderSelection

public void refreshSliderSelection()

isCurrentlyPerformingDrag

public boolean isCurrentlyPerformingDrag()
Returns true if the slider's thumb is being dragged. It it important to have this information, for example not to update the thumb size when the drag is performed.

Returns:
true if the thumb is currenlty being dragged.

dispose

public void dispose()

Disposes allocated resources.


selectionChanged

public final boolean selectionChanged()

TODO SGu (07.07.2005): Comment method

Returns:

toString

public java.lang.String toString()

setRangeProperties

public void setRangeProperties(int newValue,
                               int newExtent,
                               int newMin,
                               int newMax,
                               int newIncrement,
                               int newPageIncrement,
                               boolean adjusting)

TODO SGu (12.07.2005): Comment method

Parameters:
newValue -
newExtent -
newMin -
newMax -
newIncrement -
newPageIncrement -
adjusting -


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.