|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hdcookbook.grin.util.ManagedImage com.hdcookbook.grin.util.HeadlessManagedImage
public class HeadlessManagedImage
This class implements the ManagedImage contract for a headless Java program. It is used in the grin compiler.
Constructor Summary | |
---|---|
HeadlessManagedImage(java.lang.String name)
Create a HeadlessManagedImage instance. |
Method Summary | |
---|---|
void |
draw(java.awt.Graphics2D gr,
int x,
int y,
java.awt.Component comp)
Draw this image into the given graphics context |
void |
drawClipped(java.awt.Graphics2D gr,
int x,
int y,
java.awt.Rectangle subsection,
java.awt.Component comp)
Draw the the given subsection of the image into a graphics context, without scaling. |
void |
drawScaled(java.awt.Graphics2D gr,
java.awt.Rectangle bounds,
java.awt.Component comp)
Draw this image into the given graphics context, scaled to fit within the given bounds. |
int |
getHeight()
Get the height of this image. |
java.lang.String |
getName()
|
int |
getWidth()
Get the width of this image. |
boolean |
hadErrorLoading()
Tells whether or not the image had an error loading, e.g. |
boolean |
isLoaded()
Determine whether or not the image is currently loaded. |
void |
load(java.awt.Component comp)
Load this image for display in the given component, or any other component for the same graphics device. |
void |
prepare()
Prepare this image for display, by registering interest in having the image be loaded. |
void |
startLoading(java.awt.Component comp)
Start loading an image. |
void |
unprepare()
Undo a prepare. |
Methods inherited from class com.hdcookbook.grin.util.ManagedImage |
---|
equals, makeSticky, toString, unmakeSticky |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HeadlessManagedImage(java.lang.String name)
Method Detail |
---|
public java.lang.String getName()
getName
in class ManagedImage
public int getWidth()
ManagedImage
getWidth
in class ManagedImage
public int getHeight()
ManagedImage
getHeight
in class ManagedImage
public void prepare()
load(Component)
must be called.
See ManagedImage's main class documentation under "ManagedImage contract - image loading and unloading".
prepare
in class ManagedImage
ManagedImage.isLoaded()
,
ManagedImage.load(Component)
,
ManagedImage.unprepare()
,
ManagedImage
public boolean isLoaded()
See ManagedImage's main class documentation under "ManagedImage contract - image loading and unloading".
isLoaded
in class ManagedImage
ManagedImage
public boolean hadErrorLoading()
hadErrorLoading
in class ManagedImage
public void load(java.awt.Component comp)
prepare()
. If no interest
has been registered, or if this image is already loaded, then this
method will return immediately. If another thread is loading this
same image, this method will wait until that image load is complete
before it returns.
See ManagedImage's main class documentation under "ManagedImage contract - image loading and unloading". This version works with a null component.
load
in class ManagedImage
comp
- A component to use for loading the image. Clients
using ManagedImage should never pass in null.ManagedImage.prepare()
,
ManagedImage.unprepare()
,
ManagedImage
public void startLoading(java.awt.Component comp)
load(Component)
, except that it doesn't block until
the image is loaded. If the image has a postive prepare()
count, then sometime after startLoading(Component)
is
called, isLoaded()
will return true (unless, of course,
the caller loses interest in the image and calls
unprepare()
This method is useful for loading an image asynchronously when the threading model makes polling for image load a natural thing to do. For example, if one wants to load an image while a show is running, one good way to do that is to start the loading, then poll for the completion of the loading in a once-per-frame "heartbeat" method.
startLoading
in class ManagedImage
ManagedImage.prepare()
,
ManagedImage.unprepare()
,
ManagedImage.load(Component)
,
ManagedImage.isLoaded()
,
ManagedImage
public void unprepare()
See ManagedImage's main class documentation under "ManagedImage contract - image loading and unloading".
unprepare
in class ManagedImage
ManagedImage.prepare()
,
ManagedImage.load(Component)
,
ManagedImage.makeSticky()
,
ManagedImage.unmakeSticky()
,
ManagedImage
public void draw(java.awt.Graphics2D gr, int x, int y, java.awt.Component comp)
draw
in class ManagedImage
public void drawScaled(java.awt.Graphics2D gr, java.awt.Rectangle bounds, java.awt.Component comp)
drawScaled
in class ManagedImage
public void drawClipped(java.awt.Graphics2D gr, int x, int y, java.awt.Rectangle subsection, java.awt.Component comp)
drawClipped
in class ManagedImage
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |