Facemorph
Class KnockedUpApplet

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by Facemorph.KnockedUpApplet
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener, javax.swing.RootPaneContainer

public class KnockedUpApplet
extends javax.swing.JApplet
implements javax.swing.event.ChangeListener, java.awt.event.ActionListener, java.lang.Runnable

Applet for averaging multiple pre-delineated images, or adding new images and auto-delineating them. Images are added by calling a method from the browser (e.g. in a separate frame). The URL of the new image is passed as a String, usually this will be after a successful upload. The method to add the image to the applet can be called as part of the response to the upload form, e.g. during the page loading. This prevent the need for reloading the entire applet each time.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
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
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
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
KnockedUpApplet()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          This method is called when the "Save to Browser" button is clicked.
 Template autoDelineate(java.awt.Image subjectImage, java.awt.Point[] points)
          Method to autodelineate a new image, using 3 points specified by the user.
 void init()
          Initializes the applet AverageApplet, setting up the GUI components and loading the pre-delineated images as specified as applet parameters.
 void loadFormImage(java.lang.String url, java.lang.String sex)
          Method to load a new (undelineated) image into the applet.
 void makeAverage()
          Instruct the applet to recalculate and display the average
 void run()
           
 void stateChanged(javax.swing.event.ChangeEvent ae)
          This method is called when a different tab is selected.
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KnockedUpApplet

public KnockedUpApplet()
Method Detail

init

public void init()
Initializes the applet AverageApplet, setting up the GUI components and loading the pre-delineated images as specified as applet parameters.

Overrides:
init in class java.applet.Applet

loadFormImage

public void loadFormImage(java.lang.String url,
                          java.lang.String sex)
Method to load a new (undelineated) image into the applet. It is usually called by the browser after a successful image upload.

Parameters:
url - A String giving the URL of the image to load into the applet.
sex - should be "male" or "female"

autoDelineate

public Template autoDelineate(java.awt.Image subjectImage,
                              java.awt.Point[] points)
Method to autodelineate a new image, using 3 points specified by the user.

Parameters:
subjectImage - The image to delineate
points - The 3 points to initialise the semi-automatic delineation
Returns:
Returns the estimated template for the image.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
This method is called when the "Save to Browser" button is clicked. It writes the image data back to the server as though through a form submission the browser responds either with an error message (signaled by "error") or the URL of the saved image and the target window (e.g. "_blank" for a new browser window/tab. If successful, the applet then uses the showDocument method to get the browser to display the saved image as a jpeg.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - The event that triggered this method.

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent ae)
This method is called when a different tab is selected. tab 0 is the averaging tab, so it tries to calculate the average when this is clicked tab 1 is the grid of image buttons tab 2 is the delineation tab

Specified by:
stateChanged in interface javax.swing.event.ChangeListener
Parameters:
ae - The event that caused this method to be called.

makeAverage

public void makeAverage()
Instruct the applet to recalculate and display the average


run

public void run()
Specified by:
run in interface java.lang.Runnable