com.mindprod.common11
Class ResizingImageViewer

java.lang.Object
  extended by java.awt.Component
      extended by com.mindprod.common11.ResizingImageViewer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public final class ResizingImageViewer
extends java.awt.Component

Component to display an Image, magnifying or shrinking it.

Simplified version of Symantec ImageViewer. Always resizes the image to fit the size of the component, even if it distorts the aspect ratio. Used by com.mindprod.networkcam.NetworkCam

Since:
2003
Version:
1.2 2007-04-20 allow AffineTransform.
Author:
Roedy Green, Canadian Mind Products
See Also:
ImageViewer, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.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
ResizingImageViewer()
          default Constructor
ResizingImageViewer(java.awt.geom.AffineTransform transform)
          Constructor with transform.
ResizingImageViewer(java.awt.Image image)
          Constructor with Image.
 
Method Summary
 java.awt.Image getImage()
          Get the Image currently being displayed.
 java.awt.Dimension getMinimumSize()
          Minimum layout size.
 java.awt.Dimension getPreferredSize()
          Preferred Layout size.
 void paint(java.awt.Graphics g)
          Paints this component using the given graphics context.
 void setImage(java.awt.Image image)
          Set or change the current Image to display.
 void update(java.awt.Graphics g)
          bypass usual clear for speed since will fill entire frame
 
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, getBaseline, getBaselineResizeBehavior, 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, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, 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, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResizingImageViewer

public ResizingImageViewer()
default Constructor


ResizingImageViewer

public ResizingImageViewer(java.awt.geom.AffineTransform transform)
Constructor with transform.

Parameters:
transform - to flip, mirror, rotate the image. Usually null.

ResizingImageViewer

public ResizingImageViewer(java.awt.Image image)
Constructor with Image.

Parameters:
image - the Image to be displayed, See the Java glossary under Image for ways to create an Image.
Method Detail

getImage

public java.awt.Image getImage()
Get the Image currently being displayed.

Returns:
the Image currently displayed or null if no Image

getMinimumSize

public java.awt.Dimension getMinimumSize()
Minimum layout size.

Overrides:
getMinimumSize in class java.awt.Component
Returns:
he minimum dimensions to properly display the Image

getPreferredSize

public java.awt.Dimension getPreferredSize()
Preferred Layout size.

Overrides:
getPreferredSize in class java.awt.Component
Returns:
the recommended dimensions to display the Image.

paint

public void paint(java.awt.Graphics g)
Paints this component using the given graphics context.

Overrides:
paint in class java.awt.Component
Parameters:
g - Graphics context where to paint, e.g. to screen, printer, RAM.

setImage

public void setImage(java.awt.Image image)
Set or change the current Image to display. setImage does a MediaTracker to ensure the Image is loaded. You don't have to. If you don't plan to use the old image again you should do a getImage().flush();

Parameters:
image - the new Image to be displayed. If the image jpg may have recently changed, don't use getImage to create it, use URL.openConnection() URLConnection.setUseCaches( false ) Connection.getContent Component.createImage

update

public void update(java.awt.Graphics g)
bypass usual clear for speed since will fill entire frame

Overrides:
update in class java.awt.Component
Parameters:
g - graphics region to paint