java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
com.jdwsoftware.wfh.control.GameComponent
- All Implemented Interfaces:
- java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
- public class GameComponent
- extends javax.swing.JComponent
Title: Woody's Fishing Hole
Description: Educational Fishing Game
Copyright: Copyright (C) 2003 JDW Software, LLC
Company: JDW Software, LLC
This is the heart of the game. This component displays most
of the graphics, handles game logic, creates fish, pretty much
all the logic for the game.
This class consists of 2 major parts, the main class which
sets up all the graphics figures out how many fish are displayed,
paints the fish and handles events. The second is a seperate thread
that calculates movement for the fish. The calculations are done
on a seperate thread in an attempt to not slow down the redrawing
thread. In general, since the fish won't be moving very fast there
is no synchronization, if things are off they'll be right hopefully
in 1/5 of a second...
- Version:
- $Revision: 1.8 $
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Fields inherited from class java.awt.Container |
|
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, 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, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, 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, 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, processMouseEvent, 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, transferFocusBackward, transferFocusUpCycle |
COPYRIGHT
private static final java.lang.String COPYRIGHT
- See Also:
- Constant Field Values
VERSION
private static final java.lang.String VERSION
- See Also:
- Constant Field Values
DELAY
private static final long DELAY
- See Also:
- Constant Field Values
GT_COLOR
private static final int GT_COLOR
- See Also:
- Constant Field Values
GT_NUM
private static final int GT_NUM
- See Also:
- Constant Field Values
GT_MATH
private static final int GT_MATH
- See Also:
- Constant Field Values
MAX_FISH
private static final int MAX_FISH
- See Also:
- Constant Field Values
DEFAULT_NUM_FISH
private static final int DEFAULT_NUM_FISH
- See Also:
- Constant Field Values
GAME_TYPES
private static final java.lang.String[] GAME_TYPES
CEILING
private static final float CEILING
- See Also:
- Constant Field Values
_paused
private boolean _paused
_background
private java.awt.Image _background
_hook
private java.awt.Image _hook
_fishImages
private java.awt.Image[] _fishImages
_upFishImages
private java.awt.Image[] _upFishImages
mouseLoc
private java.awt.Point mouseLoc
r
private java.util.Random r
_fishes
private com.jdwsoftware.wfh.model.Fish[] _fishes
_enteringFish
private com.jdwsoftware.wfh.model.Fish _enteringFish
_exittingFish
private com.jdwsoftware.wfh.model.Fish _exittingFish
_statusBar
private javax.swing.JLabel _statusBar
_width
private int _width
_height
private int _height
_fishWidth
private int _fishWidth
_fishHeight
private int _fishHeight
_gameType
private int _gameType
_numFish
private int _numFish
_currentGame
private com.jdwsoftware.wfh.model.GameType _currentGame
_calcThread
private GameComponent.CalculationThread _calcThread
GameComponent
public GameComponent()
- Default constructor
setStatusBar
public void setStatusBar(javax.swing.JLabel statusBar)
- If the main component has a status bar, it should register that
status bar here so messages can be displayed.
loadCurrentGame
private void loadCurrentGame()
pauseGame
public void pauseGame(boolean pause)
paintComponent
protected void paintComponent(java.awt.Graphics g)
- Description copied from class:
javax.swing.JComponent
- Paint the component's body. This usually means calling ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)>
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent) 55 on the JComponent.ui>JComponent.ui 55 property of the component, if
it is non-null. You may override this if you wish to
customize the component's body-painting behavior. The component's body
is painted first, before the border and children.
getPreferredSize
public java.awt.Dimension getPreferredSize()
- Get the preferred size of this component.
notifyMouseMoved
public void notifyMouseMoved(java.awt.Point p)
- Keep track of the current mouse location by being notified
of mouse movements here.
setGameType
public void setGameType(java.lang.String gameType)
- Set the game type and then invalidate the current
game so a new game can be created
notifyMouseClicked
public void notifyMouseClicked(java.awt.Point p)
- Handle a mouse click. If the click happens on a fish with the
correct answer, start the correct answer actions.
getNumFish
public int getNumFish()
- Get the current number of fish being displayed
setNumFish
public void setNumFish(int numFish)
- Set the number of fish to display. Also resets any current
fish.