visad.util
Class VisADSlider

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by visad.util.VisADSlider
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener, ControlListener, ScalarMapListener

public class VisADSlider
extends JPanel
implements ChangeListener, ControlListener, ScalarMapListener

VisADSlider combines a JSlider and a JLabel and links them to either a Real (via a DataReference) or a ScalarMap that maps to Display.SelectValue. Changes in the slider will reflect the Real or ScalarMap linked to it. If no bounds are specified, they will be detected from the ScalarMap and the slider will auto-scale. Note that a slider linked to a Real cannot auto-scale, because it has no way to detect the bounds.

BoxLayout doesn't handle a mixture of the standard center-aligned widgets and VisADSliders, which are left-aligned by default. If you have problems with widgets being too wide, you may want to change the other widgets in the JPanel to align on the left (e.g. widget.setAlignmentX(BoxLayout.LEFT_ALIGNMENT))

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, 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
VisADSlider(DataReference ref, float min, float max)
          construct a VisADSlider from an existing Real pointed to by r, with minimum and maximum bounds min and max
VisADSlider(DataReference ref, float min, float max, float start, RealType rt, String n)
          construct a VisADSlider by creating a Real and linking it to r, using RealType rt and name n, with minimum and maximum bounds min and max, and starting value start
VisADSlider(ScalarMap smap)
          construct a VisADSlider from a ScalarMap that maps to Display.SelectValue, with auto-scaling minimum and maximum bounds, non-integral values, and a statically sized label.
VisADSlider(ScalarMap smap, boolean integralTicks)
          construct a VisADSlider from a ScalarMap that maps to Display.SelectValue, with auto-scaling minimum and maximum bounds, either integer or floating-point values, depending on the setting of integralTicks, and a statically sized label.
VisADSlider(ScalarMap smap, boolean integralTicks, boolean dynamicLabelWidth)
          construct a VisADSlider from a ScalarMap that maps to Display.SelectValue, with auto-scaling minimum and maximum bounds, either integer or floating-point values (depending on the setting of integralTicks, and either a static or dynamically sized label (depending on the setting of dynamicLabelWidth.
VisADSlider(ScalarMap smap, float min, float max)
          construct a VisADSlider from a ScalarMap that maps to Display.SelectValue, with minimum and maximum bounds min and max, no auto-scaling, non-integer values, and a static label width.
VisADSlider(String n, int lo, int hi, int st, double scale, DataReference ref, RealType rt)
          JSlider values range between low and hi (with initial value st) and are multiplied by scale to create Real values of RealType rt referenced by ref.
VisADSlider(String n, int lo, int hi, int st, double scale, DataReference ref, RealType rt, boolean dynamicLabelWidth)
          JSlider values range between low and hi (with initial value st) and are multiplied by scale to create Real values of RealType rt referenced by ref.
 
Method Summary
 void controlChanged(ControlEvent e)
          Update slider when value of linked ValueControl changes
 void controlChanged(ScalarMapControlEvent evt)
          ScalarMapListener method used to detect new control.
 void hardcodeSizePercent(int percent)
          Hardcode the preferred size of the slider after increasing the current width by the specified percentage (or decreasing it if percent is negative.)
 void mapChanged(ScalarMapEvent e)
          used for auto-scaling the minimum and maximum
 void stateChanged(ChangeEvent e)
          called when slider is adjusted
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
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, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VisADSlider

public VisADSlider(String n,
                   int lo,
                   int hi,
                   int st,
                   double scale,
                   DataReference ref,
                   RealType rt)
            throws VisADException,
                   RemoteException
JSlider values range between low and hi (with initial value st) and are multiplied by scale to create Real values of RealType rt referenced by ref.

Throws:
VisADException
RemoteException

VisADSlider

public VisADSlider(String n,
                   int lo,
                   int hi,
                   int st,
                   double scale,
                   DataReference ref,
                   RealType rt,
                   boolean dynamicLabelWidth)
            throws VisADException,
                   RemoteException
JSlider values range between low and hi (with initial value st) and are multiplied by scale to create Real values of RealType rt referenced by ref. The slider label has a dynamically sized width if dynamicLabelWidth is true.

Throws:
VisADException
RemoteException

VisADSlider

public VisADSlider(ScalarMap smap)
            throws VisADException,
                   RemoteException
construct a VisADSlider from a ScalarMap that maps to Display.SelectValue, with auto-scaling minimum and maximum bounds, non-integral values, and a statically sized label.

Throws:
VisADException
RemoteException

VisADSlider

public VisADSlider(ScalarMap smap,
                   boolean integralTicks)
            throws VisADException,
                   RemoteException
construct a VisADSlider from a ScalarMap that maps to Display.SelectValue, with auto-scaling minimum and maximum bounds, either integer or floating-point values, depending on the setting of integralTicks, and a statically sized label.

Throws:
VisADException
RemoteException

VisADSlider

public VisADSlider(ScalarMap smap,
                   boolean integralTicks,
                   boolean dynamicLabelWidth)
            throws VisADException,
                   RemoteException
construct a VisADSlider from a ScalarMap that maps to Display.SelectValue, with auto-scaling minimum and maximum bounds, either integer or floating-point values (depending on the setting of integralTicks, and either a static or dynamically sized label (depending on the setting of dynamicLabelWidth.

Throws:
VisADException
RemoteException

VisADSlider

public VisADSlider(ScalarMap smap,
                   float min,
                   float max)
            throws VisADException,
                   RemoteException
construct a VisADSlider from a ScalarMap that maps to Display.SelectValue, with minimum and maximum bounds min and max, no auto-scaling, non-integer values, and a static label width.

Throws:
VisADException
RemoteException

VisADSlider

public VisADSlider(DataReference ref,
                   float min,
                   float max,
                   float start,
                   RealType rt,
                   String n)
            throws VisADException,
                   RemoteException
construct a VisADSlider by creating a Real and linking it to r, using RealType rt and name n, with minimum and maximum bounds min and max, and starting value start

Throws:
VisADException
RemoteException

VisADSlider

public VisADSlider(DataReference ref,
                   float min,
                   float max)
            throws VisADException,
                   RemoteException
construct a VisADSlider from an existing Real pointed to by r, with minimum and maximum bounds min and max

Throws:
VisADException
RemoteException
Method Detail

hardcodeSizePercent

public void hardcodeSizePercent(int percent)
Hardcode the preferred size of the slider after increasing the current width by the specified percentage (or decreasing it if percent is negative.)

This method is primarily useful to keep changes in the label (of a VisADSlider with dynamicLabelWidth set to true) from causing the rest of the window to be redrawn.

Parameters:
percent - percent of current size to use for hardcoded size. (e.g. to keep the current size, specify 100; to increase the size a bit, specify 115, to decrease it a bit, specify 85, etc.)

stateChanged

public void stateChanged(ChangeEvent e)
called when slider is adjusted

Specified by:
stateChanged in interface ChangeListener

mapChanged

public void mapChanged(ScalarMapEvent e)
used for auto-scaling the minimum and maximum

Specified by:
mapChanged in interface ScalarMapListener
Parameters:
e - the event

controlChanged

public void controlChanged(ScalarMapControlEvent evt)
ScalarMapListener method used to detect new control.

Specified by:
controlChanged in interface ScalarMapListener
Parameters:
evt - the event

controlChanged

public void controlChanged(ControlEvent e)
                    throws VisADException,
                           RemoteException
Update slider when value of linked ValueControl changes

Specified by:
controlChanged in interface ControlListener
Throws:
VisADException
RemoteException