|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
com.ccg.awt.ImageViewer
public class ImageViewer
Simple lightweight component to display a image.
The component is intended to display a bitmap in a window. Currently, it simply blits the image starting at the coordinates (0,0). However, as it is used more and more in the future, other capabilities will be added including:
text when
the image is not yet available (or set) for
display (this is implemented now).
This class was originally create to test out the ImageHolder class. The sample program, Viewer.java has been provided to
demonstrate its usage. Viewer.html has also been provided
so you can see what it looks like in an applet.
ImageHolder,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| 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 | |
|---|---|
ImageViewer()
Initializes such that there is no image/text to display. |
|
| Method Summary | |
|---|---|
Image |
getImage()
Get the displayed image |
String |
getText()
Get the status message to display |
boolean |
imageUpdate(Image im,
int flags,
int x,
int y,
int w,
int h)
Our implementation of the ImageObserver. |
void |
paint(Graphics g)
Paints the image or text. |
void |
setImage(Image val)
Set the displayed image |
void |
setText(String val)
Set the status message to display |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ImageViewer()
image and/or
text to display.
setImage(java.awt.Image)| Method Detail |
|---|
public void setImage(Image val)
val - New Image value to assign.getImage()public Image getImage()
setImage(java.awt.Image)public void setText(String val)
val - New String value to assign.getText()public String getText()
setText(java.lang.String)public void paint(Graphics g)
image or text.
This method is called when the component needs to paint
itself. If a image object has been assigned and is ready for display, it will be displayed. If
there isn't an image ready for display, then the current text associated with the object (its status) will be
displayed centered in the objects area.
paint in class Componentg - Standard Graphics object to do the drawing onto.setImage(java.awt.Image)
public boolean imageUpdate(Image im,
int flags,
int x,
int y,
int w,
int h)
ImageObserver.
Since images can take time to load, this component registers
itself as an observer of its associated image object. When the image loader determines that the
image is fully loaded, it will invoke this method and we will
then repaint ourselves to display the image to the user.
imageUpdate in interface ImageObserverimageUpdate in class Componentim - Image which new information is available.flags - Current state of image loading (we look for ImageObserver.ALLBITS)x - We ignore this.y - We ignore this.w - We ignore this.h - We ignore this.
paint(java.awt.Graphics)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||