Sleepbot.com Java Classes

com.sleepbot.WRLDtime.time
Interface WRLDtimePiece

All Known Implementing Classes:
WRLDtime, WRLDtimePieceNoOp

public interface WRLDtimePiece

An interface which defines everything you'll need to create a custom WRLDtime time-piece.
 
An implementing class can be used by both WRLDtimeApp and WRLDtimeApplet. Depending upon its owner's context, your time-piece will provide Frame or Applet functionality. In terms of time-keeping and rendering, they'll be largely similar.
 
The best example of how to provide such an implementation is the WRLDtime class. There's also a no-op implementing class; WRLDtimePieceNoOp.
 
For more information, please see the general documentation at Sleepbot.com.
 
version 1.3 - 01Jan05 - Daniel M Foley
version 1.0 - 15Feb98 - Daniel M Foley


Method Summary
 void destroy()
          This routine is called by the owner just before it destroys itself.
 void init(WRLDcron cron, java.applet.Applet a)
          This routine is called during initialization by an owning applet (eg. WRLDtimeApplet).
 void init(WRLDcron cron, java.awt.Frame f, java.lang.String[] args)
          This routine is called during initialization by an owning application (eg. WRLDtimeApp) which has constructed a Frame.
 void init(WRLDcron cron, java.lang.String[] args)
          This routine is called during initialization by a simple owning application.
 boolean isLoaded()
          This routine is called when the owner needs to know if all resources (images, configuration files, etc) have been loaded.
 boolean isPaintable()
          This routine is called when the owner needs to know if this class is ready to paint itself or not.
 void paint(java.awt.Graphics g, java.awt.Dimension d)
          This routine is called when the owner wants you to paint yourself.
 void start(WRLDcron cron)
          This routine is called by the owner just before its thread starts up.
 void stop(WRLDcron cron)
          This routine is called by the owner just before its thread stops.
 void tick(WRLDcron cron)
          This routine is called when the owner's chronometer has been incremented.
 void waiting(WRLDcron cron)
          This routine is called within the owner's inner time-keeping loop.
 

Method Detail

init

public void init(WRLDcron cron,
                 java.applet.Applet a)
This routine is called during initialization by an owning applet (eg. WRLDtimeApplet).
 
This generally that happens once, when the applet is first loaded into the browser (eg. during its own init() routine). This is a good time to set up instance variables, allocate dynamic storage, etc.
 

Parameters:
cron - a WRLDcron object which is maintained by the owner.
a - the owning Applet itself

init

public void init(WRLDcron cron,
                 java.awt.Frame f,
                 java.lang.String[] args)
This routine is called during initialization by an owning application (eg. WRLDtimeApp) which has constructed a Frame.
 
This generally that happens once, when the application first starts. This is a good time to set up instance variables, allocate dynamic storage, etc.
 

Parameters:
cron - a WRLDcron object which is maintained by the owner.
f - the Frame into which the time-piece will be rendered
args - the raw command line arguments from the application, in case you want them

init

public void init(WRLDcron cron,
                 java.lang.String[] args)
This routine is called during initialization by a simple owning application.
 
This method would be called by an application that does NOT have a display Frame. Most likely, we're talking about a command-line app that just dumps to stdout. Even though WRLDtimeNow does not invoke this method, it's a viable consideration.
 
This generally that happens once, when the application first starts. This is a good time to set up instance variables, allocate dynamic storage, etc.
 

Parameters:
cron - a WRLDcron object which is maintained by the owner.
args - the raw command line arguments from the application, in case you want them

destroy

public void destroy()
This routine is called by the owner just before it destroys itself.
 
This is a good time to clean up after yourself


start

public void start(WRLDcron cron)
This routine is called by the owner just before its thread starts up.
 
This method is always called at some time after the appropriate init() method has completed. In an application, it is called once, just after start-up. In an applet, it's called every time you refresh the page. This is a good time to complete your pre-run preparations.
 

Parameters:
cron - a WRLDcron object which is maintained by the owner.

stop

public void stop(WRLDcron cron)
This routine is called by the owner just before its thread stops.
 
This method is always called shortly before the destroy() method is invoked. In an application, it's called once, just before termination. In an applet, it's called every time you refresh the page. Basically, just stop everything you were doing to keep time.
 

Parameters:
cron - a WRLDcron object which is maintained by the owner.

waiting

public void waiting(WRLDcron cron)
This routine is called within the owner's inner time-keeping loop.
 
The chronometer has not changed since the last tick(WRLDcron); the owner is just keeping time. If there's anything you need to do while waiting, here's where to do it.
 

Parameters:
cron - a WRLDcron object which is maintained by the owner.

tick

public void tick(WRLDcron cron)
This routine is called when the owner's chronometer has been incremented.
 
All of the owner's waiting(WRLDcron) has paid off and there's a new WRLDtime code to be leveraged. The paint(Graphics, Dimension) does NOT receive a WRLDcron object, so this is your opportunity to take a snapshot (eg. WRLDcronTick) of the current time code. This is an intentional optimization; paint requests and new time codes are completely asynchronous events.
 

Parameters:
cron - a WRLDcron object which is maintained by the owner.

paint

public void paint(java.awt.Graphics g,
                  java.awt.Dimension d)
This routine is called when the owner wants you to paint yourself.
 
This event happens whenever the owner's render model chooses to fire it off. This is the time to render the current WRLDtime code, as remembered from the last tick(WRLDcron) event.
 

Parameters:
g - a Graphics object for drawing
d - the Dimension of the display area

isPaintable

public boolean isPaintable()
This routine is called when the owner needs to know if this class is ready to paint itself or not.
 
If this method returns false, the owner will display the standard "WRLDtime" logo instead.
 

Returns:
true if this class is ready to handle paint requests, false otherwise

isLoaded

public boolean isLoaded()
This routine is called when the owner needs to know if all resources (images, configuration files, etc) have been loaded.
 
If this method returns false, the owner will perform patient ticks rather than dedicated ones (ie. less accuracy) That in turn will increase the performance of the loading process.
 

Returns:
true if this class has loaded all of its resources, false otherwise

Sleepbot.com Java Classes

Copyright 1995-..   Lookit the Cat Productions