visad.browser
Class RangeSlider

java.lang.Object
  extended by java.awt.Component
      extended by visad.browser.RangeSlider
All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener
Direct Known Subclasses:
RangeSlider

public class RangeSlider
extends Component
implements MouseListener, MouseMotionListener

A slider widget that allows users to select a lower and upper bound.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String DEFAULT_NAME
          Default variable name.
static int FONT_BOTTOM_Y
          Y-coordinate of bottom of font.
static int FONT_HEIGHT
          Height of font.
static int FONT_TOP_Y
          Y-coordinate of top of font.
static int GRIP_BOTTOM_Y
          Y-coordinate of bottom of grip.
static int GRIP_HEIGHT
          Height of grip.
static int GRIP_MIDDLE_Y
          Y-coordinate of middle of grip.
static int GRIP_TOP_Y
          Y-coordinate of top of grip.
static int GRIP_WIDTH
          Width of grip.
protected  boolean lSlideMoved
          Flag whether left gripper has moved.
protected  int maxGrip
          Location of max gripper.
protected  float maxLimit
          Maximum slider value.
protected  Dimension maxSize
          Maximum widget size.
protected  float maxValue
          Percent through scale of max gripper.
protected  int minGrip
          Location of min gripper.
protected  float minLimit
          Minimum slider value.
protected  Dimension minSize
          Minimum widget size.
protected  float minValue
          Percent through scale of min gripper.
protected  Dimension prefSize
          Preferred widget size.
protected  boolean rSlideMoved
          Flag whether right gripper has moved.
static int SLIDER_LINE_HEIGHT
          Height of slider line.
static int SLIDER_LINE_WIDTH
          Width of slider line.
static int SLIDER_PREF_HEIGHT
          Preferred slider height.
static int SLIDER_PREF_WIDTH
          Preferred slider width.
protected  boolean textChanged
          Flag whether current text string value needs updating.
 
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
RangeSlider(String n, float min, float max)
          Constructs a RangeSlider with the specified range of values.
 
Method Summary
 Dimension getMaximumSize()
          Returns maximum size of range slider.
 Dimension getMinimumSize()
          Returns minimum size of range slider.
 float[] getMinMaxValues()
          Gets minimum and maximum slider values.
 Dimension getPreferredSize()
          Returns preferred size of range slider.
protected  float gripToValue(int pos, int width)
           
static void main(String[] argv)
          Main method for testing purposes.
 void mouseClicked(MouseEvent e)
          Not used.
 void mouseDragged(MouseEvent e)
          MouseMotionListener method for moving slider.
 void mouseEntered(MouseEvent e)
          Not used.
 void mouseExited(MouseEvent e)
          Not used.
 void mouseMoved(MouseEvent e)
          Not used.
 void mousePressed(MouseEvent e)
          MouseListener method for moving slider.
 void mouseReleased(MouseEvent e)
          MouseListener method for moving slider.
 void paint(Graphics g)
          Draws the slider from scratch.
 void repaint()
          Repaints anything that needs it.
protected  void resetValues(float min, float max)
          Resets the minimum and maximum values.
 void setBounds(float min, float max)
          Sets the slider's lo and hi bounds.
 void setBounds(int x, int y, int w, int h)
          Redraws the slider if the widget width changes.
 void setMaximumSize(Dimension dim)
          Sets preferred size of range slider.
 void setMinimumSize(Dimension dim)
          Sets minimum size of range slider.
 void setName(String name)
          Sets the slider's name.
 void setPreferredSize(Dimension dim)
          Sets preferred size of range slider.
 void setValues(float lo, float hi)
          Sets the slider's lo and hi values.
 void valuesUpdated()
          Called whenever the min or max value is updated.
protected  int valueToGrip(float value, int width)
           
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_NAME

public static final String DEFAULT_NAME
Default variable name.

See Also:
Constant Field Values

SLIDER_PREF_HEIGHT

public static final int SLIDER_PREF_HEIGHT
Preferred slider height.

See Also:
Constant Field Values

SLIDER_PREF_WIDTH

public static final int SLIDER_PREF_WIDTH
Preferred slider width.

See Also:
Constant Field Values

GRIP_WIDTH

public static final int GRIP_WIDTH
Width of grip.

See Also:
Constant Field Values

GRIP_HEIGHT

public static final int GRIP_HEIGHT
Height of grip.

See Also:
Constant Field Values

GRIP_TOP_Y

public static final int GRIP_TOP_Y
Y-coordinate of top of grip.

See Also:
Constant Field Values

GRIP_BOTTOM_Y

public static final int GRIP_BOTTOM_Y
Y-coordinate of bottom of grip.

See Also:
Constant Field Values

GRIP_MIDDLE_Y

public static final int GRIP_MIDDLE_Y
Y-coordinate of middle of grip.

See Also:
Constant Field Values

SLIDER_LINE_HEIGHT

public static final int SLIDER_LINE_HEIGHT
Height of slider line.

See Also:
Constant Field Values

SLIDER_LINE_WIDTH

public static final int SLIDER_LINE_WIDTH
Width of slider line.

See Also:
Constant Field Values

FONT_HEIGHT

public static final int FONT_HEIGHT
Height of font.

See Also:
Constant Field Values

FONT_TOP_Y

public static final int FONT_TOP_Y
Y-coordinate of top of font.

See Also:
Constant Field Values

FONT_BOTTOM_Y

public static final int FONT_BOTTOM_Y
Y-coordinate of bottom of font.

See Also:
Constant Field Values

minValue

protected float minValue
Percent through scale of min gripper.


maxValue

protected float maxValue
Percent through scale of max gripper.


minLimit

protected float minLimit
Minimum slider value.


maxLimit

protected float maxLimit
Maximum slider value.


minGrip

protected int minGrip
Location of min gripper.


maxGrip

protected int maxGrip
Location of max gripper.


lSlideMoved

protected boolean lSlideMoved
Flag whether left gripper has moved.


rSlideMoved

protected boolean rSlideMoved
Flag whether right gripper has moved.


textChanged

protected boolean textChanged
Flag whether current text string value needs updating.


minSize

protected Dimension minSize
Minimum widget size.


prefSize

protected Dimension prefSize
Preferred widget size.


maxSize

protected Dimension maxSize
Maximum widget size.

Constructor Detail

RangeSlider

public RangeSlider(String n,
                   float min,
                   float max)
Constructs a RangeSlider with the specified range of values.

Method Detail

getMinMaxValues

public float[] getMinMaxValues()
Gets minimum and maximum slider values.


resetValues

protected void resetValues(float min,
                           float max)
Resets the minimum and maximum values.


setName

public void setName(String name)
Sets the slider's name.

Overrides:
setName in class Component

setBounds

public void setBounds(float min,
                      float max)
Sets the slider's lo and hi bounds.


setValues

public void setValues(float lo,
                      float hi)
Sets the slider's lo and hi values.


setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Redraws the slider if the widget width changes.

Overrides:
setBounds in class Component

mousePressed

public void mousePressed(MouseEvent e)
MouseListener method for moving slider.

Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
MouseListener method for moving slider.

Specified by:
mouseReleased in interface MouseListener

mouseClicked

public void mouseClicked(MouseEvent e)
Not used.

Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Not used.

Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Not used.

Specified by:
mouseExited in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent e)
MouseMotionListener method for moving slider.

Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent e)
Not used.

Specified by:
mouseMoved in interface MouseMotionListener

getMinimumSize

public Dimension getMinimumSize()
Returns minimum size of range slider.

Overrides:
getMinimumSize in class Component

setMinimumSize

public void setMinimumSize(Dimension dim)
Sets minimum size of range slider.

Overrides:
setMinimumSize in class Component

getPreferredSize

public Dimension getPreferredSize()
Returns preferred size of range slider.

Overrides:
getPreferredSize in class Component

setPreferredSize

public void setPreferredSize(Dimension dim)
Sets preferred size of range slider.

Overrides:
setPreferredSize in class Component

getMaximumSize

public Dimension getMaximumSize()
Returns maximum size of range slider.

Overrides:
getMaximumSize in class Component

setMaximumSize

public void setMaximumSize(Dimension dim)
Sets preferred size of range slider.

Overrides:
setMaximumSize in class Component

gripToValue

protected float gripToValue(int pos,
                            int width)

valueToGrip

protected int valueToGrip(float value,
                          int width)

valuesUpdated

public void valuesUpdated()
Called whenever the min or max value is updated. This method is meant to be overridden by extension classes.


paint

public void paint(Graphics g)
Draws the slider from scratch.

Overrides:
paint in class Component

repaint

public void repaint()
Repaints anything that needs it.

Overrides:
repaint in class Component

main

public static void main(String[] argv)
Main method for testing purposes.