com.tecnick.jrelaxtimer
Class JRelaxTimer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by com.tecnick.jrelaxtimer.JRelaxTimer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, javax.accessibility.Accessible

public class JRelaxTimer
extends java.applet.Applet
implements java.lang.Runnable

Title: JRelaxTimer
Description: Applet to display timer that allows you to open Web pages at specific time intervals

Copyright (c) 2002-2006 Tecnick.com S.r.l (www.tecnick.com) Via Ugo Foscolo n.19 - 09045 Quartu Sant'Elena (CA) - ITALY - www.tecnick.com - info@tecnick.com
Project homepage: http://jxhtmledit.sourceforge.net
License: http://www.gnu.org/copyleft/gpl.html GPL 2

Version:
1.0.001
Author:
Nicola Asuni [www.tecnick.com].
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
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
(package private)  java.applet.Applet a
          only final variables can be used in inner anonymous classes
private  java.awt.Choice break_type_selector
          selector for break type
(package private)  java.lang.String[][] break_types
          array containing break types information
private  ImageButton button_break
          break button
private  ImageButton button_pause
          pause button
private  ImageButton button_play
          play button
private  ImageButton button_stop
          stop button
private  int current_break
          count breaks
 int current_break_type
          type of break index
 int current_interval
          time interval in minutes
private  DisplayPanel dpanel_counter
          display panel to count breaks
private  DisplayPanel dpanel_current_time
          display panel for current time (clock)
private  DisplayPanel dpanel_elapsed
          display panel to show elapsed time since start
private  DisplayPanel dpanel_next
          display panel to show remaining time to next break
private  DisplayPanel dpanel_started
          display panel for starting time
private  long dtarget
          time to next break
private  java.text.SimpleDateFormat formatter
          /** date formatter
private  java.awt.Choice interval_selector
          selector for interval
(package private)  java.lang.String[] intervals
          array containing intervals values
private static java.lang.String JRELAXTIMER_VERSION
          Software version
private  java.util.Date now
          current time
private  java.awt.Color p_background_color
          background color for applet
private  java.awt.Color p_background_color_counter
          background color (RRGGBB) for break counter display
private  java.awt.Color p_background_color_current_time
          background color (RRGGBB) for current time display
private  java.awt.Color p_background_color_elapsed
          background color (RRGGBB) for elapsed time display
private  java.awt.Color p_background_color_next
          background color (RRGGBB) for remaining time to next break display
private  java.awt.Color p_background_color_started
          background color (RRGGBB) for staring time display
private  java.awt.Image p_background_image_counter
          background image for break counter display
private  java.awt.Image p_background_image_current_time
          background image for current time display
private  java.awt.Image p_background_image_elapsed
          background image for elapsed time display
private  java.awt.Image p_background_image_next
          background image for remaining time to next break display
private  java.awt.Image p_background_image_started
          background image for staring time display
private  java.lang.String p_counter_pattern
          the break counter pattern
private  boolean p_display_counter
          if true show the counter display
private  boolean p_display_current_time
          if true show the current time display
private  boolean p_display_elapsed
          if true show the elapsed time display
private  boolean p_display_next
          if true show the remaining time display
private  java.lang.String p_display_pattern
          the full datetime pattern
private  boolean p_display_started
          if true show the starting time display
private  java.awt.Image p_img_break_off
          break button image for inactive state
private  java.awt.Image p_img_break_on
          break button image for active state
private  java.awt.Image p_img_break_over
          break button image for mouse over state
private  java.awt.Image[] p_img_counter
          number and symbols images
private  java.awt.Image[] p_img_current_time
          number and symbols images
private  java.lang.String p_img_dir_buttons
          dicrectory where are stored images for buttons
private  java.lang.String p_img_dir_counter
          dicrectory where are stored images for break counter display
private  java.lang.String p_img_dir_current_time
          dicrectory where are stored images for current time display
private  java.lang.String p_img_dir_elapsed
          dicrectory where are stored images for elapsed time display
private  java.lang.String p_img_dir_next
          dicrectory where are stored images for remaining time display
private  java.lang.String p_img_dir_started
          dicrectory where are stored images for starting time display
private  java.awt.Image[] p_img_elapsed
          number and symbols images
private  java.awt.Image[] p_img_next
          number and symbols images
private  java.awt.Image p_img_pause_off
          pause button image for inactive state
private  java.awt.Image p_img_pause_on
          stop button image for active state
private  java.awt.Image p_img_pause_over
          pause button image for mouse over state
private  java.awt.Image p_img_play_off
          play button image for inactive state
private  java.awt.Image p_img_play_on
          play button image for active state
private  java.awt.Image p_img_play_over
          play button image for mouse over state
private  java.awt.Image[] p_img_started
          number and symbols images
private  java.awt.Image p_img_stop_off
          stop button image for inactive state
private  java.awt.Image p_img_stop_on
          stop button image for active state
private  java.awt.Image p_img_stop_over
          stop button image for mouse over state
private  java.awt.Image p_logo_image
          logo image
private  java.lang.String p_logo_url
          url of the company (link associated with logo image)
private  java.lang.String p_page_extension
          extension of the break pages to call
private  java.lang.String p_remaining_pattern
          the remaining time pattern
private  java.lang.String p_target_url
          target url of the page to open for breaks
private  boolean pause_status
          current status is true when timer is running
private  boolean play_status
          current status is true when timer is running
private  long remaining_time
          remaining time to next break
private static int SECONDS_IN_DAY
          CONSTANT: number of seconds in one day
private static int SECONDS_IN_HOUR
          CONSTANT: number of seconds in one hour
private static int SECONDS_IN_MINUTE
          CONSTANT: number of seconds in one minute
private static int SECONDS_IN_MONTH
          CONSTANT: number of seconds in one month
private static int SECONDS_IN_YEAR
          CONSTANT: number of seconds in one year
private static long serialVersionUID
          serialVersionUID
private static int SLEEP_TIME
          sleep time in milliseconds between two successive call to display function
private  java.util.Date start_time
          starting time
private  int time_interval
          time interval in milliseconds
(package private)  java.lang.Thread timer
          The thread that displays clock
private  java.util.TimeZone tz
          Time zone
 
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
JRelaxTimer()
          Applet void constructor
 
Method Summary
 void destroy()
          Destroy the applet
 java.lang.String getAppletInfo()
          Get Applet information.
private  java.lang.String getParameter(java.lang.String key, java.lang.String def)
          Get applet parameter value, return default if void.
private  void getParameters()
          Get the applet parameters.
 void init()
          Initialize the applet
private static java.awt.Image loadImage(java.applet.Applet a, java.net.URL file)
          Load an image.
private  java.lang.String millisecToPattern(long millisecs, java.lang.String tmppattern)
          Convert milliseconds to date pattern format.
private  java.lang.String numberToPattern(long number, java.lang.String tmppattern)
          Convert number to pattern format.
 void run()
          run
private  java.net.URL setURL(java.lang.String link)
          Computes full, canonical URL from a relative specification.
private  java.lang.String[] splitData(java.lang.String input_string, char sep_ch)
          Split a string in array of predefined size.
 void start()
          Start the timers reset the timers and counters
 void stop()
          Stop the applet
private  void TakeBreak()
          execute the break opening a popup page call the specified URL passing the following parameters: t for the type of break b the current break number i the time interval
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, 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

serialVersionUID

private static final long serialVersionUID
serialVersionUID

See Also:
Constant Field Values

JRELAXTIMER_VERSION

private static final java.lang.String JRELAXTIMER_VERSION
Software version

See Also:
Constant Field Values

timer

java.lang.Thread timer
The thread that displays clock


dpanel_started

private DisplayPanel dpanel_started
display panel for starting time


dpanel_current_time

private DisplayPanel dpanel_current_time
display panel for current time (clock)


dpanel_elapsed

private DisplayPanel dpanel_elapsed
display panel to show elapsed time since start


dpanel_next

private DisplayPanel dpanel_next
display panel to show remaining time to next break


dpanel_counter

private DisplayPanel dpanel_counter
display panel to count breaks


a

final java.applet.Applet a
only final variables can be used in inner anonymous classes


p_target_url

private java.lang.String p_target_url
target url of the page to open for breaks


p_logo_url

private java.lang.String p_logo_url
url of the company (link associated with logo image)


p_counter_pattern

private java.lang.String p_counter_pattern
the break counter pattern


p_remaining_pattern

private java.lang.String p_remaining_pattern
the remaining time pattern


p_display_pattern

private java.lang.String p_display_pattern
the full datetime pattern


p_display_counter

private boolean p_display_counter
if true show the counter display


p_display_started

private boolean p_display_started
if true show the starting time display


p_display_current_time

private boolean p_display_current_time
if true show the current time display


p_display_elapsed

private boolean p_display_elapsed
if true show the elapsed time display


p_display_next

private boolean p_display_next
if true show the remaining time display


p_background_color

private java.awt.Color p_background_color
background color for applet


p_background_color_started

private java.awt.Color p_background_color_started
background color (RRGGBB) for staring time display


p_background_color_current_time

private java.awt.Color p_background_color_current_time
background color (RRGGBB) for current time display


p_background_color_elapsed

private java.awt.Color p_background_color_elapsed
background color (RRGGBB) for elapsed time display


p_background_color_next

private java.awt.Color p_background_color_next
background color (RRGGBB) for remaining time to next break display


p_background_color_counter

private java.awt.Color p_background_color_counter
background color (RRGGBB) for break counter display


p_logo_image

private java.awt.Image p_logo_image
logo image


p_background_image_started

private java.awt.Image p_background_image_started
background image for staring time display


p_background_image_current_time

private java.awt.Image p_background_image_current_time
background image for current time display


p_background_image_elapsed

private java.awt.Image p_background_image_elapsed
background image for elapsed time display


p_background_image_next

private java.awt.Image p_background_image_next
background image for remaining time to next break display


p_background_image_counter

private java.awt.Image p_background_image_counter
background image for break counter display


p_img_dir_started

private java.lang.String p_img_dir_started
dicrectory where are stored images for starting time display


p_img_dir_current_time

private java.lang.String p_img_dir_current_time
dicrectory where are stored images for current time display


p_img_dir_elapsed

private java.lang.String p_img_dir_elapsed
dicrectory where are stored images for elapsed time display


p_img_dir_next

private java.lang.String p_img_dir_next
dicrectory where are stored images for remaining time display


p_img_dir_counter

private java.lang.String p_img_dir_counter
dicrectory where are stored images for break counter display


p_img_dir_buttons

private java.lang.String p_img_dir_buttons
dicrectory where are stored images for buttons


p_img_started

private java.awt.Image[] p_img_started
number and symbols images


p_img_current_time

private java.awt.Image[] p_img_current_time
number and symbols images


p_img_elapsed

private java.awt.Image[] p_img_elapsed
number and symbols images


p_img_next

private java.awt.Image[] p_img_next
number and symbols images


p_img_counter

private java.awt.Image[] p_img_counter
number and symbols images


p_img_pause_off

private java.awt.Image p_img_pause_off
pause button image for inactive state


p_img_pause_over

private java.awt.Image p_img_pause_over
pause button image for mouse over state


p_img_pause_on

private java.awt.Image p_img_pause_on
stop button image for active state


p_img_stop_off

private java.awt.Image p_img_stop_off
stop button image for inactive state


p_img_stop_over

private java.awt.Image p_img_stop_over
stop button image for mouse over state


p_img_stop_on

private java.awt.Image p_img_stop_on
stop button image for active state


p_img_play_off

private java.awt.Image p_img_play_off
play button image for inactive state


p_img_play_over

private java.awt.Image p_img_play_over
play button image for mouse over state


p_img_play_on

private java.awt.Image p_img_play_on
play button image for active state


p_img_break_off

private java.awt.Image p_img_break_off
break button image for inactive state


p_img_break_over

private java.awt.Image p_img_break_over
break button image for mouse over state


p_img_break_on

private java.awt.Image p_img_break_on
break button image for active state


now

private java.util.Date now
current time


start_time

private java.util.Date start_time
starting time


dtarget

private long dtarget
time to next break


remaining_time

private long remaining_time
remaining time to next break


formatter

private java.text.SimpleDateFormat formatter
/** date formatter


button_pause

private ImageButton button_pause
pause button


button_stop

private ImageButton button_stop
stop button


button_play

private ImageButton button_play
play button


button_break

private ImageButton button_break
break button


tz

private java.util.TimeZone tz
Time zone


SECONDS_IN_MINUTE

private static final int SECONDS_IN_MINUTE
CONSTANT: number of seconds in one minute

See Also:
Constant Field Values

SECONDS_IN_HOUR

private static final int SECONDS_IN_HOUR
CONSTANT: number of seconds in one hour

See Also:
Constant Field Values

SECONDS_IN_DAY

private static final int SECONDS_IN_DAY
CONSTANT: number of seconds in one day

See Also:
Constant Field Values

SECONDS_IN_MONTH

private static final int SECONDS_IN_MONTH
CONSTANT: number of seconds in one month

See Also:
Constant Field Values

SECONDS_IN_YEAR

private static final int SECONDS_IN_YEAR
CONSTANT: number of seconds in one year

See Also:
Constant Field Values

SLEEP_TIME

private static final int SLEEP_TIME
sleep time in milliseconds between two successive call to display function

See Also:
Constant Field Values

play_status

private boolean play_status
current status is true when timer is running


pause_status

private boolean pause_status
current status is true when timer is running


current_break

private int current_break
count breaks


current_interval

public int current_interval
time interval in minutes


time_interval

private int time_interval
time interval in milliseconds


intervals

java.lang.String[] intervals
array containing intervals values


break_types

java.lang.String[][] break_types
array containing break types information


current_break_type

public int current_break_type
type of break index


p_page_extension

private java.lang.String p_page_extension
extension of the break pages to call


break_type_selector

private java.awt.Choice break_type_selector
selector for break type


interval_selector

private java.awt.Choice interval_selector
selector for interval

Constructor Detail

JRelaxTimer

public JRelaxTimer()
Applet void constructor

Method Detail

loadImage

private static java.awt.Image loadImage(java.applet.Applet a,
                                        java.net.URL file)
Load an image.

Parameters:
a - applet
file - image file URL
Returns:
loadImage

getParameter

private java.lang.String getParameter(java.lang.String key,
                                      java.lang.String def)
Get applet parameter value, return default if void.

Parameters:
key - name of parameter to read
def - default value
Returns:
parameter value or default

setURL

private java.net.URL setURL(java.lang.String link)
Computes full, canonical URL from a relative specification.

Parameters:
link - string containing URL
Returns:
canonical URL

getParameters

private void getParameters()
Get the applet parameters.


splitData

private java.lang.String[] splitData(java.lang.String input_string,
                                     char sep_ch)
Split a string in array of predefined size.

Parameters:
input_string - string to split
sep_ch - separator character
Returns:
splitted_array of strings

init

public void init()
Initialize the applet

Overrides:
init in class java.applet.Applet

TakeBreak

private void TakeBreak()
execute the break opening a popup page call the specified URL passing the following parameters: t for the type of break b the current break number i the time interval


start

public void start()
Start the timers reset the timers and counters

Overrides:
start in class java.applet.Applet

stop

public void stop()
Stop the applet

Overrides:
stop in class java.applet.Applet

destroy

public void destroy()
Destroy the applet

Overrides:
destroy in class java.applet.Applet

run

public void run()
run

Specified by:
run in interface java.lang.Runnable

millisecToPattern

private java.lang.String millisecToPattern(long millisecs,
                                           java.lang.String tmppattern)
Convert milliseconds to date pattern format.

Parameters:
millisecs - time to convert (milliseconds)
tmppattern - string pattern to apply
Returns:
String representation of time

numberToPattern

private java.lang.String numberToPattern(long number,
                                         java.lang.String tmppattern)
Convert number to pattern format.

Parameters:
number - num,ber to display
tmppattern - string pattern to apply
Returns:
String representation of number

getAppletInfo

public java.lang.String getAppletInfo()
Get Applet information.

Overrides:
getAppletInfo in class java.applet.Applet
Returns:
applet info