gishur.awt
Class SymbolbarSlider

java.lang.Object
  |
  +--gishur.awt.SymbolbarElement
        |
        +--gishur.awt.SymbolbarSlider
All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

public class SymbolbarSlider
extends SymbolbarElement

A Symbolbarelement class that represents a slider. The values in the slider range from 0 to a specified maximum value. The smallest increment / decrement of the value is 1. To map the slider value to real world values, one has to transform the values outside of this control. The labels of the slider - three labels (one left, one right and one in the middle) are possible - can be specified freely via the methods setLeftText(java.lang.String), setRightText(java.lang.String) and setMidText(java.lang.String). If the value of the slider changes, by user interaction or by a call to the setValue(int) method, an action event of the type SYMBOLSLIDER_VALUE_CHANGED will be dispatched at the symbolbar. It is possible to set the slider bar value without dispatching events (see setValueTo(int) method) and to change the maximum value dynamically (see setMaxValue(int)).

Version:
1.0
Author:
Stefan Schwarz & Thomas Wolf

Field Summary
 java.awt.Color back_color
          The background color.
 java.awt.Color bar_color
          The color of the bar.
 int bar_height
          Height of the slider bar.
 java.awt.Font font
          font of the _slider label
 int hspace
          Distance to the left and right border.
 int slider_size
          Size of the Slider.
 int slider_voffset
          Vertical distance of the slider from center position.
static int SYMBOLSLIDER_VALUE_CHANGED
          ActionEvent-Type: Changed Value
 java.awt.Color text_color
          The forground color.
 java.awt.Color text_value_color
          The color of the value-text.
 int text_voffset
          Vertical distance of the text from the slider bar.
 
Fields inherited from class gishur.awt.SymbolbarElement
_needs_repaint, command, label, width
 
Constructor Summary
SymbolbarSlider(java.lang.String label, java.lang.String command, int width, int max_value)
          Constructor.
 
Method Summary
 void disableNumberedValues()
          Disables automatical printing of numbered labels and values.
 java.lang.String leftText()
           
 int maxValue()
          Returns the maximum value of the slider.
 java.lang.String midText()
           
 void mouseClicked(java.awt.event.MouseEvent e)
          Invoked when the mouse has been clicked on a component.
 void mouseDragged(java.awt.event.MouseEvent e)
          Invoked when a mouse button is pressed on a component and then dragged.
 void mousePressed(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been pressed on a component.
 void mouseReleased(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been released on a component.
 java.lang.String rightText()
           
 void setLeftText(java.lang.String text)
           
 void setMaxValue(int max)
          Sets the maximum value of the slider (must be >=0).
 void setMidText(java.lang.String text)
           
 void setNumberedLabels(int offset)
          Sets the text labels to the min/max numbers, where the minimum label is the given offset and the maximum label is offset+maxValue()().
 void setNumberedValues(int offset)
          Sets automatical printing of numbered labels and values.
 void setRightText(java.lang.String text)
           
 void setValue(int value)
          Sets the value of the slider to the given value and dispatches a value-changed event at the parent symbolbar.
 void setValueText(java.lang.String text)
           
 void setValueTo(int val)
          Sets the slider value to the specified value without dispatching events.
 void update(java.awt.Graphics g, int height)
          Redraw the element.
 int value()
          Returns the slider value (ranging from 0 to the maximum value).
 java.lang.String valueText()
           
 
Methods inherited from class gishur.awt.SymbolbarElement
active, disable, enable, enabled, getCommand, getLabel, getParent, getPreferredHeight, getSize, mouseEntered, mouseExited, mouseMoved, setActive, setCommand, setLabel, setParent, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYMBOLSLIDER_VALUE_CHANGED

public static final int SYMBOLSLIDER_VALUE_CHANGED
ActionEvent-Type: Changed Value

font

public java.awt.Font font
font of the _slider label

text_color

public java.awt.Color text_color
The forground color.

text_value_color

public java.awt.Color text_value_color
The color of the value-text.

back_color

public java.awt.Color back_color
The background color.

bar_color

public java.awt.Color bar_color
The color of the bar.

hspace

public int hspace
Distance to the left and right border.

bar_height

public int bar_height
Height of the slider bar.

slider_size

public int slider_size
Size of the Slider.

slider_voffset

public int slider_voffset
Vertical distance of the slider from center position.

text_voffset

public int text_voffset
Vertical distance of the text from the slider bar.
Constructor Detail

SymbolbarSlider

public SymbolbarSlider(java.lang.String label,
                       java.lang.String command,
                       int width,
                       int max_value)
Constructor.
Parameters:
label - the label string of the slider
command - the command string of the slider
width - the width of the element
max_value - the maximum value of the slider
Method Detail

update

public void update(java.awt.Graphics g,
                   int height)
Redraw the element.
Overrides:
update in class SymbolbarElement
Parameters:
g - the graphics on which we draw.
height - of the redrawing area.

setNumberedValues

public void setNumberedValues(int offset)
Sets automatical printing of numbered labels and values.
Parameters:
offset - the offset for displayed values
See Also:
setNumberedValues(int)

disableNumberedValues

public void disableNumberedValues()
Disables automatical printing of numbered labels and values. Labels and values may be set via setLeftText(java.lang.String), setMidText(java.lang.String), setRightText(java.lang.String) and setValueText(java.lang.String).
See Also:
setNumberedValues(int)

setLeftText

public void setLeftText(java.lang.String text)

leftText

public java.lang.String leftText()

setRightText

public void setRightText(java.lang.String text)

rightText

public java.lang.String rightText()

setMidText

public void setMidText(java.lang.String text)

midText

public java.lang.String midText()

setValueText

public void setValueText(java.lang.String text)

valueText

public java.lang.String valueText()

value

public int value()
Returns the slider value (ranging from 0 to the maximum value).
Returns:
the slider value

setValueTo

public void setValueTo(int val)
Sets the slider value to the specified value without dispatching events.
Parameters:
val - new slider value

maxValue

public int maxValue()
Returns the maximum value of the slider.
Returns:
maximum value

setMaxValue

public void setMaxValue(int max)
Sets the maximum value of the slider (must be >=0). This method does not relabel the left/mid/right labels!
Parameters:
max - new maximum value

setNumberedLabels

public void setNumberedLabels(int offset)
Sets the text labels to the min/max numbers, where the minimum label is the given offset and the maximum label is offset+maxValue()().

setValue

public void setValue(int value)
Sets the value of the slider to the given value and dispatches a value-changed event at the parent symbolbar.
Parameters:
value - new value

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed on a component.
Overrides:
mousePressed in class SymbolbarElement

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released on a component.
Overrides:
mouseReleased in class SymbolbarElement

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged. Mouse drag events will continue to be delivered to the component where the first originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).
Overrides:
mouseDragged in class SymbolbarElement

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse has been clicked on a component.
Overrides:
mouseClicked in class SymbolbarElement