Sharkysoft home

lava.gui
Class ImageCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--lava.gui.SizedCanvas
                    |
                    +--lava.gui.ImageCanvas
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class ImageCanvas
extends lava.gui.SizedCanvas

SizedCanvas that displays an Image.

Details: An ImageCanvas is a SizedCanvas that displays a single image. The image can be centered (default) or flush against the canvas' sides or corners, or stretched horizontally and/or vertically to span the entire canvas. ImageCanvas supports animated images, such as animated GIFs.

Since:
1998.09.17
Version:
1999.04.21
See Also:
Serialized Form

Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  int alignment
          Image alignment.
protected  java.awt.Image image
          The Image displayed in this Canvas.
protected  java.awt.Dimension max_size
          The maximum size of this Canvas.
protected  java.awt.Dimension min_size
          The minimum size of this Canvas.
protected  java.awt.Point position
          Image position.
protected  java.awt.Dimension pref_size
          The preferred size of this Canvas.
protected  java.awt.Dimension size
          Image size.
 
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
ImageCanvas(java.awt.Dimension dim, java.awt.Image image)
          Initializes this ImageCanvas to have the given dimension and image content.
ImageCanvas(java.awt.Dimension dim, java.awt.Image image, int alignment)
          Initializes this ImageCanvas to have the given dimension and image content.
ImageCanvas(java.awt.Image image)
          Initializes with image.
 
Method Summary
 java.awt.Image getImage()
          Returns the current image.
 java.awt.Dimension getMaximumSize()
          Reports the maximum display size of this Canvas.
 java.awt.Dimension getMinimumSize()
          Reports the minimum display size of this Canvas.
 java.awt.Dimension getPreferredSize()
          Reports the preferrred display size of this Canvas.
 boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
          Progressively renders image.
 void paint(java.awt.Graphics g)
          Draws this Canvas using the specified Graphics object.
 void reshape(int x, int y, int w, int h)
          Changes bounds (deprecated).
 void setImage(java.awt.Image image)
          Sets the image to be displayed in this Canvas.
 void setImageAlignment(int new_alignment)
          Changes the image alignment.
 void setImagePosition(java.awt.Point p)
          Moves the image.
 void setImageSize(java.awt.Dimension d)
          Sets image size.
 void setMaximumSize(java.awt.Dimension max_size)
          Sets the maximum size.
 void setMinimumSize(java.awt.Dimension min_size)
          Sets the minimum size.
 void setPreferredSize(java.awt.Dimension pref_size)
          Sets the preferred size.
 void setSizes(java.awt.Dimension min_size, java.awt.Dimension pref_size, java.awt.Dimension max_size)
          Sets the minimum, preferred, and maximum sizes.
 
Methods inherited from class java.awt.Canvas
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

image

protected java.awt.Image image
The Image displayed in this Canvas.

alignment

protected int alignment
Image alignment.

Details: This member indicates the current alignment, as set during construction or in calls to setImageAlignment.

Default value: CENTER

Since:
1998.10.06

position

protected java.awt.Point position
Image position.

Details: position is the location, in the Canvas, of the upper-left corner of the image. The value of position is updated by calls to setImage, setImageAlignment, and setImagePosition.

Since:
1999.04.20

size

protected java.awt.Dimension size
Image size.

Details: size is the display size of this ImageCanvas' image. size may be different from the image's natural size if the ImageCanvas is set to display a stretched image. A null value indicates that the image is to be rendered at its natural size, without stretching. Because of this, settting size to null results in more efficient image rendering.

Since:
1999.04.20

min_size

protected java.awt.Dimension min_size
The minimum size of this Canvas.

pref_size

protected java.awt.Dimension pref_size
The preferred size of this Canvas.

max_size

protected java.awt.Dimension max_size
The maximum size of this Canvas.
Constructor Detail

ImageCanvas

public ImageCanvas(java.awt.Image image)
Initializes with image.

Details: This constructor sets the current image and sets the canvas size to be the same as the image. This constructor will not return until the image's dimensions have been determined, and will fail if the dimensions cannot be determined.

Parameters:
image - the image
Since:
1999.04.21

ImageCanvas

public ImageCanvas(java.awt.Dimension dim,
                   java.awt.Image image)
Initializes this ImageCanvas to have the given dimension and image content. A null image indicates that no image is to be displayed (yet). The image can be changed by calling setImage.
Parameters:
dim - the minimum size of this Canvas
image - the image currently displayed in this canvas

ImageCanvas

public ImageCanvas(java.awt.Dimension dim,
                   java.awt.Image image,
                   int alignment)
Initializes this ImageCanvas to have the given dimension and image content. A null image indicates that no image is to be displayed (yet). This image can be changed by calling setImage.
Parameters:
dim - the minimum size of this Canvas
image - the image currently displayed in this canvas
Method Detail

setImage

public void setImage(java.awt.Image image)
Sets the image to be displayed in this Canvas. Specifying a null image is legal and results in no image being displayed at all.
Parameters:
image - the new image

getImage

public java.awt.Image getImage()
Returns the current image.
Returns:
the current image
Since:
1998.10.10

paint

public void paint(java.awt.Graphics g)
Draws this Canvas using the specified Graphics object. Called by the AWT subsystem.
Overrides:
paint in class java.awt.Canvas
Parameters:
g - the graphics object

setImageAlignment

public void setImageAlignment(int new_alignment)
Changes the image alignment.

Details: setImageAlignment changes the alignment of the image displayed in the canvas. new_alignment may be Alignment.NORTH, Alignment.SOUTH, Alignment.EAST, Alignment.WEST, or any sensible combination of these constants. (Combinations are formed by OR-ing.)

setImageAlignment preserves the image's current display size unless the new alignment requires stretching the image to a new size.

Parameters:
new_alignment - the new alignment setting
Since:
1998.10.06

setImagePosition

public void setImagePosition(java.awt.Point p)
Moves the image.

Details: setImagePosition moves the image so that its upper-left corner is the pixel at canvas coordinate p.

Parameters:
p - the new position
Since:
1999.04.20

setImageSize

public void setImageSize(java.awt.Dimension d)
Sets image size.

Details: setImageSize sets the display dimensions of the image. Normally, this method should only be called when the intent is to stretch or shrink the image from its normal size. If d is null, the image will be displayed at its natural size.

Parameters:
d - the new image size
Since:
1999.04.20

imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
Progressively renders image.

Details: imageUpdate responds to progressively available image data. This method is used internally and should not be called by user threads.

Overrides:
imageUpdate in class java.awt.Component
Since:
1999.04.20

reshape

public void reshape(int x,
                    int y,
                    int w,
                    int h)
Changes bounds (deprecated).

Details: Whether you call setBounds, setSize, resize, or what-have-you, Component.reshape is the method ultimately called by the AWT whenever a component's dimensions are changed. Nevertheless, the retards at Sun deprecated reshape by introducing a setBounds method, whose implementation does nothing but forward the parameters to reshape anyway. Thus, in order to augment resizing behavior, ImageCanvas must override reshape, even though it is deprecated. Don't forget, however, that reshape is still considered to be a deprecated method name and therefore this method should never be called (unless you work for Sun). Use setBounds instead.

Overrides:
reshape in class java.awt.Component
Since:
2000.02.23

getMinimumSize

public java.awt.Dimension getMinimumSize()
Reports the minimum display size of this Canvas.
Overrides:
getMinimumSize in class java.awt.Component
Returns:
min_size
Since:
1988.09.26

getPreferredSize

public java.awt.Dimension getPreferredSize()
Reports the preferrred display size of this Canvas.
Overrides:
getPreferredSize in class java.awt.Component
Returns:
pref_size
Since:
1988.09.26

getMaximumSize

public java.awt.Dimension getMaximumSize()
Reports the maximum display size of this Canvas.
Overrides:
getMaximumSize in class java.awt.Component
Returns:
max_size
Since:
1988.09.26

setMinimumSize

public void setMinimumSize(java.awt.Dimension min_size)
Sets the minimum size.

Details: An IllegalArgumentException is thrown if the resulting size set is not ordered.

Parameters:
min_size - the new minimum size
Since:
1988.10.22

setPreferredSize

public void setPreferredSize(java.awt.Dimension pref_size)
Sets the preferred size.

Details: An IllegalArgumentException is thrown if the resulting size set is not ordered.

Parameters:
min_size - the new preferred size
Since:
1988.10.22

setMaximumSize

public void setMaximumSize(java.awt.Dimension max_size)
Sets the maximum size.

Details: An IllegalArgumentException is thrown if the resulting size set is not ordered.

Parameters:
min_size - the new maximum size
Since:
1988.10.22

setSizes

public void setSizes(java.awt.Dimension min_size,
                     java.awt.Dimension pref_size,
                     java.awt.Dimension max_size)
Sets the minimum, preferred, and maximum sizes.

Details: An IllegalArgumentException is thrown if the resulting size set is not ordered.

Parameters:
min_size - the new minimum size
pref_size - the new preferred size
max_size - the new maximum size
Since:
1988.10.22

Sharkysoft home