com.glaivestone.javax.awt
Class ImageWindow

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--com.glaivestone.javax.awt.ImageWindow
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class ImageWindow
extends java.awt.Window

A Window on an Image.

Note that this class only uses AWT classes and not any Swing classes.

Version:
1.0
Author:
Gary Gregory
See Also:
Serialized Form

Field Summary
static int DEFAULT_MEDIA_TRACKER_ID
          The default MediaTracker ID used to wait for an image to be loaded, 0.
 
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
ImageWindow(java.awt.Frame parent, java.awt.Image image)
          Create a new window with the given parent and image.
 
Method Summary
 void centerOnScreen()
          Center this window on the screen.
 java.awt.Image getImage()
          Get the image to display for the window.
 java.awt.MediaTracker getMediaTracker()
          Get the MediaTracker used to load the image.
 boolean hasMediaTracker()
          Returns whether or not the media tracker field has been set.
 boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
          Implementation of the single ImageObserver interface method imageUpdate.
 boolean isImagePainted()
          Get whether or not the image has been painted in the window.
static ImageWindow newForFilenameImage(java.awt.Frame parent, java.lang.String filename)
          Create and return a new ImageWindow with the given parent Frame and image read from the given file name.
static ImageWindow newForSystemResourceImage(java.awt.Frame parent, java.lang.String filename)
          Create and return a new ImageWindow with the given parent Frame and image read from the given file name on the system class path.
static ImageWindow newImageWindow(java.awt.Frame parent, java.awt.Image image)
          Create and return a new ImageWindow with the given parent Frame and Image.
 void paint(java.awt.Graphics g)
          Paints the window.
 void setImage(java.awt.Image image)
          Set the image to display for the window.
 void setMediaTracker(java.awt.MediaTracker mediaTracker)
          Set the MediaTracker used to load the image.
 boolean setSizeCheck(int width, int height)
          Resizes this component so that it has width and height.
 void setSizeToImageSize()
          Set the size of this window of the size the expression: this.getImage().
 void setSizeToImageSize(java.awt.Image anImage)
          Set the size of this window of the size of the given Image.
 java.lang.String toString()
           
 void waitForImage()
          Starts loading all images tracked by this media tracker with the DEFAULT_MEDIA_TRACKER_ID identifier.
 void waitForImage(int mediaTrackerID)
          Starts loading all images tracked by this media tracker with the specified identifier.
 
Methods inherited from class java.awt.Window
addNotify, addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getAccessibleContext, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MEDIA_TRACKER_ID

public static final int DEFAULT_MEDIA_TRACKER_ID
The default MediaTracker ID used to wait for an image to be loaded, 0.

See Also:
Constant Field Values
Constructor Detail

ImageWindow

public ImageWindow(java.awt.Frame parent,
                   java.awt.Image image)
Create a new window with the given parent and image.

Method Detail

newImageWindow

public static ImageWindow newImageWindow(java.awt.Frame parent,
                                         java.awt.Image image)
Create and return a new ImageWindow with the given parent Frame and Image.


newForFilenameImage

public static ImageWindow newForFilenameImage(java.awt.Frame parent,
                                              java.lang.String filename)
Create and return a new ImageWindow with the given parent Frame and image read from the given file name.


newForSystemResourceImage

public static ImageWindow newForSystemResourceImage(java.awt.Frame parent,
                                                    java.lang.String filename)
Create and return a new ImageWindow with the given parent Frame and image read from the given file name on the system class path.


centerOnScreen

public void centerOnScreen()
Center this window on the screen.


paint

public void paint(java.awt.Graphics g)
Paints the window.

Overrides:
paint in class java.awt.Container
Parameters:
g - the specified Graphics window
See Also:
Component.paint(java.awt.Graphics)

setSizeToImageSize

public void setSizeToImageSize(java.awt.Image anImage)
Set the size of this window of the size of the given Image.


setSizeToImageSize

public void setSizeToImageSize()
Set the size of this window of the size the expression: this.getImage().


setSizeCheck

public boolean setSizeCheck(int width,
                            int height)
Resizes this component so that it has width and height.

If width or height equals -1, then return true, indicating that the window size needs to be set with a call to this method.

Otherwise, set the window size and return false, indicating that no further calls to this method is needed.

See Also:
Component.setSize(int,int)

imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
Implementation of the single ImageObserver interface method imageUpdate.

Specified by:
imageUpdate in interface java.awt.image.ImageObserver
Overrides:
imageUpdate in class java.awt.Component
See Also:
setSizeCheck(int,int)

getImage

public java.awt.Image getImage()
Get the image to display for the window.


hasMediaTracker

public boolean hasMediaTracker()
Returns whether or not the media tracker field has been set.


getMediaTracker

public java.awt.MediaTracker getMediaTracker()
Get the MediaTracker used to load the image. This media tracker is lazy-initialized. This window is used as the component associated with the media tracker.


setImage

public void setImage(java.awt.Image image)
Set the image to display for the window.


setMediaTracker

public void setMediaTracker(java.awt.MediaTracker mediaTracker)
Set the MediaTracker used to load the image. Clients can use this method to provide their own MediaTracker instead of the one provided by getMediaTracker().


toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Component

waitForImage

public void waitForImage()
Starts loading all images tracked by this media tracker with the DEFAULT_MEDIA_TRACKER_ID identifier. This method waits until all the images with the specified identifier have finished loading.

This method calls waitForImage(int) with DEFAULT_MEDIA_TRACKER_ID

See Also:
waitForImage(int)

waitForImage

public void waitForImage(int mediaTrackerID)
Starts loading all images tracked by this media tracker with the specified identifier. This method waits until all the images with the specified identifier have finished loading.

This method uses a media tracker to load the window's image.

See Also:
MediaTracker, MediaTracker.addImage(java.awt.Image,int), MediaTracker.waitForID(int)

isImagePainted

public boolean isImagePainted()
Get whether or not the image has been painted in the window.


GFL 1.1 API