Facemorph.psychomorph
Class ImageZoomPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by Facemorph.psychomorph.ImageZoomPanel
All Implemented Interfaces:
TransformerListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.Scrollable

public class ImageZoomPanel
extends javax.swing.JPanel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, javax.swing.Scrollable, TransformerListener

ImageZoomPanel displays a resizable, scrollable etc view of an image and a template. Also has a selection rectangle and 3 point display and supports template editing

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
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
static int DISPLAY_NONE
          Don't display a template or 3 points
static int DISPLAY_POINTS
          Display 3 points
static int DISPLAY_TEMPLATE
          Display the Template
static int EDIT_ADD_LINE
          Edit add line
static int EDIT_ADD_POINT
          Edit add points
static int EDIT_ADD_TO_MASK
          Edit add points / lines to mask
static int EDIT_ADD_TO_SYMMETRY
          Edit add points to symmetry data
static int EDIT_DELETE
          Edit delete points / lines
static int EDIT_MOVE
          Edit movement of points /lines
static int EDIT_START_CLOSED_LINE
          Edit start a closed line
static int EDIT_START_OPEN_LINE
          Edit start an open line
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ImageZoomPanel()
          Constructor for image zoom panel (default size 300 x 300)
ImageZoomPanel(java.awt.Image img, Template tmplt)
          Constructor for Image Zoom Panel
 
Method Summary
 void drawAverage(java.awt.Image img, Template tem, int i, int count)
          Called when the average needs to be redrawn
 void drawImage(java.awt.Image img, Template tem, boolean warped)
          Called when the image needs to be drawn
 int getEditState()
          Gets the current edit state
 FloatImage[] getFloatImage()
          Get the current image
 java.awt.Image getImage()
          Get the current image
 java.lang.String getImgPath()
           
 java.awt.geom.Point2D.Float getLeftEye()
          Get the left eye circle position
 Mask getMask()
          Get the current MaskInterface
 MaskInterface getMaskInterface()
          Get the current MaskInterface
 java.awt.geom.Point2D.Float getMouth()
          Get the mouth circle positions
 int[] getNormPoints()
          Get the normalisation points
 java.awt.Dimension getPreferredScrollableViewportSize()
           
 java.awt.Dimension getPreferredSize()
           
 java.awt.Rectangle getRectangle()
          Get the current rectangle
 java.awt.geom.Point2D.Float getRightEye()
          Get the right eye circle position
 int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
           
 boolean getScrollableTracksViewportHeight()
           
 boolean getScrollableTracksViewportWidth()
           
 int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
           
 java.lang.String getTemPath()
           
 Template getTemplate()
          Return the Template
 java.util.Stack<Template> getUndoStack()
          Get the undo stack for templates
 float getZoom()
          Get the zoom (magnification/subsampling)
 boolean inFloatMode()
           
 boolean inRect(int X, int Y, float z)
          Checks in the point is int the current rectangle at the current zoom
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paintComponent(java.awt.Graphics g)
           
 void setDisplayMask(boolean displayMask)
          Swiches display of the mask on and off
 void setDisplayRectangle(boolean val)
          Should the rectangle be displayed
 void setDisplayState(int state)
          Set the display state
 void setEditState(int newState)
          Set the edit state
 void setImage(FloatImage fimg)
          Set the image to display
 void setImage(FloatImage[] fimg)
          Set the image to display
 void setImage(java.awt.Image img)
          Set the image to display
 void setImgPath(java.lang.String imgPath)
           
 void setMask(MaskInterface mask)
          Set the mask
 void setNormPoints(int[] normPoints)
          Sets the normalisation points
 void setRectangle(java.awt.Rectangle r)
          Set teh rectangle
 void setTemPath(java.lang.String temPath)
           
 void setTemplate(Template t)
          Set the Template
 void setUndoStack(java.util.Stack<Template> undoStack)
          Set the undo stack for templates
 void setZoom(int zoom, int sub)
          Set the zoom level
 void undoMask()
          Undo the last MaskInterface edit
static java.awt.Image zoomImage(java.awt.Image subjectImage, java.awt.image.ImageObserver iob, int zoom, int sub)
          Zooms and/or subsamples an image
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DISPLAY_NONE

public static final int DISPLAY_NONE
Don't display a template or 3 points

See Also:
Constant Field Values

DISPLAY_TEMPLATE

public static final int DISPLAY_TEMPLATE
Display the Template

See Also:
Constant Field Values

DISPLAY_POINTS

public static final int DISPLAY_POINTS
Display 3 points

See Also:
Constant Field Values

EDIT_MOVE

public static final int EDIT_MOVE
Edit movement of points /lines

See Also:
Constant Field Values

EDIT_ADD_POINT

public static final int EDIT_ADD_POINT
Edit add points

See Also:
Constant Field Values

EDIT_ADD_LINE

public static final int EDIT_ADD_LINE
Edit add line

See Also:
Constant Field Values

EDIT_START_CLOSED_LINE

public static final int EDIT_START_CLOSED_LINE
Edit start a closed line

See Also:
Constant Field Values

EDIT_START_OPEN_LINE

public static final int EDIT_START_OPEN_LINE
Edit start an open line

See Also:
Constant Field Values

EDIT_DELETE

public static final int EDIT_DELETE
Edit delete points / lines

See Also:
Constant Field Values

EDIT_ADD_TO_MASK

public static final int EDIT_ADD_TO_MASK
Edit add points / lines to mask

See Also:
Constant Field Values

EDIT_ADD_TO_SYMMETRY

public static final int EDIT_ADD_TO_SYMMETRY
Edit add points to symmetry data

See Also:
Constant Field Values
Constructor Detail

ImageZoomPanel

public ImageZoomPanel()
Constructor for image zoom panel (default size 300 x 300)


ImageZoomPanel

public ImageZoomPanel(java.awt.Image img,
                      Template tmplt)
Constructor for Image Zoom Panel

Parameters:
img - the image to display
tmplt - the Template to display
Method Detail

getRectangle

public java.awt.Rectangle getRectangle()
Get the current rectangle

Returns:
return the rectangle

setRectangle

public void setRectangle(java.awt.Rectangle r)
Set teh rectangle

Parameters:
r - the new value for the rectangle

setDisplayRectangle

public void setDisplayRectangle(boolean val)
Should the rectangle be displayed

Parameters:
val - the new value of the rectangle display flag

setEditState

public void setEditState(int newState)
Set the edit state

Parameters:
newState - the new state, one of EDIT_MOVE, EDIT_ADD_POINT, EDIT_ADD_LINE,t EDIT_START_CLOSED_LINE, EDIT_START_OPEN_LINE, EDIT_DELETE, EDIT_ADD_TO_MASK or EDIT_ADD_TO_SYMMETRY.

getEditState

public int getEditState()
Gets the current edit state

Returns:
one of EDIT_MOVE, EDIT_ADD_POINT, EDIT_ADD_LINE,t EDIT_START_CLOSED_LINE, EDIT_START_OPEN_LINE, EDIT_DELETE, EDIT_ADD_TO_MASK or EDIT_ADD_TO_SYMMETRY.

setUndoStack

public void setUndoStack(java.util.Stack<Template> undoStack)
Set the undo stack for templates

Parameters:
undoStack - the new undo stack

getUndoStack

public java.util.Stack<Template> getUndoStack()
Get the undo stack for templates

Returns:
returns the Template undo stack

setMask

public void setMask(MaskInterface mask)
Set the mask

Parameters:
mask - the mask to use

setDisplayMask

public void setDisplayMask(boolean displayMask)
Swiches display of the mask on and off

Parameters:
displayMask - true if the mask should be displayed

setNormPoints

public void setNormPoints(int[] normPoints)
Sets the normalisation points

Parameters:
normPoints - the normalisation points to use

getNormPoints

public int[] getNormPoints()
Get the normalisation points

Returns:
return the current normalisation point indices

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

getTemplate

public Template getTemplate()
Return the Template

Returns:
returns the Template

setTemplate

public void setTemplate(Template t)
Set the Template

Parameters:
t - the new Template to use / display

getLeftEye

public java.awt.geom.Point2D.Float getLeftEye()
Get the left eye circle position

Returns:
returns the location of the left eye circle

getRightEye

public java.awt.geom.Point2D.Float getRightEye()
Get the right eye circle position

Returns:
returns the right eye circle position

getMouth

public java.awt.geom.Point2D.Float getMouth()
Get the mouth circle positions

Returns:
returns the mouth oval position

setDisplayState

public void setDisplayState(int state)
Set the display state

Parameters:
state - the new display state, one of DISPLAY_NONE, DISPLAY_TEMPLATE or DISPLAY_POINTS

setImage

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

Parameters:
img -

setImage

public void setImage(FloatImage[] fimg)
Set the image to display

Parameters:
img -

setImage

public void setImage(FloatImage fimg)
Set the image to display

Parameters:
img -

inFloatMode

public boolean inFloatMode()

getImage

public java.awt.Image getImage()
Get the current image

Returns:
return the image

getFloatImage

public FloatImage[] getFloatImage()
Get the current image

Returns:
return the image

setZoom

public void setZoom(int zoom,
                    int sub)
Set the zoom level

Parameters:
zoom - the pixel magnification
sub - the pixel subsampling

getZoom

public float getZoom()
Get the zoom (magnification/subsampling)

Returns:
the current zoom settings

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

undoMask

public void undoMask()
Undo the last MaskInterface edit


getMask

public Mask getMask()
Get the current MaskInterface

Returns:
returns the MaskInterface

getMaskInterface

public MaskInterface getMaskInterface()
Get the current MaskInterface

Returns:
returns the MaskInterface

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

inRect

public boolean inRect(int X,
                      int Y,
                      float z)
Checks in the point is int the current rectangle at the current zoom

Parameters:
X - the x-coord
Y - the y-coord
z - the zoom factor
Returns:
returns true if the point is in the rectangle

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

zoomImage

public static java.awt.Image zoomImage(java.awt.Image subjectImage,
                                       java.awt.image.ImageObserver iob,
                                       int zoom,
                                       int sub)
Zooms and/or subsamples an image

Parameters:
subjectImage - The image to zoom/subsample
iob - Image Observer
zoom - The zoom factor (each pixel is repeated zoom times)
sub - The subsampling factor (a jump of sub pixels is taken between sampling, after zooming)
Returns:
The resized image

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

getPreferredScrollableViewportSize

public java.awt.Dimension getPreferredScrollableViewportSize()
Specified by:
getPreferredScrollableViewportSize in interface javax.swing.Scrollable

getScrollableBlockIncrement

public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Specified by:
getScrollableBlockIncrement in interface javax.swing.Scrollable

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Specified by:
getScrollableTracksViewportHeight in interface javax.swing.Scrollable

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Specified by:
getScrollableTracksViewportWidth in interface javax.swing.Scrollable

getScrollableUnitIncrement

public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Specified by:
getScrollableUnitIncrement in interface javax.swing.Scrollable

drawImage

public void drawImage(java.awt.Image img,
                      Template tem,
                      boolean warped)
Description copied from interface: TransformerListener
Called when the image needs to be drawn

Specified by:
drawImage in interface TransformerListener
Parameters:
img - the image to draw
tem - the template to draw
warped - indicates if this is the warped image

drawAverage

public void drawAverage(java.awt.Image img,
                        Template tem,
                        int i,
                        int count)
Description copied from interface: TransformerListener
Called when the average needs to be redrawn

Specified by:
drawAverage in interface TransformerListener
Parameters:
img - the image to draw
tem - the template to draw
i - the number of this image in the average
count - the total number of images to be put in the average

getTemPath

public java.lang.String getTemPath()
Returns:
the temPath

setTemPath

public void setTemPath(java.lang.String temPath)
Parameters:
temPath - the temPath to set

getImgPath

public java.lang.String getImgPath()
Returns:
the imgPath

setImgPath

public void setImgPath(java.lang.String imgPath)
Parameters:
imgPath - the imgPath to set