Class ImageCanvas

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----ImageCanvas

public class ImageCanvas
extends Canvas
A canvas that displays an image. In effect, ImageCanvas makes an Image into a Component. Based on class ImageCanvas from "Graphic Java 1.1" p. 262. Java 1.1 Implementation

See Also:
Canvas

Constructor Index

 o ImageCanvas(Image)
Straightforward constructor.

Method Index

 o getImage()
Return the image.
 o getPreferredSize()
The preferred size is the image size.
 o imageUpdate(Image, int, int, int, int, int)
The callback function for image updates.
 o paint(Graphics)
 o update(Graphics)
Update the display screen.

Constructors

 o ImageCanvas
 public ImageCanvas(Image image)
Straightforward constructor. It starts loading the image if it has not already been started. The constructor waits for the image size to be loaded and sets the component size to the image size.

Parameters:
image - the image to display.

Methods

 o getImage
 public Image getImage()
Return the image.

Returns:
the image.
 o getPreferredSize
 public Dimension getPreferredSize()
The preferred size is the image size. This method is called by some LayoutManager's, for example, FlowLayout. The default preferred and default minimum Canvas sizes sre zero; so this method should be overriden. By the Archimedian Property, there exists an image such that any fraction of it is bigger than a reasonably sized Container; so the default minimum Canvas size of zero is best, and the method getMinimumSize() is not overriden.

Returns:
the image size.
Overrides:
getPreferredSize in class Component
See Also:
LayoutManager, Dimension
 o imageUpdate
 public boolean imageUpdate(Image i,
                            int infoflags,
                            int x,
                            int y,
                            int width,
                            int height)
The callback function for image updates. When the image size is already available this method does the default action of repainting the screen. If the image size is not available yet then the info flags are tested and a synchronized code block may be executed to modify the object state.

Returns:
true if further updates are requested.
Overrides:
imageUpdate in class Component
See Also:
waitForImageSize, ImageObserver
 o paint
 public void paint(Graphics g)
Overrides:
paint in class Canvas
 o update
 public void update(Graphics g)
Update the display screen. Modified from the default action to eliminate screen flicker.

Overrides:
update in class Component