gecco.client
Class Game

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--gecco.client.Game
All Implemented Interfaces:
Accessible, Animator, Client, ImageObserver, MenuContainer, RootPaneContainer, Serializable, WindowConstants

public class Game
extends JFrame
implements Client, Animator

This is the main game class. It contains the complete client for an arbitrary game.

Author:
Andreas Enblom
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Inner classes inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Inner classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Inner classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
Component.AccessibleAWTComponent
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Game(String gameTitle)
          Constructor for the Game object
 
Method Summary
 void abortExecutingAction(Piece p)
          Aborts the currently executing action of the given piece.
 void abortExecutingAction(Piece p, boolean abortAll)
          Aborts the currently executing action of the given piece.
 void actionReply(long id, boolean ok)
          Description of the Method
 void addPiece(int handle, String name, Position pos, Set actions, Map properties, String type)
          Adds the specified piece, as described in Client.java.
 void addPieceAction(int handle, Action a)
          Adds a feature to the PieceAction attribute of the Game object
 void animationDone(AnimatedPiece p)
          Description of the Method
 void connectionLost()
          Description of the Method
 void destroyPiece(int handle)
          Description of the Method
 Piece getPieceAt(Point point)
          Returns the piece at the given point of the board, or null if no such piece exists.
 Enumeration getPiecesIntersecting(Rectangle rect)
          Returns all pieces of the game that intersect the given rectangle.
 Position getPreferredCenter()
          Returns the preferred center of the map.
 Enumeration getSelectedPiecePositions()
          Returns the positions of the queued actions (and the currently executing action) of the selected piece, or NULL if no piece is selected.
 void hideMapPoint(int x, int y)
          Makes an automaton in the map invisible.
 void hideMapPoints(int[] x, int[] y)
          Makes a number of automatons invisible.
static void main(String[] argv)
          Main method for program start.
 void mapLoadingProgressUpdate(double progress)
          Description of the Method
 void mapUpdate(int[] x, int[] y, int[] colors)
          Description of the Method
 void mapUpdate(int x, int y, int color)
          Description of the Method
 void removePiece(int handle)
          Description of the Method
 void removePieceAction(int handle, Action a)
          Description of the Method
 void repaintAnimation(AnimatedPiece p)
          Description of the Method
 void timeUpdate(String time)
          Description of the Method
 void unitMessage(int handle, String message)
          Description of the Method
 void updatePiece(int handle, Position newPosition)
          Description of the Method
 void updatePiece(int handle, Property[] newProperties)
          Description of the Method
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, isResizable, remove, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, dispose, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Constructor Detail

Game

public Game(String gameTitle)
Constructor for the Game object
Parameters:
gameTitle - Description of Parameter
Method Detail

getPieceAt

public Piece getPieceAt(Point point)
Returns the piece at the given point of the board, or null if no such piece exists.
Parameters:
point - Description of Parameter
Returns:
The PieceAt value

getPiecesIntersecting

public Enumeration getPiecesIntersecting(Rectangle rect)
Returns all pieces of the game that intersect the given rectangle. The rectangle is in actual screen coordinates, relative to the component of the board where the map and the pieces are painted.
Parameters:
rect - Description of Parameter
Returns:
The PiecesIntersecting value

getPreferredCenter

public Position getPreferredCenter()
Returns the preferred center of the map. This is the center of the current screen or, if there is a selected piece, the position of the selected piece. The preferred center is the center around which the board will zoom in and out.
Returns:
The preferred center of the map.

getSelectedPiecePositions

public Enumeration getSelectedPiecePositions()
Returns the positions of the queued actions (and the currently executing action) of the selected piece, or NULL if no piece is selected. The position of an action is the position of its argument (if any). The collection points is started with the position of the selected piece.
Returns:
The SelectedPiecePositions value

mapUpdate

public void mapUpdate(int[] x,
                      int[] y,
                      int[] colors)
Description of the Method
Specified by:
mapUpdate in interface Client
Parameters:
x - Description of Parameter
y - Description of Parameter
colors - Description of Parameter

mapUpdate

public void mapUpdate(int x,
                      int y,
                      int color)
Description of the Method
Specified by:
mapUpdate in interface Client
Parameters:
x - Description of Parameter
y - Description of Parameter
color - Description of Parameter

hideMapPoints

public void hideMapPoints(int[] x,
                          int[] y)
Makes a number of automatons invisible.
Specified by:
hideMapPoints in interface Client
Parameters:
x - A vector of automaton x coordinates.
y - A vector of automaton y coordinates.

hideMapPoint

public void hideMapPoint(int x,
                         int y)
Makes an automaton in the map invisible.
Specified by:
hideMapPoint in interface Client
Parameters:
x - The x coordinate of the automaton.
y - The y coordinate of the automaton.

unitMessage

public void unitMessage(int handle,
                        String message)
Description of the Method
Specified by:
unitMessage in interface Client
Parameters:
handle - Description of Parameter
message - Description of Parameter

timeUpdate

public void timeUpdate(String time)
Description of the Method
Specified by:
timeUpdate in interface Client
Parameters:
time - Description of Parameter

addPiece

public void addPiece(int handle,
                     String name,
                     Position pos,
                     Set actions,
                     Map properties,
                     String type)
Adds the specified piece, as described in Client.java. If there is a ghost piece with the same type and position, that ghost piece will be removed and replaced with the new piece. If the ghost is selected, the selection will carry over to the new piece.
Specified by:
addPiece in interface Client
Parameters:
handle - The feature to be added to the Piece attribute
name - The feature to be added to the Piece attribute
pos - The feature to be added to the Piece attribute
actions - The feature to be added to the Piece attribute
properties - The feature to be added to the Piece attribute
type - The feature to be added to the Piece attribute

updatePiece

public void updatePiece(int handle,
                        Property[] newProperties)
Description of the Method
Specified by:
updatePiece in interface Client
Parameters:
handle - Description of Parameter
newProperties - Description of Parameter

updatePiece

public void updatePiece(int handle,
                        Position newPosition)
Description of the Method
Specified by:
updatePiece in interface Client
Parameters:
handle - Description of Parameter
newPosition - Description of Parameter

removePiece

public void removePiece(int handle)
Description of the Method
Specified by:
removePiece in interface Client
Parameters:
handle - Description of Parameter

destroyPiece

public void destroyPiece(int handle)
Description of the Method
Specified by:
destroyPiece in interface Client
Parameters:
handle - Description of Parameter

addPieceAction

public void addPieceAction(int handle,
                           Action a)
Adds a feature to the PieceAction attribute of the Game object
Specified by:
addPieceAction in interface Client
Parameters:
handle - The feature to be added to the PieceAction attribute
a - The feature to be added to the PieceAction attribute

removePieceAction

public void removePieceAction(int handle,
                              Action a)
Description of the Method
Specified by:
removePieceAction in interface Client
Parameters:
handle - Description of Parameter
a - Description of Parameter

actionReply

public void actionReply(long id,
                        boolean ok)
Description of the Method
Specified by:
actionReply in interface Client
Parameters:
id - Description of Parameter
ok - Description of Parameter
message - Description of Parameter

connectionLost

public void connectionLost()
Description of the Method
Specified by:
connectionLost in interface Client

mapLoadingProgressUpdate

public void mapLoadingProgressUpdate(double progress)
Description of the Method
Specified by:
mapLoadingProgressUpdate in interface Client
Parameters:
progress - Description of Parameter

repaintAnimation

public void repaintAnimation(AnimatedPiece p)
Description of the Method
Specified by:
repaintAnimation in interface Animator
Parameters:
p - Description of Parameter

animationDone

public void animationDone(AnimatedPiece p)
Description of the Method
Specified by:
animationDone in interface Animator
Parameters:
p - Description of Parameter

abortExecutingAction

public void abortExecutingAction(Piece p,
                                 boolean abortAll)
Aborts the currently executing action of the given piece. Optionally, all queued actions are aborted, if not the next action in queue is executed.
Parameters:
p - The piece.
abortAll - Indiactes whether or not all executing actions should be aborted.

abortExecutingAction

public void abortExecutingAction(Piece p)
Aborts the currently executing action of the given piece. The next action in queue is then executed.
Parameters:
p - Description of Parameter

main

public static void main(String[] argv)
Main method for program start.
Parameters:
argv - The command line arguments