infovis.panel.dqinter
Class RangeSlider

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by infovis.panel.dqinter.RangeSlider
All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, ChangeListener

public class RangeSlider
extends JComponent
implements MouseListener, MouseMotionListener, ChangeListener

Implements a Swing-based Range slider, which allows the user to enter a range-based value.

Version:
$Revision: 1.6 $
Author:
Ben B. Bederson, Jon Meyer and Jean-Daniel Fekete
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
RangeSlider(BoundedRangeModel model)
          Creates a new RangeSlider object.
RangeSlider(int minimum, int maximum, int lowValue, int highValue)
          Constructs a new range slider.
 
Method Summary
 boolean contains(int v)
          Returns true if the specified value is within the range indicated by this range slider, i˙e˙ lowValue 1 <= v <= highValue.
 int getHighValue()
          Returns the current "high" value shown by the range slider's bar.
 int getLowValue()
          Returns the current "low" value shown by the range slider's bar.
 int getMaximum()
          Returns the maximum possible value for either the low value or the high value.
 int getMinimum()
          Returns the minimum possible value for either the low value or the high value.
 BoundedRangeModel getModel()
          Returns the sizeModel.
 Dimension getPreferredSize()
           
 String getToolTipText(MouseEvent event)
           
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void setEnabled(boolean v)
           
 void setHighValue(int highValue)
          Sets the high value shown by this range slider.
 void setLowValue(int lowValue)
          Sets the low value shown by this range slider.
 void setMaximum(int max)
          Sets the maximum value of the sizeModel.
 void setMinimum(int min)
          Sets the minimum value of the sizeModel.
 void setModel(BoundedRangeModel model)
          Sets the sizeModel.
 void stateChanged(ChangeEvent e)
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RangeSlider

public RangeSlider(int minimum,
                   int maximum,
                   int lowValue,
                   int highValue)
Constructs a new range slider.

Parameters:
minimum - - the minimum value of the range.
maximum - - the maximum value of the range.
lowValue - - the current low value shown by the range slider's bar.
highValue - - the current high value shown by the range slider's bar.

RangeSlider

public RangeSlider(BoundedRangeModel model)
Creates a new RangeSlider object.

Parameters:
model - the BoundedRangeModel.
Method Detail

getLowValue

public int getLowValue()
Returns the current "low" value shown by the range slider's bar. The low value meets the constraint minimum <= lowValue <= highValue <= maximum.

Returns:
the current "low" value shown by the range slider's bar.

getHighValue

public int getHighValue()
Returns the current "high" value shown by the range slider's bar. The high value meets the constraint minimum <= lowValue <= highValue <= maximum.

Returns:
the current "high" value shown by the range slider's bar.

getMinimum

public int getMinimum()
Returns the minimum possible value for either the low value or the high value.

Returns:
the minimum possible value for either the low value or the high value.

getMaximum

public int getMaximum()
Returns the maximum possible value for either the low value or the high value.

Returns:
the maximum possible value for either the low value or the high value.

contains

public boolean contains(int v)
Returns true if the specified value is within the range indicated by this range slider, i˙e˙ lowValue 1 <= v <= highValue.

Parameters:
v - value
Returns:
true if the specified value is within the range indicated by this range slider.

setLowValue

public void setLowValue(int lowValue)
Sets the low value shown by this range slider. This causes the range slider to be repainted and a RangeEvent to be fired.

Parameters:
lowValue - the low value shown by this range slider

setHighValue

public void setHighValue(int highValue)
Sets the high value shown by this range slider. This causes the range slider to be repainted and a RangeEvent to be fired.

Parameters:
highValue - the high value shown by this range slider

setMinimum

public void setMinimum(int min)
Sets the minimum value of the sizeModel.

Parameters:
min - the minimum value.

setMaximum

public void setMaximum(int max)
Sets the maximum value of the sizeModel.

Parameters:
max - the maximum value.

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener
See Also:
MouseMotionListener.mouseDragged(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener
See Also:
MouseMotionListener.mouseMoved(java.awt.event.MouseEvent)

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent)

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class JComponent
See Also:
JComponent.getPreferredSize()

setEnabled

public void setEnabled(boolean v)
Overrides:
setEnabled in class JComponent
See Also:
JComponent.setEnabled(boolean)

stateChanged

public void stateChanged(ChangeEvent e)
Specified by:
stateChanged in interface ChangeListener
See Also:
ChangeListener.stateChanged(ChangeEvent)

getModel

public BoundedRangeModel getModel()
Returns the sizeModel.

Returns:
BoundedRangeModel

setModel

public void setModel(BoundedRangeModel model)
Sets the sizeModel.

Parameters:
model - The BoundedRangeModel to set

getToolTipText

public String getToolTipText(MouseEvent event)
Overrides:
getToolTipText in class JComponent
See Also:
JComponent.getToolTipText(MouseEvent)


Copyright © 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.