jsky.util.gui
Class VRangeSlider

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by jsky.util.gui.VRangeSlider
All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener

public class VRangeSlider
extends JComponent
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 javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean drawLabels
          Flag determining whether text labels are drawn.
protected  EventListenerList listenerList
          list of listeners for change events
protected  double maxLimit
          Maximum slider value.
protected  Dimension maxSize
          Maximum widget size.
protected  double maxValue
          Percent through scale of max gripper.
protected  double minLimit
          Minimum slider value.
protected  Dimension minSize
          Minimum widget size.
protected  double minValue
          Percent through scale of min gripper.
protected  Dimension prefSize
          Preferred widget size.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, TOOL_TIP_TEXT_KEY, ui, 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
VRangeSlider(String label, double min, double max)
          Constructs a VRangeSlider with the specified range of values.
 
Method Summary
 void addChangeListener(ChangeListener l)
          register to receive change events from this object whenever the min or max values are changed.
protected  void fireChange()
          Notify any listeners of a change in the image or cut levels.
 boolean getDrawLabels()
          Indicates whether textual annotations will be drawn near this widget.
 Dimension getMaximumSize()
          Returns maximum size of range slider.
 double getMaxValue()
          Percent through scale of max gripper.
 Dimension getMinimumSize()
          Returns minimum size of range slider.
 double[] getMinMaxValues()
          Gets minimum and maximum slider values.
 double getMinValue()
          Percent through scale of min gripper.
 Dimension getPreferredSize()
          Returns preferred size of range slider.
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 paintComponent(Graphics g)
          Draws the slider from scratch.
 void removeChangeListener(ChangeListener l)
          Stop receiving change events from this object.
protected  void resetValues(double min, double max)
          Resets the minimum and maximum values.
 void setBounds(double min, double 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 setDrawLabels(boolean drawLabels)
          Determines whether textual annotations should be drawn near this widget.
 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(double lo, double hi)
          Sets the slider's lo and hi values.
 void valuesUpdated()
          Called whenever the min or max value is updated.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

minValue

protected double minValue
Percent through scale of min gripper.


maxValue

protected double maxValue
Percent through scale of max gripper.


minLimit

protected double minLimit
Minimum slider value.


maxLimit

protected double maxLimit
Maximum slider value.


minSize

protected Dimension minSize
Minimum widget size.


prefSize

protected Dimension prefSize
Preferred widget size.


maxSize

protected Dimension maxSize
Maximum widget size.


drawLabels

protected boolean drawLabels
Flag determining whether text labels are drawn.


listenerList

protected EventListenerList listenerList
list of listeners for change events

Constructor Detail

VRangeSlider

public VRangeSlider(String label,
                    double min,
                    double max)
Constructs a VRangeSlider with the specified range of values.

Method Detail

getMinValue

public double getMinValue()
Percent through scale of min gripper.


getMaxValue

public double getMaxValue()
Percent through scale of max gripper.


getMinMaxValues

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


resetValues

protected void resetValues(double min,
                           double 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(double min,
                      double max)
Sets the slider's lo and hi bounds.


setValues

public void setValues(double lo,
                      double 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

addChangeListener

public void addChangeListener(ChangeListener l)
register to receive change events from this object whenever the min or max values are changed.


removeChangeListener

public void removeChangeListener(ChangeListener l)
Stop receiving change events from this object.


fireChange

protected void fireChange()
Notify any listeners of a change in the image or cut levels.


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 JComponent

setMinimumSize

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

Overrides:
setMinimumSize in class JComponent

getPreferredSize

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

Overrides:
getPreferredSize in class JComponent

setPreferredSize

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

Overrides:
setPreferredSize in class JComponent

getMaximumSize

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

Overrides:
getMaximumSize in class JComponent

setMaximumSize

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

Overrides:
setMaximumSize in class JComponent

valuesUpdated

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


paintComponent

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

Overrides:
paintComponent in class JComponent

setDrawLabels

public void setDrawLabels(boolean drawLabels)
Determines whether textual annotations should be drawn near this widget.

Parameters:
drawLabels - whether to draw textual annotation

getDrawLabels

public boolean getDrawLabels()
Indicates whether textual annotations will be drawn near this widget.

Returns:
whether textual annotation will be drawn

main

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



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.