com.ccg.awt
Class ImageViewer

java.lang.Object
  extended by java.awt.Component
      extended by com.ccg.awt.ImageViewer
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class ImageViewer
extends Component
implements ImageObserver

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:

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.

Since:
1.0
Version:
$Revision: 1.2 $
Author:
$Author: pkb $
See Also:
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.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImageViewer

public ImageViewer()
Initializes such that there is no image/text to display. After initializing the object in this fashion, its paint routine will do nothing until you set the image and/or text to display.

Since:
1.0
See Also:
setImage(java.awt.Image)
Method Detail

setImage

public void setImage(Image val)
Set the displayed image

Parameters:
val - New Image value to assign.
See Also:
getImage()

getImage

public Image getImage()
Get the displayed image

Returns:
Current Image value assigned.
See Also:
setImage(java.awt.Image)

setText

public void setText(String val)
Set the status message to display

Parameters:
val - New String value to assign.
See Also:
getText()

getText

public String getText()
Get the status message to display

Returns:
Current String value assigned.
See Also:
setText(java.lang.String)

paint

public void paint(Graphics g)
Paints the 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.

Overrides:
paint in class Component
Parameters:
g - Standard Graphics object to do the drawing onto.
Since:
1.0
See Also:
setImage(java.awt.Image)

imageUpdate

public boolean imageUpdate(Image im,
                           int flags,
                           int x,
                           int y,
                           int w,
                           int h)
Our implementation of the 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.

Specified by:
imageUpdate in interface ImageObserver
Overrides:
imageUpdate in class Component
Parameters:
im - 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.
Returns:
true - once the entire image we are waiting for is available.
Since:
1.0
See Also:
paint(java.awt.Graphics)


Copyright 1998-1998-2006 null. All Rights Reserved.