krut.KRUT_GUI
Class KrutTimer

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 krut.KRUT_GUI.KrutTimer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class KrutTimer
extends javax.swing.JPanel

A class used as a timer to start the Krut program. The KrutTimer is a JPanel that when displayed sits below the main window of the Krut program. It can be used to program Krut to start and stop recording at given offset times, or at given system calendar clock times.

See Also:
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int COUNTDOWN
          The countdown mode for the KrutTimer.
static int COUNTUP
          The countup mode for the KrutTimer.
static int NOT_ACTIVE
          The not active state for the KrutTimer.
static int RECORDING
          The recording state for the KrutTimer.
 javax.swing.Timer timer
          Timer used to count down to recording start/stop.
static int WAITING
          The waiting state for the KrutTimer.
 
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
KrutTimer(javax.swing.JFrame GUI)
          Creates new KrutTimer.
 
Method Summary
 void disableToggleButton()
          Disables the "Activate Timer" togglebutton.
 void enableToggleButton()
          Enables the "Activate Timer" togglebutton.
 int getHours(int seconds)
          Returns the number of whole hours in a time given in seconds.
 int getMinutes(int seconds)
          Returns the number of whole minutes in a time given in seconds.
 int getMode()
          Returns the mode of the timer, either COUNTDOWN or COUNTUP.
 int getSeconds(int hours, int minutes, int seconds)
          Gives the number of seconds in the time given in the input parameters.
 int getState()
          Returns the state of the timer, either NOT_ACTIVE, RECORDING or WAITING.
 javax.swing.JToggleButton getTimerButton()
          This method returns the toggle button that activates the timer, so that the user can decide what to do when the timer is activated.
 void initTimer(int msDelay)
          This initializes the timer, and makes it start to keep track of the calendar time.
 void setMainGUI(javax.swing.JFrame GUI)
          This is used to give the KrutTimer direct access to the main GUI, for easy communication.
 void setMode(int newMode)
          Sets the mode of the KrutTimer.
 void setOutput(OutputText output)
          Used to set the output window for this KrutTimer.
 void startTimer()
          Start the KrutTimer
 void stopTimer()
          Stop the KrutTimer
 void updateToggleButton()
          Controls if the "Activate Timer"-buttons should be enabled or disabled.
 
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, 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, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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

timer

public javax.swing.Timer timer
Timer used to count down to recording start/stop.


COUNTDOWN

public static final int COUNTDOWN
The countdown mode for the KrutTimer.

See Also:
Constant Field Values

COUNTUP

public static final int COUNTUP
The countup mode for the KrutTimer.

See Also:
Constant Field Values

NOT_ACTIVE

public static final int NOT_ACTIVE
The not active state for the KrutTimer.

See Also:
Constant Field Values

WAITING

public static final int WAITING
The waiting state for the KrutTimer.

See Also:
Constant Field Values

RECORDING

public static final int RECORDING
The recording state for the KrutTimer.

See Also:
Constant Field Values
Constructor Detail

KrutTimer

public KrutTimer(javax.swing.JFrame GUI)
Creates new KrutTimer.

Parameters:
GUI - The JFrame that this KrutTimer is being drawn in.
Method Detail

setMainGUI

public void setMainGUI(javax.swing.JFrame GUI)
This is used to give the KrutTimer direct access to the main GUI, for easy communication.


setOutput

public void setOutput(OutputText output)
Used to set the output window for this KrutTimer.

Parameters:
output - An OutputText object that this KrutTimer can use for its output.

initTimer

public void initTimer(int msDelay)
This initializes the timer, and makes it start to keep track of the calendar time. After this is done, the startTimer method must be called to start the KrutTimer, and the stopTimer method will stop the KrutTimer.

Parameters:
msDelay - The delay in ms between each update for the timer.

startTimer

public void startTimer()
Start the KrutTimer


stopTimer

public void stopTimer()
Stop the KrutTimer


setMode

public void setMode(int newMode)
Sets the mode of the KrutTimer. The mode should be set to either COUNTDOWN or COUNTUP. COUNTDOWN means that the timer will count down the number of hours, minutes and seconds given in the start-time in the GUI before starting to record, and then count down the time given in the stop-time in the GUI before stopping recording. COUNTUP means that the timer will start recording when the system clock reaches the time given in the start-time in the GUI, and stop recording when the system time reaches the stop-time given in the GUI.

Parameters:
newMode - An integer containing either COUNTDOWN or COUNTUP.

getHours

public int getHours(int seconds)
Returns the number of whole hours in a time given in seconds.

Parameters:
seconds - The total number of seconds
Returns:
The total number of whole hours.

getMinutes

public int getMinutes(int seconds)
Returns the number of whole minutes in a time given in seconds.

Parameters:
seconds - The total number of seconds
Returns:
The total number of whole minutes.

getSeconds

public int getSeconds(int hours,
                      int minutes,
                      int seconds)
Gives the number of seconds in the time given in the input parameters.

Parameters:
hours - The number of hours
minutes - The number of minutes
seconds - The number of seconds
Returns:
The total number of seconds.

updateToggleButton

public void updateToggleButton()
Controls if the "Activate Timer"-buttons should be enabled or disabled. It should be enabled if the given starting time of recording is more than 0s into the future. This method also enables or disables the button based on the results. This method also makes sure that the toggleButton is selected when the timer is activated and deselected when the timer not activated.


disableToggleButton

public void disableToggleButton()
Disables the "Activate Timer" togglebutton.


enableToggleButton

public void enableToggleButton()
Enables the "Activate Timer" togglebutton.


getTimerButton

public javax.swing.JToggleButton getTimerButton()
This method returns the toggle button that activates the timer, so that the user can decide what to do when the timer is activated. The following ActionEvents will be fired to all ActionListeners on the button: Action: Action name: Timer activated "Timer active" Recording started "Timer recording" Recording stopped "Timer stopped"

Returns:
the JToggleButton that activates the timer.

getMode

public int getMode()
Returns the mode of the timer, either COUNTDOWN or COUNTUP.

Returns:
The mode of the timer.

getState

public int getState()
Returns the state of the timer, either NOT_ACTIVE, RECORDING or WAITING.

Returns:
The state of the timer.