com.vistech.imageviewer
Class CompositeCanvas2D

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.vistech.imageviewer.ImageCanvas
                          |
                          +--com.vistech.imageviewer.ImageCanvas2D
                                |
                                +--com.vistech.imageviewer.CompositeCanvas2D
All Implemented Interfaces:
DrawingCanvas, ImageDisplay, ImageManipulator, java.awt.image.ImageObserver, ImagePrint, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable

public class CompositeCanvas2D
extends ImageCanvas2D
implements DrawingCanvas

A canvas class for drawing graphics over images.

Version:
1.0 4 April 2000
Author:
Larry 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.Shape currentShape
           
protected  int imageHeight
           
protected  int imageWidth
           
protected  int offsetX
           
protected  int offsetY
           
protected  int viewerHt
           
protected  int viewerWid
           
 
Fields inherited from class com.vistech.imageviewer.ImageCanvas2D
atx, dispModeAtx, flipAtx, interpolationType, magCenterX, magCenterY, magFactor, magOn, panOffset, rotateOn, rotationAngle, rotationCenterX, rotationCenterY, shearFactor, shearOn, shearX, shearY, zoomOffset
 
Fields inherited from class com.vistech.imageviewer.ImageCanvas
bufferedImage, clipShape, dispGc, displayImage, displayMode, flipMode, height, imageType, invertOn, offScrGc, offScrImage, originalImageType, paintFlag, PRINT_SIZE_ACTUAL, PRINT_SIZE_PAGE, printLoc, printMode, printSize, 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.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CompositeCanvas2D()
           
CompositeCanvas2D(java.awt.image.BufferedImage img, int wid, int ht)
           
 
Method Summary
 void drawShape(java.awt.Shape s)
          Draws a shape on the canvas.
 void eraseShapes()
          Erases shapes drawn on the canvas.
 void fillShape(java.awt.Shape s)
          Fills the specified shape.
 java.awt.geom.AffineTransform getAllAtx()
          Gets the current transformation that includes the transformation computed for setting the display and flip modes.
 java.awt.image.BufferedImage getDisplayedImage()
          Returns the image displayed on the canvas.
 java.awt.Graphics2D getDisplayedImageGC()
          Use this method to check out the graphics context.
 java.awt.geom.AffineTransform getDispModeAtx()
          Gets the transformation computed for setting the display and flip modes.
 boolean paintImage(java.awt.image.BufferedImage img)
          Paints the image with the current display and flip modes.
 void reset()
          Resets the canvas
 
Methods inherited from class com.vistech.imageviewer.ImageCanvas2D
applyTransform, applyTransform, createFlipTransform, doDisplayModeAndFlip, getInterpolationType, getMagFactor, getMagOn, getPanOffset, getRotationAngle, getShearFactor, getShearFactorX, getShearFactorY, getTransform, init, main, resetManipulation, setInterpolationType, setMagFactor, setMagOn, setPanOffset, setRotationAngle, setShearFactor, setTransform
 
Methods inherited from class com.vistech.imageviewer.ImageCanvas
addImageSentListener, clearImageCanvas, convertToAWTImage, convertToBufferedImage, createDisplayImage, doFlip, doFlip, draw, drawingDim, fireImageSentEvents, getAWTImage, getBufferedImage, getDisplayMode, getFlipMode, getImageSize, getImageType, getInvert, getOffScreenImage, getPreferredSize, getPrintLocation, getPrintSize, imageUpdate, invert, paintComponent, paintImage, print, printImage, redraw, removeImageSentListener, setAWTImage, setBufferedImage, setClip, setDisplayImage, setDisplayMode, setFlipMode, setImageType, setInvert, setOffScreenImage, setOffScrGc, setPrintLocation, setPrintSize
 
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, 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, 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.DrawingCanvas
addMouseListener, addMouseMotionListener, getTransform, removeMouseListener, removeMouseMotionListener, repaint, setTransform
 
Methods inherited from interface com.vistech.imageviewer.ImageDisplay
addMouseListener, addMouseMotionListener, addPropertyChangeListener, addVetoableChangeListener, draw, getAWTImage, getBufferedImage, getDisplayMode, getFlipMode, getImageSize, getImageType, getInvert, getOffScreenImage, paintImage, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removeVetoableChangeListener, setAWTImage, setBufferedImage, setClip, setCursor, setDisplayImage, setDisplayMode, setFlipMode, setImageType, setInvert, setOffScreenImage
 

Field Detail

imageWidth

protected int imageWidth

imageHeight

protected int imageHeight

viewerWid

protected int viewerWid

viewerHt

protected int viewerHt

offsetX

protected int offsetX

offsetY

protected int offsetY

currentShape

protected java.awt.Shape currentShape
Constructor Detail

CompositeCanvas2D

public CompositeCanvas2D()

CompositeCanvas2D

public CompositeCanvas2D(java.awt.image.BufferedImage img,
                         int wid,
                         int ht)
Parameters:
img - the image over which the graphics are to be drawn.
wid - the width of the canvas.
ht - the height of the canvas.
Method Detail

paintImage

public boolean paintImage(java.awt.image.BufferedImage img)
Paints the image with the current display and flip modes.
Parameters:
img - the image to be painted on the canvas.
Returns:
true if the drawing is successful.

getAllAtx

public java.awt.geom.AffineTransform getAllAtx()
Gets the current transformation that includes the transformation computed for setting the display and flip modes.
Returns:
all the transformation that includes the trasformation computed for initial display mode and flip modes.

getDispModeAtx

public java.awt.geom.AffineTransform getDispModeAtx()
Gets the transformation computed for setting the display and flip modes.
Returns:
the transformation computed for initial display mode and flip modes.

drawShape

public void drawShape(java.awt.Shape s)
Draws a shape on the canvas.
Parameters:
s - the Shape to be drawn on the canvas.

fillShape

public void fillShape(java.awt.Shape s)
Fills the specified shape.
Parameters:
s - the Shape to be filled.

eraseShapes

public void eraseShapes()
Erases shapes drawn on the canvas.
Specified by:
eraseShapes in interface DrawingCanvas

getDisplayedImageGC

public java.awt.Graphics2D getDisplayedImageGC()
Description copied from interface: DrawingCanvas
Use this method to check out the graphics context.
Specified by:
getDisplayedImageGC in interface DrawingCanvas
Overrides:
getDisplayedImageGC in class ImageCanvas
Following copied from interface: com.vistech.imageviewer.DrawingCanvas
Returns:
the graphics context on which the image drawn. Graphics objects are drawn on this context.

getDisplayedImage

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

reset

public void reset()
Description copied from interface: DrawingCanvas
Resets the canvas
Specified by:
reset in interface DrawingCanvas
Overrides:
reset in class ImageCanvas2D