|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sac.ui.SplashScreen
public class SplashScreen
SplashScreen is a general-purpose splash screen for application start-up. Usage is straightforward: simply construct a SplashScreen at the start of main() and call its splash() method. Proceed with start-up as normal. Use showStatus(String) for reporting progress during start-up. Finally, at the end of main() call SplashScreen's dispose() method. By default, the splash loads image splash.gif but you can change this if necessary.
| Field Summary |
|---|
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
SplashScreen()
Constructs SplashScreen using filename "splash.gif" for the image unless you change the default using setImage or call splash with an argument specifying a different image. |
|
SplashScreen(java.lang.String filename)
Constructs SplashScreen using a given filename for the splash image. |
|
SplashScreen(java.net.URL url)
Constructs SplashScreen using a given URL for the splash image. |
|
| Method Summary | |
|---|---|
void |
delayForSplash()
Optimise splash latency by delaying the calling thread according to number of processors available. |
void |
dispose()
Closes the splash screen if open, or abandons splash screen if not already open. |
boolean |
imageUpdate(java.awt.Image img,
int infoflags,
int x,
int y,
int width,
int height)
Runs during image loading. |
static SplashScreen |
instance()
Ensures the class has only one instance and gives a global point of access to it. |
void |
setImage(java.lang.String filename)
Uses the given filename for the splash image. |
void |
setImage(java.net.URL url)
Uses the given URL for the splash image. |
void |
showStatus(java.lang.String s)
Changes the status message just below the image. |
void |
splash()
Starts the asynchronous splash screen using the previously specified image, or using filename "splash.gif" by default if no image yet specified. |
void |
splash(java.awt.Image img)
Splash the screen! Or, in other words, make a splash! Actually, this method merely starts the process of splashing. |
void |
splash(java.lang.String filename)
Starts the asynchronous splash screen using the given filename for the image. |
void |
splash(java.net.URL url)
Starts the asynchronous splash screen using the given URL for the image. |
void |
splashFor(int ms)
Splashes the screen for at least the given number of milliseconds if, and only if, the splash screen has already loaded. |
void |
waitForSplash()
Waits for the splash screen to load, returns when the splash starts. |
void |
waitForSplash(long ms)
Waits for the splash screen to load for a limited amount of time. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SplashScreen(java.lang.String filename)
filename - name of an image filepublic SplashScreen(java.net.URL url)
url - the URL of an imagepublic SplashScreen()
| Method Detail |
|---|
public void setImage(java.lang.String filename)
splash(createImage(... if you want Image privacy.
filename - name of an image filepublic void setImage(java.net.URL url)
url - the URL of an imagepublic void splash(java.lang.String filename)
filename - name of an image filepublic void splash(java.net.URL url)
url - the URL of an imagepublic void splash()
public void splash(java.awt.Image img)
img - the image used for splashing
public boolean imageUpdate(java.awt.Image img,
int infoflags,
int x,
int y,
int width,
int height)
synchronized.
imageUpdate in interface java.awt.image.ImageObserverpublic void showStatus(java.lang.String s)
public void waitForSplash()
Please note following discussion taken from design documentation by R.R.
As a guide, invoke this method at the end of start-up, not the beginning. Waiting for the image to load does not make the image load faster, necessarily. Image loading is an `input bound' process, reading from filesystem or network. Remaining start-up steps are typically `compute bound' and likely compute resource is available for consumption. Most likely, start-up mixes input and compute resource demands, and possibly even output.This guideline applies to uniprocessor as well as multiprocessor platforms. Waiting only wastes any available compute cycles. If you need to delay unnecessarily, do this at the end when there is nothing left to do. Even so, this practice can be viewed as user interface cruft! Please use with care.
public void waitForSplash(long ms)
ms - milliseconds to wait forpublic void delayForSplash()
public void splashFor(int ms)
Why is this method synchronized? In order to
avoid a race condition. It accesses the splashTime attribute
which updates in another thread.
ms - milliseconds of minimum splashpublic void dispose()
Implementation note.
If you dispose too fast, this method could coincide with
splashScreen(). We cannot now preempt the other thread. It
needs synchronisation. This situation and its requirement
proves inevitable when two threads access the same thing. For
this reason, methods dispose() and splashScreen() share the
synchronized attribute.
public static SplashScreen instance()
The implementation actually mixes singleton and non-singleton patterns. (Tempting to call it Multiton but that refers to a variation of Singleton where the instance has many multiplicity instead of unity.) Correctly applying the Singleton pattern requires closing access to constructor methods. However, SplashScreen retains public constructors, so compromises the pattern. You can follow Singleton usage or not at your own discretion.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||