org.jscience.swing.spinner
Class SpinnerTimerControl

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 org.jscience.swing.spinner.SpinnerTimerControl
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class SpinnerTimerControl
extends javax.swing.JPanel

This JPanel contains a JSpinner and a TimerControlPanel handling a timer iterating through the SpinnerModel's sequence.

Clicks on the timer's buttons have the following effects:

action left directed arrow button stop button right directed arrow button break button
left mouse click runs the timer backward through the spinner's sequence resets to value 0 if it is in the domain and the SpinnerModel is a SpinnerNumberModel, otherwise does nothing runs the timer forward through the spinner's sequence stops the timer
right mouse click jump to the minimum value of the spinner's sequence (only if the SpinnerModel is a SpinnerNumberModel and a lower limit is set, otherwise the timer if running will stop at the current value) does nothing jump to the maximum value of the spinner's sequence (only if the SpinnerModel is a SpinnerNumberModel and an upper limit is set, otherwise the timer if running will stop at the current value) does nothing

Note:
stop button is only seen, if the timer is not running
break button is only seen, if the timer is running

See Also:
ArrowIcon, SquareIcon, RectanglesIcon, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int HORIZONTAL
          Final variable to adjust the two UI components JSpinner and TimerControlPanel horizontally.
static int VERTICAL
          Final variable to adjust the two UI components JSpinner and TimerControlPanel vertically.
static java.lang.String ZERO_STRING
           
 
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
SpinnerTimerControl()
          Creates a new SpinnerTimerControl with a SpinnerNumberModel as the current SpinnerModel.
SpinnerTimerControl(javax.swing.SpinnerModel spinnerModel)
          Creates a new SpinnerTimerControl with the specified SpinnerModel as the current SpinnerModel.
SpinnerTimerControl(javax.swing.SpinnerModel spinnerModel, int adjustment)
          Creates a new SpinnerTimerControl with the specified SpinnerModel as the current SpinnerModel.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Adds a listener to the list that is notified each time a change to the spinner's model occurs.
protected  void fireStateChanged()
          Sends a ChangeEvent, whose source is this SpinnerTimerControl, to each listener which was added to this SpinnerTimerControl.
 int getLayoutAdjustment()
          Returns the current layout adjustment.
 javax.swing.SpinnerModel getSpinnerModel()
          Returns the current SpinnerModel.
 SharableTimer getTimer()
          Returns the SharableTimer this' TimerControlPanel is using.
 int getTimerDelay()
          Returns the current timer delay in msec.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes a ChangeListener from this SpinnerTimerControl.
 void setLayoutAdjustment(int newAdjustment)
          Sets a new layout adjustment and revalidates this JPanel's component tree.
 void setSpinnerModel(javax.swing.SpinnerModel newModel)
          Sets this' SpinnerModel to the specified one.
 void setTimer(SharableTimer timer)
          Sets a new SharableTimer this' TimerControlPanel should use.
 void setTimerDelay(int newDelay)
          Sets the timer delay (in msec) to newDelay.
 
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
 

Field Detail

HORIZONTAL

public static final int HORIZONTAL
Final variable to adjust the two UI components JSpinner and TimerControlPanel horizontally.

See Also:
SpinnerTimerControl(SpinnerModel,int), Constant Field Values

VERTICAL

public static final int VERTICAL
Final variable to adjust the two UI components JSpinner and TimerControlPanel vertically.

See Also:
SpinnerTimerControl(SpinnerModel,int), Constant Field Values

ZERO_STRING

public static final java.lang.String ZERO_STRING
See Also:
Constant Field Values
Constructor Detail

SpinnerTimerControl

public SpinnerTimerControl()
Creates a new SpinnerTimerControl with a SpinnerNumberModel as the current SpinnerModel. The adjustment of the JSpinner and TimerControlPanel is HORIZONTAL.


SpinnerTimerControl

public SpinnerTimerControl(javax.swing.SpinnerModel spinnerModel)
Creates a new SpinnerTimerControl with the specified SpinnerModel as the current SpinnerModel. The adjustment of the JSpinner and TimerControlPanel is HORIZONTAL.


SpinnerTimerControl

public SpinnerTimerControl(javax.swing.SpinnerModel spinnerModel,
                           int adjustment)
Creates a new SpinnerTimerControl with the specified SpinnerModel as the current SpinnerModel. The int value specifies the adjustment of the UI components JSpinner and TimerControlPanel to each other. Use one of the final fields HORIZONTAL and VERTICAL.

Parameters:
adjustment - HORIZONTAL or VERTICAL.
Method Detail

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Adds a listener to the list that is notified each time a change to the spinner's model occurs.

Parameters:
l - the ChangeListener to add

fireStateChanged

protected void fireStateChanged()
Sends a ChangeEvent, whose source is this SpinnerTimerControl, to each listener which was added to this SpinnerTimerControl. This method is called each time a ChangeEvent is received from the spinner.

See Also:
#addChangeListener(ChangeListenerl)

getLayoutAdjustment

public int getLayoutAdjustment()
Returns the current layout adjustment.

Returns:
the current layout adjustment.

getSpinnerModel

public javax.swing.SpinnerModel getSpinnerModel()
Returns the current SpinnerModel.

Returns:
the current SpinnerModel.
See Also:
setSpinnerModel(SpinnerModel)

getTimer

public SharableTimer getTimer()
Returns the SharableTimer this' TimerControlPanel is using.

Returns:
the SharableTimer of the TimerControlPanel.
See Also:
TimerControlPanel.getTimer()

getTimerDelay

public int getTimerDelay()
Returns the current timer delay in msec.

Returns:
the current timer delay in msec.
See Also:
setTimerDelay(int), Timer.getDelay()

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from this SpinnerTimerControl.

Parameters:
l - the listener to remove.

setLayoutAdjustment

public void setLayoutAdjustment(int newAdjustment)
Sets a new layout adjustment and revalidates this JPanel's component tree. Possible adjustments are: HORIZONTAL, VERTICAL.

Parameters:
newAdjustment - The new layout adjustment.

setSpinnerModel

public void setSpinnerModel(javax.swing.SpinnerModel newModel)
Sets this' SpinnerModel to the specified one.

Parameters:
newModel - The new SpinnerModel.
See Also:
getSpinnerModel()

setTimer

public void setTimer(SharableTimer timer)
Sets a new SharableTimer this' TimerControlPanel should use.

Parameters:
timer - the new Timer.
See Also:
TimerControlPanel.setTimer(SharableTimer)

setTimerDelay

public void setTimerDelay(int newDelay)
Sets the timer delay (in msec) to newDelay.

Parameters:
newDelay - The new timer delay in msec.
See Also:
getTimerDelay()