|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--java.applet.Applet | +--MainApplet
CLASS: MainApplet
PURPOSE: This class handle all the GUI action and this is also
the main class for the applet
IMPORT: java.applet.Applet, java.awt.Graphics, java.awt.Image,
java.awt.MediaTracker, java.awt.Color, java.awt.event.MouseListener,
java.awt.event.MouseMotionListener, java.awt.event.MouseEvent,
FlyManager, FlyCreator
EXPORT: New Class|MainApplet
New Method| destroy, init, mouseClicked,
mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed,
mouseReleased, paint, run, setEyePos, update, drawFrog
Inner classes inherited from class java.applet.Applet |
java.applet.Applet.AccessibleApplet |
Inner classes inherited from class java.awt.Panel |
java.awt.Panel.AccessibleAWTPanel |
Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock |
Field Summary | |
private java.lang.Thread |
animation
Thread for animation |
private java.awt.Graphics |
backBufferGraphics
Graphic context associate with the back image buffer |
private java.awt.Image |
backBufferImage
Back Image buffer for drawing |
private int |
drawTongue
delay for drawing the tongue |
private int |
eye_x
position of the frog's eye (x) |
private int |
eye_y
position of the frog's eye (y) |
private int |
eyeCenterX
position of the center of frog's eye (x) |
private int |
eyeCenterY
position of the center of frog's eye (y) |
private int |
eyeEmotion
For displaying eye emotion, happy, sad, netural |
private int |
eyeSize
size of the frog's eye |
private int |
eyeXOffset
x offset for drawing the frog's eye |
private int |
eyeYOffset
y offset for drawing the frog's eye |
private FlyCreator |
fc
FlyCreator for creating fly |
private java.awt.Image |
flyImage
Fly image |
private FlyManager |
fm
FlyManager for eating fly |
private java.awt.Image |
frogEatImage
Frog image (eating) |
private int |
frogHeight
Height of the frog image in pixel |
private java.awt.Image |
frogImage
Frog image (still) |
private int |
frogWidth
Width of the frog image in pixel |
private int |
frogY_pos
position of the frog image |
private int |
height
Display Height of the applet |
private int |
mouth_x
position of the mouth(x) |
private int |
mouth_y
position of the mouth(y) |
private long |
refreshRate
rehresh rate in millisecond |
private int |
tongue_x
destination of the tongue (x) |
private int |
tongue_y
destination of the tongue (y) |
private int |
width
Display Width of the applet |
Fields inherited from class java.applet.Applet |
accessibleContext, serialVersionUID, stub |
Fields inherited from class java.awt.Panel |
base, nameCounter |
Fields inherited from class java.awt.Container |
component, containerListener, containerSerializedDataVersion, dbg, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads |
Fields inherited from class java.awt.Component |
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, windowClosingException, windowListenerK, x, y |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
MainApplet()
|
Method Summary | |
void |
destroy()
PRE: NONE POST: Clean up the thread |
private void |
drawFrog(java.awt.Graphics g)
PRE: A valid Graphics object POST: Draw the frog onto the Graphics object |
void |
init()
PRE: NONE POST: Initialize all variables and start all the threads |
void |
mouseClicked(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent object POST: Nothing. |
void |
mouseDragged(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent object POST: Nothing. |
void |
mouseEntered(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent object POST: Nothing. |
void |
mouseExited(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent object POST: set the eye position to center |
void |
mouseMoved(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent object POST: Set eye position according to the mouse movement |
void |
mousePressed(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent object POST: try to eat the fly and set the animations |
void |
mouseReleased(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent object POST: Nothing. |
void |
paint(java.awt.Graphics g)
PRE: A valid Graphics object POST: Paint all the objects |
void |
run()
PRE: NONE POST: Refresh the screen in a timely manner and move the flies too |
void |
setEyePos(int x,
int y)
PRE: NONE POST: set the eye position so that it will stare at that point |
void |
update(java.awt.Graphics g)
PRE: A valid Graphics object POST: Paint all the objects |
Methods inherited from class java.applet.Applet |
getAccessibleContext, 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 |
|
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, adjustListeningChildren, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocus, numListening, paintComponents, paintHeavyweightComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, setLayout, transferFocus, validate, validateTree, writeObject |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait |
Field Detail |
private java.awt.Image frogImage
private java.awt.Image frogEatImage
private java.awt.Image flyImage
private long refreshRate
private java.lang.Thread animation
private FlyManager fm
private FlyCreator fc
private int width
private int height
private int frogHeight
private int frogWidth
private int frogY_pos
private int eye_y
private int eye_x
private int eyeCenterX
private int eyeCenterY
private int eyeSize
private int eyeXOffset
private int eyeYOffset
private int drawTongue
private int tongue_y
private int tongue_x
private int mouth_x
private int mouth_y
private int eyeEmotion
private java.awt.Image backBufferImage
private java.awt.Graphics backBufferGraphics
Constructor Detail |
public MainApplet()
Method Detail |
public void init()
init
in class java.applet.Applet
public void paint(java.awt.Graphics g)
paint
in class java.awt.Container
public void update(java.awt.Graphics g)
update
in class java.awt.Container
private void drawFrog(java.awt.Graphics g)
public void run()
run
in interface java.lang.Runnable
public void setEyePos(int x, int y)
public void destroy()
destroy
in class java.applet.Applet
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |