com.vistech.jai.render
Class ImageManipulatorCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.vistech.jai.render.JAIImageCanvas
                          |
                          +--com.vistech.jai.render.RenderedImageCanvas
                                |
                                +--com.vistech.jai.render.ImageManipulatorCanvas
All Implemented Interfaces:
ImageDisplay, ImageManipulator, java.awt.image.ImageObserver, java.awt.MenuContainer, ScrollController, java.io.Serializable
Direct Known Subclasses:
CompositeCanvasJAI

public class ImageManipulatorCanvas
extends RenderedImageCanvas
implements ImageManipulator

A component class for displaying and manipulating rendered images.

Version:
1.0 18 Apr 2000
Author:
Lawrence Rodrigues
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  java.awt.Image awtImage
           
protected  double diffFactor
           
protected  int displayMode
           
protected  int flipMode
           
protected  int imageType
           
protected  int interpMode
           
protected  int magCenterX
           
protected  int magCenterY
           
protected  double magFactor
           
protected  boolean magOn
           
protected  java.awt.Point panOffset
           
protected  boolean rotateOn
           
protected  double rotationAngle
           
protected  int rotationCenterX
           
protected  int rotationCenterY
           
protected  double shearFactor
           
protected  boolean shearOn
           
protected  double shearX
           
protected  double shearY
           
 
Fields inherited from class com.vistech.jai.render.RenderedImageCanvas
colorModel, displayImage, imageHeight, imageWidth, maxTileCordX, maxTileCordY, maxTileIndexX, maxTileIndexY, minTileCordX, minTileCordY, minTileIndexX, minTileIndexY, origImage, sampleModel, tc, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, viewerHeight, viewerWidth
 
Fields inherited from class com.vistech.jai.render.JAIImageCanvas
atx, height, image, imageDrawn, MAX_HEIGHT, MAX_WIDTH, panX, panY, scrollAnchor, scrollOn, vpPos, width
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface com.vistech.imageviewer.ImageDisplay
TYPE_AWT_IMAGE, TYPE_BUFFERED_IMAGE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ImageManipulatorCanvas()
           
 
Method Summary
 void applyTransform(java.awt.geom.AffineTransform atx)
          Applies the transform
protected  void applyTransform(java.awt.image.RenderedImage ri, java.awt.geom.AffineTransform atx)
           
 void createTiledImage(javax.media.jai.PlanarImage img)
           
 void draw(java.awt.Shape shape)
          Draws the specified shape on the destination image
 java.awt.Image getAWTImage()
          Returns the image property.
 java.awt.image.BufferedImage getBufferedImage()
          Returns the BufferedImage property.
 java.awt.image.BufferedImage getDisplayedImage()
          Returns the image displayed on the canvas.
 int getDisplayMode()
          Returns the display mode.
 int getFlipMode()
          Returns the flip mode.
 javax.media.jai.PlanarImage getImage()
           
 java.awt.Dimension getImageSize()
          Returns the image size.
 int getImageType()
          Returns the image type property.
 int getInterpolationType()
           
 boolean getInvert()
          Returns the invert mode.
 double getMagFactor()
          Gets the magFactor property.
 java.awt.image.BufferedImage getOffScreenImage()
          Returns the off screen image.
 double getRotationAngle()
          Gets the rotation angle property.
 double getShearFactor()
           
 double getShearFactorX()
           
 double getShearFactorY()
           
 void invert(boolean on)
           
 void paintComponent(java.awt.Graphics gc)
          Paints the tiles that are visible.
 boolean paintImage()
          This method paints the current image i.e.; the image set by the setImage() method.
 void paintImage(int magCenterX, int magCenterY, double mag)
           
 void resetManipulation()
          Resets manipulation.
 void setAWTImage(java.awt.Image image)
          Sets the image property.
 void setBufferedImage(java.awt.image.BufferedImage image)
          Sets the BufferedImage property.
 void setClip(java.awt.Shape clip)
          Sets the clip shape on the destination image
 void setDisplayImage(java.awt.image.BufferedImage image)
          Sets the image to be displayed on the canvas.
 void setDisplayMode(int mode)
          Sets the display mode.
 void setFlipMode(int mode)
          Sets the flip mode.
 void setImageType(int imageType)
          Sets the image type property.
 void setInterpolationType(int mode)
          Sets the interpolationType property.
 void setInvert(boolean on)
          Sets the invert mode property.
 void setMagFactor(double magFactor)
          Sets the magFactor property.
 void setOffScreenImage(java.awt.image.BufferedImage image)
          Sets the off screen image.
 void setRotationAngle(double rotationAngle)
          Sets the rotationAngle property.
 void setShearFactor(double shearFactor)
          Sets the shearFactor property.
 
Methods inherited from class com.vistech.jai.render.RenderedImageCanvas
fireTilePropertyChange, getDisplayImage, getImageHeight, getImageWidth, getMaxTileIndexX, getMaxTileIndexY, getTileHeight, getTileInfo, getTileWidth, makeTiledImage, setImage, setTileHeight, setTileWidth
 
Methods inherited from class com.vistech.jai.render.JAIImageCanvas
getPanOffset, getScrollOn, getTransform, getViewportPosition, isImageDrawn, pan, reset, scroll, setPanOffset, setScrollOn, setTransform, setViewportPosition, startScroll, stopScroll
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.vistech.imageviewer.ImageManipulator
getPanOffset, getTransform, setPanOffset, setTransform
 
Methods inherited from interface com.vistech.imageviewer.ImageDisplay
addMouseListener, addMouseMotionListener, addPropertyChangeListener, addVetoableChangeListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removeVetoableChangeListener, setCursor
 

Field Detail

awtImage

protected transient java.awt.Image awtImage

imageType

protected int imageType

panOffset

protected java.awt.Point panOffset

magOn

protected boolean magOn

magFactor

protected double magFactor

magCenterX

protected int magCenterX

magCenterY

protected int magCenterY

rotationAngle

protected double rotationAngle

rotateOn

protected boolean rotateOn

rotationCenterX

protected int rotationCenterX

rotationCenterY

protected int rotationCenterY

shearOn

protected boolean shearOn

shearFactor

protected double shearFactor

shearX

protected double shearX

shearY

protected double shearY

displayMode

protected int displayMode

flipMode

protected int flipMode

interpMode

protected int interpMode

diffFactor

protected double diffFactor
Constructor Detail

ImageManipulatorCanvas

public ImageManipulatorCanvas()
Method Detail

getImage

public javax.media.jai.PlanarImage getImage()
Overrides:
getImage in class JAIImageCanvas

getImageSize

public java.awt.Dimension getImageSize()
Description copied from interface: ImageDisplay
Returns the image size.
Specified by:
getImageSize in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Returns:
the image size.

setInterpolationType

public void setInterpolationType(int mode)
Description copied from interface: ImageManipulator
Sets the interpolationType property.
Specified by:
setInterpolationType in interface ImageManipulator
Following copied from interface: com.vistech.imageviewer.ImageManipulator
Parameters:
the - interpolation type

getInterpolationType

public int getInterpolationType()
Specified by:
getInterpolationType in interface ImageManipulator

setDisplayMode

public void setDisplayMode(int mode)
Description copied from interface: ImageDisplay
Sets the display mode. This is a bound property . The input parameter can be one of NORMAL, ORIG_SIZE, TO_FIT, SCALED. These constants are defined in the DisplayMode class. Call to this method would reset the viewport and the image is redarwn with new display mode.
Specified by:
setDisplayMode in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Parameters:
dispMode - the display mode

getDisplayMode

public int getDisplayMode()
Description copied from interface: ImageDisplay
Returns the display mode.
Specified by:
getDisplayMode in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Returns:
the current display mode.

setFlipMode

public void setFlipMode(int mode)
Description copied from interface: ImageDisplay
Sets the flip mode. This is a bound property . The input parameter can be one of NORMAL, LEFT_RIGHT, TOP_BOTTOM, LEFT_RIGHT_TOP_BOTTON. These constants are defined in the FlipMode class. Call to this method would reset the viewport and the image is redraw with new flip mode.
Specified by:
setFlipMode in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Parameters:
flipMode - the flip mode

getFlipMode

public int getFlipMode()
Description copied from interface: ImageDisplay
Returns the flip mode.
Specified by:
getFlipMode in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Returns:
the current flip mode.

setMagFactor

public void setMagFactor(double magFactor)
Description copied from interface: ImageManipulator
Sets the magFactor property.
Specified by:
setMagFactor in interface ImageManipulator
Following copied from interface: com.vistech.imageviewer.ImageManipulator
Parameters:
magFactor - the magnification factor.

getMagFactor

public double getMagFactor()
Description copied from interface: ImageManipulator
Gets the magFactor property.
Specified by:
getMagFactor in interface ImageManipulator
Following copied from interface: com.vistech.imageviewer.ImageManipulator
Returns:
the magFactor.

setShearFactor

public void setShearFactor(double shearFactor)
Description copied from interface: ImageManipulator
Sets the shearFactor property.
Specified by:
setShearFactor in interface ImageManipulator
Following copied from interface: com.vistech.imageviewer.ImageManipulator
Parameters:
shearFactor - the shearFactor property.

getShearFactor

public double getShearFactor()
Specified by:
getShearFactor in interface ImageManipulator
Following copied from interface: com.vistech.imageviewer.ImageManipulator
Returns:
the shearFactor.

getShearFactorX

public double getShearFactorX()

getShearFactorY

public double getShearFactorY()

setRotationAngle

public void setRotationAngle(double rotationAngle)
Description copied from interface: ImageManipulator
Sets the rotationAngle property.
Specified by:
setRotationAngle in interface ImageManipulator
Following copied from interface: com.vistech.imageviewer.ImageManipulator
Parameters:
rotationAngle - the rotation angle

getRotationAngle

public double getRotationAngle()
Description copied from interface: ImageManipulator
Gets the rotation angle property.
Specified by:
getRotationAngle in interface ImageManipulator
Following copied from interface: com.vistech.imageviewer.ImageManipulator
Returns:
the rotation angle.

paintImage

public void paintImage(int magCenterX,
                       int magCenterY,
                       double mag)

applyTransform

protected void applyTransform(java.awt.image.RenderedImage ri,
                              java.awt.geom.AffineTransform atx)

applyTransform

public void applyTransform(java.awt.geom.AffineTransform atx)
Description copied from interface: ImageManipulator
Applies the transform
Specified by:
applyTransform in interface ImageManipulator
Following copied from interface: com.vistech.imageviewer.ImageManipulator
Parameters:
the - transform.

createTiledImage

public void createTiledImage(javax.media.jai.PlanarImage img)

resetManipulation

public void resetManipulation()
Description copied from interface: ImageManipulator
Resets manipulation.
Specified by:
resetManipulation in interface ImageManipulator

paintComponent

public void paintComponent(java.awt.Graphics gc)
Description copied from class: RenderedImageCanvas
Paints the tiles that are visible. This method first computes only the tiles that are visible. Each of the tiles is converted into a BufferedImage object, which is then drawn over the components graphics context.
Overrides:
paintComponent in class RenderedImageCanvas
Following copied from class: com.vistech.jai.render.RenderedImageCanvas
Parameters:
gc - the graphics context.

setAWTImage

public void setAWTImage(java.awt.Image image)
Description copied from interface: ImageDisplay
Sets the image property. If the input parameter is not null, the it becomes the current image. This is a bound property.
Specified by:
setAWTImage in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Parameters:
image - the image object

getAWTImage

public java.awt.Image getAWTImage()
Description copied from interface: ImageDisplay
Returns the image property.
Specified by:
getAWTImage in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Returns:
the image object

setImageType

public void setImageType(int imageType)
Description copied from interface: ImageDisplay
Sets the image type property.
Specified by:
setImageType in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Parameters:
imageType - the image type.

getImageType

public int getImageType()
Description copied from interface: ImageDisplay
Returns the image type property.
Specified by:
getImageType in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Returns:
the image type.

setClip

public void setClip(java.awt.Shape clip)
Description copied from interface: ImageDisplay
Sets the clip shape on the destination image
Specified by:
setClip in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Parameters:
clipshape - the shape of the clipping area

setBufferedImage

public void setBufferedImage(java.awt.image.BufferedImage image)
Description copied from interface: ImageDisplay
Sets the BufferedImage property. If the input parameter is not null, the it becomes the current image. This is a bound property.
Specified by:
setBufferedImage in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Parameters:
BufferedImage - the image object

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage()
Description copied from interface: ImageDisplay
Returns the BufferedImage property. If the image loaded is of Image type, this method creates a BufferedImage from the original image object.
Specified by:
getBufferedImage in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Returns:
the BufferedImage object

setOffScreenImage

public void setOffScreenImage(java.awt.image.BufferedImage image)
Description copied from interface: ImageDisplay
Sets the off screen image.
Specified by:
setOffScreenImage in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Parameters:
image - the off screen image.

getOffScreenImage

public java.awt.image.BufferedImage getOffScreenImage()
Description copied from interface: ImageDisplay
Returns the off screen image.
Specified by:
getOffScreenImage in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Returns:
the off screen imge.

setDisplayImage

public void setDisplayImage(java.awt.image.BufferedImage image)
Description copied from interface: ImageDisplay
Sets the image to be displayed on the canvas. When an image is set this way, it is not saved. This method needs to be used for temporory display only.The correct way to set the image is to call the setAWTImage() or setBufferedImage() methods.
Specified by:
setDisplayImage in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Parameters:
image - the image to be displayed.

getDisplayedImage

public java.awt.image.BufferedImage getDisplayedImage()
Description copied from interface: ImageDisplay
Returns the image displayed on the canvas.
Specified by:
getDisplayedImage in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Returns:
the displayed imge.

draw

public void draw(java.awt.Shape shape)
Description copied from interface: ImageDisplay
Draws the specified shape on the destination image
Specified by:
draw in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Parameters:
shape - the shape to be drawn

invert

public void invert(boolean on)

setInvert

public void setInvert(boolean on)
Description copied from interface: ImageDisplay
Sets the invert mode property. It fires the propertyChange events because it is a bound property. If set true, it inverts the image.
Specified by:
setInvert in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Parameters:
onOrOff - the invert mode.

getInvert

public boolean getInvert()
Description copied from interface: ImageDisplay
Returns the invert mode.
Specified by:
getInvert in interface ImageDisplay
Following copied from interface: com.vistech.imageviewer.ImageDisplay
Returns:
the invert mode

paintImage

public boolean paintImage()
Description copied from interface: ImageDisplay
This method paints the current image i.e.; the image set by the setImage() method. While painting it applies the current display and flip mode policies. Call to this method will reset the panOffset and magFactor properties to default values. This method is called whenever the display and flip modes are changed.
Specified by:
paintImage in interface ImageDisplay