gameboard
Class AbsThreadedJP

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 gameboard.AbsThreadedJP
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, javax.accessibility.Accessible
Direct Known Subclasses:
OthelloCell, ScorePanel, SplashPanel

public abstract class AbsThreadedJP
extends javax.swing.JPanel
implements java.lang.Runnable, java.io.Serializable

Last updated September 27, 2006
An abstract threaded JPanel that can be used to create animated game panels.

Version:
m.6
Author:
Eric Angeli
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 java.lang.Thread runner
          Handles the games animation thread.
 
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
AbsThreadedJP()
          Creates a new instance of AbsThreadedJP
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds the property change listener.
 java.awt.Color getBgColor()
          Gets the background color
 int getBoard()
          Gets the board being used.
 java.awt.Graphics2D getG2d()
          Returns the graphics of the double buffered image.
 int getGameSleep()
          Gets the ammount of time the between animation steps.
 int getLevel()
          Gets the current level.
 java.beans.PropertyChangeSupport getPropertySupport()
          Gets the property change support.
 void init()
          Initializes the panel components.
 boolean isPauseGame()
          Gets the current pause state of the game.
 void paintGame()
          Paints the game area to the panel.
 void pauseGame(boolean pg)
          Sets the pause state of the game.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes the property change listener.
 void renderPanel()
          Renders the panel to the screen.
abstract  void renderSprites(java.awt.Graphics2D g)
          Renders the sprites onto the panel.
 void resumeGame()
          Restarts the game.
 void run()
          Handles running the thread.
 void setBgColor(java.awt.Color bgColor)
          Sets the color of the background.
 void setBoard(int brd)
          Sets which board is being used.
 void setGameSleep(int gameSleep)
          Sets the sleep time for the animation loop.
 void setLevel(int level)
          Sets the level.
 void setPauseGame(boolean pauseGame)
          Sets the current pause state of the game.
 void startGame()
          Starts the game.
 void stopGame()
          Stops the game.
abstract  void updateGame()
          Updates the playing are for the game.
 
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, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, 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, 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, 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

runner

public java.lang.Thread runner
Handles the games animation thread.

Constructor Detail

AbsThreadedJP

public AbsThreadedJP()
Creates a new instance of AbsThreadedJP

Method Detail

updateGame

public abstract void updateGame()
Updates the playing are for the game.


renderSprites

public abstract void renderSprites(java.awt.Graphics2D g)
Renders the sprites onto the panel.

Parameters:
g - The graphics used for painting.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds the property change listener.

Overrides:
addPropertyChangeListener in class java.awt.Container
Parameters:
listener - The new listener.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the property change listener.

Overrides:
removePropertyChangeListener in class java.awt.Component
Parameters:
listener - The listener to remove.

getPropertySupport

public java.beans.PropertyChangeSupport getPropertySupport()
Gets the property change support.

Returns:
The property change support.

init

public void init()
Initializes the panel components.


startGame

public void startGame()
Starts the game.


run

public void run()
Handles running the thread.
Contains the animation loop.

Specified by:
run in interface java.lang.Runnable

stopGame

public void stopGame()
Stops the game.


resumeGame

public void resumeGame()
Restarts the game.


renderPanel

public void renderPanel()
Renders the panel to the screen.


pauseGame

public void pauseGame(boolean pg)
Sets the pause state of the game.

Parameters:
pg - The new pause state of the game.

getG2d

public java.awt.Graphics2D getG2d()
Returns the graphics of the double buffered image.

Returns:
The Graphics2D of dbImage

paintGame

public void paintGame()
Paints the game area to the panel.


isPauseGame

public boolean isPauseGame()
Gets the current pause state of the game.

Returns:
The current pause state.

setPauseGame

public void setPauseGame(boolean pauseGame)
Sets the current pause state of the game.

Parameters:
pauseGame - The new pause state of the game.

getLevel

public int getLevel()
Gets the current level.

Returns:
The current level.

setLevel

public void setLevel(int level)
Sets the level.

Parameters:
level - The new level.

getGameSleep

public int getGameSleep()
Gets the ammount of time the between animation steps.

Returns:
The sleep time.

setBoard

public void setBoard(int brd)
Sets which board is being used.

Parameters:
brd - The new board to use.

getBoard

public int getBoard()
Gets the board being used.

Returns:
The board being used.

setGameSleep

public void setGameSleep(int gameSleep)
Sets the sleep time for the animation loop.

Parameters:
gameSleep - The new sleep time.

getBgColor

public java.awt.Color getBgColor()
Gets the background color

Returns:
Color - The back ground color of the panel.

setBgColor

public void setBgColor(java.awt.Color bgColor)
Sets the color of the background.

Parameters:
bgColor - The new background color.