All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class guinea.ui.Slider

java.lang.Object
   |
   +----java.awt.Component
           |
           +----guinea.ui.Slider

public class Slider
extends Component
implements Adjustable, Serializable
An adjustable AWT component similar to java.awt.Scrollbar component. This version uses a slider that is similar to Java's Swing component JSlider.

See Also:
Adjustable, Scrollbar, LineScale, GradeBar

Variable Index

· adjustmentListener
List of event listeners.
· curValue
Current value.
· EVENT_WHEN_MOVED
· EVENT_WHEN_RELEASED
· eventWhenMoved
Foo
· fixedLineLength
Minimum length of slider's line (in pixels).
· knob
The polygon used to draw slider's knob.
· knobCoordsUpdated
· knobFillColor
The slider knob's fill color.
· knobSize
Size of the slider knob.
· labelFont
Font used for the labels.
· lineCoords
· lineCoordsUpdated
· lineFillColor
The slider line's fill color.
· lineYPos
The Y coordinate of the slider line from the top of the component.
· maxValue
Maximum value.
· minValue
Minimum value.
· numTicks
Number of ticks.
· pressed
· size
Size of component.
· sliderArea
· sliderOffset
Offset of the slider's line from the left and right edge of the component.
· ticks
Ticks.
· xPos
· yPos

Constructor Index

· Slider()

Method Index

· addAdjustmentListener(AdjustmentListener)
Add a listener to recieve adjustment events when the value of the adjustable object changes.
· addTick(int)
Add a tick (without a label) to the slider.
· addTick(int, String)
Add a tick and corresponding label to the slider.
· addTick(int, String, int)
Add a tick and corresponding label to the slider.
· createKnob()
· drawKnob(Graphics)
Draw slider's knob.
· drawLine()
Draw the grading line on the slider component.
· drawLine(Graphics, Dimension)
Draw the grading line on the slider component.
· eraseKnob(Graphics)
Erase slider's knob.
· getBlockIncrement()
Gets the block value increment for the adjustable object.
· getKnobSize()
· getLabelFont()
Get the font used for drawing labels.
· getMaximum()
Gets the maximum value of the adjustable object.
· getMinimum()
Gets the minimum value of the adjustable object.
· getMinimumSize()
Gets the mininimum size of this component.
· getOrientation()
Gets the orientation of the adjustable object.
· getPreferredSize()
Gets the preferred size of this component.
· getSliderOffset()
· getUnitIncrement()
Gets the unit value increment for the adjustable object.
· getValue()
Gets the current value of the adjustable object.
· getVisibleAmount()
Gets the length of the propertional indicator.
· handleMouse(MouseEvent)
· initEvents()
· invalidate()
Invalidate cached coordinates and sizes.
· invalidateTicks()
Invalidate cached coordinates and sizes calculated in the ticks.
· main(String[])
· paint(Graphics)
Paints this component.
· postEvent()
Create an adjustment event and send it to listeners.
· processAdjustmentEvent(AdjustmentEvent)
Process adjustment event (send it to listeners).
· processMouseEvent(MouseEvent)
Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects.
· processMouseMotionEvent(MouseEvent)
Processes mouse motion events occurring on this component by dispatching them to any registered MouseMotionListener objects.
· recalculateKnobCoords()
· recalculateKnobCoords(int)
· recalculateLineCoords(Dimension)
· removeAdjustmentListener(AdjustmentListener)
Removes an adjustment listener.
· removeAllTicks()
Remove all ticks and labels from this slider.
· setBlockIncrement(int)
Sets the block value increment for the adjustable object.
· setBounds(int, int, int, int)
Set size and location of the component.
· setEnabled(boolean)
Enable or disable component.
· setKnobSize(int)
· setLabelFont(Font)
Set font for labels.
· setLineLength(int)
Set minimum length of slider line in pixels.
· setMaximum(int)
Sets the maximum value of the adjustable object.
· setMinimum(int)
Sets the minimum value of the adjustable object.
· setSliderOffset(int)
· setUnitIncrement(int)
Sets the unit value increment for the adjustable object.
· setValue(int)
Sets the current value of the adjustable object.
· setVisibleAmount(int)
Sets the length of the proportionl indicator of the adjustable object.
· setWhenEvent(int)
· translateCoordToValue(int)
Translate an x-coordinate (got from a mouse event, for example) to adjustable value corresponding to the coordinate.
· translateValueToCoord(int)
Translate an adjustable-value to a corresponding component's x-coordinate for drawing, for example.

Variables

· size
 protected transient Dimension size
Size of component.

· lineYPos
 protected int lineYPos
The Y coordinate of the slider line from the top of the component. Default is 10.

· knobSize
 protected int knobSize
Size of the slider knob. Default is 10.

· knob
 protected Polygon knob
The polygon used to draw slider's knob.

· sliderOffset
 protected int sliderOffset
Offset of the slider's line from the left and right edge of the component. Default is 10.

· fixedLineLength
 protected int fixedLineLength
Minimum length of slider's line (in pixels). The slider's length is at least this long. Default is 0.

· xPos
 protected transient int xPos
· yPos
 protected transient int yPos
· minValue
 protected int minValue
Minimum value.

· maxValue
 protected int maxValue
Maximum value.

· curValue
 protected transient int curValue
Current value.

· knobCoordsUpdated
 protected transient boolean knobCoordsUpdated
· lineCoordsUpdated
 protected transient boolean lineCoordsUpdated
· lineCoords
 protected transient Rectangle lineCoords
· knobFillColor
 protected Color knobFillColor
The slider knob's fill color.

· lineFillColor
 protected Color lineFillColor
The slider line's fill color.

· labelFont
 protected Font labelFont
Font used for the labels.

· sliderArea
 protected transient Rectangle sliderArea
· ticks
 protected Slider. Tick ticks[]
Ticks.

· numTicks
 protected int numTicks
Number of ticks.

· pressed
 protected transient boolean pressed
· eventWhenMoved
 protected boolean eventWhenMoved
Foo

· EVENT_WHEN_MOVED
 public static final int EVENT_WHEN_MOVED
· EVENT_WHEN_RELEASED
 public static final int EVENT_WHEN_RELEASED
· adjustmentListener
 protected AdjustmentListener adjustmentListener
List of event listeners.

Constructors

· Slider
 public Slider()

Methods

· createKnob
 protected Polygon createKnob()
· initEvents
 protected void initEvents()
· setWhenEvent
 public void setWhenEvent(int type)
· paint
 public synchronized void paint(Graphics g)
Paints this component.

Overrides:
paint in class Component
· recalculateLineCoords
 protected void recalculateLineCoords(Dimension s)
· drawLine
 protected void drawLine()
Draw the grading line on the slider component.

· drawLine
 protected void drawLine(Graphics g,
                         Dimension s)
Draw the grading line on the slider component.

· translateCoordToValue
 protected int translateCoordToValue(int x)
Translate an x-coordinate (got from a mouse event, for example) to adjustable value corresponding to the coordinate.

Parameters:
x - A coordinate to translate to an adjustable-value.
Returns:
An adjustable value corresponding to x-coordinate.
· translateValueToCoord
 protected int translateValueToCoord(int value)
Translate an adjustable-value to a corresponding component's x-coordinate for drawing, for example.

Parameters:
value - An adjustable value to translate to corresponding component coordinate.
Returns:
A x-coordinate corresponding to translated value.
· recalculateKnobCoords
 protected void recalculateKnobCoords(int value)
· recalculateKnobCoords
 protected void recalculateKnobCoords()
· drawKnob
 protected void drawKnob(Graphics g)
Draw slider's knob.

Parameters:
g - A graphics object.
· eraseKnob
 protected void eraseKnob(Graphics g)
Erase slider's knob.

Parameters:
g - A graphics object.
· setEnabled
 public void setEnabled(boolean enabled)
Enable or disable component.

Parameters:
enabled - Is component enabled.
Overrides:
setEnabled in class Component
· setSliderOffset
 public void setSliderOffset(int offset)
· getSliderOffset
 public int getSliderOffset()
· setKnobSize
 public void setKnobSize(int size)
· getKnobSize
 public int getKnobSize()
· setBounds
 public void setBounds(int x,
                       int y,
                       int width,
                       int height)
Set size and location of the component. Also invalidates cached position calculations in parts and ticks.

Parameters:
x - X-coordinate.
y - X-coordinate.
width - Width of component.
height - Height of component.
Overrides:
setBounds in class Component
See Also:
invalidate
· getMinimumSize
 public Dimension getMinimumSize()
Gets the mininimum size of this component.

Overrides:
getMinimumSize in class Component
· getPreferredSize
 public Dimension getPreferredSize()
Gets the preferred size of this component.

Overrides:
getPreferredSize in class Component
· setLineLength
 public void setLineLength(int len)
Set minimum length of slider line in pixels.

Parameters:
len - Length of line in pixels.
· getLabelFont
 public Font getLabelFont()
Get the font used for drawing labels.

Returns:
A Java font.
· setLabelFont
 public void setLabelFont(Font font)
Set font for labels.

Parameters:
font - A font.
· removeAllTicks
 public void removeAllTicks()
Remove all ticks and labels from this slider.

· addTick
 public void addTick(int value,
                     String label,
                     int level)
Add a tick and corresponding label to the slider.

Parameters:
value - The slider position where to set the tick.
label - A label to be shown below the tick. If null, no label is shown, only a tick.
level - Zero is default value. Use one, two, etc. to write the label below the previous level. Usefull if many labels are used and they tend to overlap.
· addTick
 public void addTick(int value,
                     String label)
Add a tick and corresponding label to the slider.

Parameters:
value - The slider position where to set the tick.
label - A label to be shown below the tick. If null, no label is shown, only a tick.
· addTick
 public void addTick(int value)
Add a tick (without a label) to the slider.

Parameters:
value - The slider position where to set the tick.
· invalidate
 public void invalidate()
Invalidate cached coordinates and sizes. Forces recalculation of them when needed next time. Also invalidates values calculated in ticks.

Overrides:
invalidate in class Component
See Also:
invalidateTicks
· invalidateTicks
 protected void invalidateTicks()
Invalidate cached coordinates and sizes calculated in the ticks. Forces recalculation of them when needed next time.

· processMouseEvent
 protected void processMouseEvent(MouseEvent e)
Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects.

Overrides:
processMouseEvent in class Component
· processMouseMotionEvent
 protected void processMouseMotionEvent(MouseEvent e)
Processes mouse motion events occurring on this component by dispatching them to any registered MouseMotionListener objects.

Overrides:
processMouseMotionEvent in class Component
· handleMouse
 protected void handleMouse(MouseEvent e)
· getOrientation
 public int getOrientation()
Gets the orientation of the adjustable object.

· setMinimum
 public void setMinimum(int min)
Sets the minimum value of the adjustable object.

Parameters:
min - the minimum value
· getMinimum
 public int getMinimum()
Gets the minimum value of the adjustable object.

· setMaximum
 public void setMaximum(int max)
Sets the maximum value of the adjustable object.

Parameters:
max - the maximum value
· getMaximum
 public int getMaximum()
Gets the maximum value of the adjustable object.

· setUnitIncrement
 public void setUnitIncrement(int u)
Sets the unit value increment for the adjustable object.

Parameters:
u - the unit increment
· getUnitIncrement
 public int getUnitIncrement()
Gets the unit value increment for the adjustable object.

· setBlockIncrement
 public void setBlockIncrement(int b)
Sets the block value increment for the adjustable object.

Parameters:
b - the block increment
· getBlockIncrement
 public int getBlockIncrement()
Gets the block value increment for the adjustable object. This is not currently used.

Returns:
Currently, 1 is always returned.
· setVisibleAmount
 public void setVisibleAmount(int v)
Sets the length of the proportionl indicator of the adjustable object. This is not currently used.

Parameters:
v - Currently this is ignored.
· getVisibleAmount
 public int getVisibleAmount()
Gets the length of the propertional indicator.

· setValue
 public void setValue(int v)
Sets the current value of the adjustable object. This value must be within the range defined by the minimum and maximum values for this object.

Parameters:
v - the current value
· getValue
 public int getValue()
Gets the current value of the adjustable object.

Returns:
Current value of the adjustable object.
· postEvent
 protected void postEvent()
Create an adjustment event and send it to listeners.

See Also:
processAdjustmentEvent
· processAdjustmentEvent
 protected void processAdjustmentEvent(AdjustmentEvent e)
Process adjustment event (send it to listeners).

Parameters:
e - An adjustment event.
· addAdjustmentListener
 public void addAdjustmentListener(AdjustmentListener l)
Add a listener to recieve adjustment events when the value of the adjustable object changes.

Parameters:
l - The listener to recieve events.
See Also:
AWTEventMulticaster, AdjustmentEvent
· removeAdjustmentListener
 public void removeAdjustmentListener(AdjustmentListener l)
Removes an adjustment listener.

Parameters:
l - The listener being removed.
See Also:
AWTEventMulticaster, AdjustmentEvent
· main
 public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index