|
EchoPoint 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nextapp.echo.AbstractImageReference nextapp.echo.StreamImageReference echopoint.image.EncodedImageReference
The EncodedImageReference
class is an ImageReference that
can render java.awt.Image
objects. The ImageEncoder
used to encode the image data is pluggable.
This class allows you to balance memory usage versus processor usage.
By default the output of the encoding is not kept in memory, so the encoding runs every time the image needs to be rendered. However this can be changed so that the encoding results are kept in memory.
If the image data is cached, they are kept in a SoftReference
so
they may be reclaimed by the GC if memory gets low.
The AWT Image object that is renderered is by default kept in memory. You can
change this by deriving a new class from EncodedImageReference
and then
drawing the AWT image on as needed basis during the call to getImage()
.
Field Summary |
Fields inherited from class nextapp.echo.AbstractImageReference |
listenerList |
Fields inherited from interface nextapp.echo.ImageReference |
SIZE_UNKNOWN |
Constructor Summary | |
EncodedImageReference()
Constructs an EncodedImageReference without an image. |
|
EncodedImageReference(java.awt.Image image)
Constructs an EncodedImageReference with an image. |
Method Summary | |
java.lang.String |
getContentType()
|
ImageEncoder |
getEncoder()
Returns the ImageEncoder in use. |
int |
getHeight()
This returns the height of the Image |
java.awt.Image |
getImage()
Returns the Image in use.
|
int |
getWidth()
This returns the width of the Image |
boolean |
isKeptInMemory()
Returns true if the encoded image is cached in memory. |
boolean |
isValid()
This returns whether the AWT Image data is currently valid. |
void |
render(java.io.OutputStream out)
|
void |
setEncoder(ImageEncoder encoder)
Sets the ImageEncoder to use for encoding |
void |
setImage(java.awt.Image image)
Sets the Image to encode. |
void |
setKeptInMemory(boolean b)
If set to true, the image will be encoded only as necessary and then cached in memory, otherwise it will be encoded as required. |
void |
setValid(boolean valid)
This controls whether the AWT Image data is currently valid. |
void |
update()
|
Methods inherited from class nextapp.echo.AbstractImageReference |
addImageUpdateListener, removeImageUpdateListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EncodedImageReference()
EncodedImageReference
without an image. You
must of course call setImage()
before the image is rendered,
otherwise there will be nothing to render.
Another alternative would be to derive a new class and override
getImage()
to provide the image as necessary. This
will use a smallest amount of memory at the expense of more CPU processing.
public EncodedImageReference(java.awt.Image image)
EncodedImageReference
with an image.
image
- A java.awt.Image to be displayed. If you intend to extend
this class and override the getImage() method to return images
only as they are needed, then you may pass null to this parameter.Method Detail |
public java.lang.String getContentType()
StreamImageReference.getContentType()
public ImageEncoder getEncoder()
ImageEncoder
in use.
public int getHeight()
getHeight
in interface nextapp.echo.ImageReference
ImageReference.getHeight()
public java.awt.Image getImage()
Image
in use.
You may extend this class and override this method such that images are created only when they are needed, thereby reducing memory usage at the cost of increased processor workload.
public int getWidth()
getWidth
in interface nextapp.echo.ImageReference
ImageReference.getWidth()
public boolean isKeptInMemory()
public boolean isValid()
public void render(java.io.OutputStream out) throws java.io.IOException
java.io.IOException
StreamImageReference.render(java.io.OutputStream)
public void setEncoder(ImageEncoder encoder)
ImageEncoder
to use for encoding
encoder
- public void setImage(java.awt.Image image)
Image
to encode. This can be null.
image
- - the AWT Image to encode.public void setKeptInMemory(boolean b)
b
- public void setValid(boolean valid)
This is used to determine whether a call to getImage()
should be made. If the
encoded image is kept in memory but the image is invalid, then it will
be encoded again. If it valid, then the cached encoded image data can be re-used.
If you derive a new class and override the getImage() method, you should set this to false when the image needs to be re-painted.
valid
- - true if the AWT image data is valid.public void update()
update
in interface nextapp.echo.ImageReference
ImageReference.update()
|
EchoPoint 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |