Glomus.Client.Java
Class GUIclient

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 Glomus.Client.Java.GUIclient
All Implemented Interfaces:
Client, java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer

public class GUIclient
extends javax.swing.JApplet
implements Client, java.awt.event.ActionListener

The GUI client wraps an applet around a basic Glomus game, allowing users to test a private game with other Server-side players. It interfaces with the ServerConnection much the same as a JavaClient, though it allows the GUI user to make the decisions.

The GUIclient is designed as an applet, and depends upon 4 applet parameters: HOST, MAP, BACKGROUND, and PLAYERS. These applet parameters match protected data of the same name, see the fields section for more information

See Also:
Glomus.Client.ServerConnection, 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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.lang.String BACKGROUND
          The background image used by this applet (including path location from CodeBase)
protected  java.lang.String HOST
          The host name at which the GUIclient expects to find a Server running
protected  java.lang.String MAP
          The map image used by this applet (including path location from CodeBase)
protected  int PLAYERS
          The total number of players in the game (GUI player + server players) With a classic setup, there must be between 2 and 6 players per game; the default is 6.
protected  int PORT
          The communication port at which to look for the running Server on the given host
 
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
GUIclient()
           
 
Method Summary
 void accuse(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          A failed accusation overheard (successful ones end the game, and thus do not need to be reported)
 void actionPerformed(java.awt.event.ActionEvent e)
          The general event listener method for all Action Events generated by this GUI.
 void answer(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          Tells the client who won and what the answer was
 void cantRefute(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          A failed refutation overheard
 void endKnowledge(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          Informs the player of what another player in the game knows for certain
 void init()
          Loads and shows the GUI
 void init(java.lang.String identity, java.lang.String startRoom, java.util.HashSet<java.lang.String> suspects, java.util.HashSet<java.lang.String> weapons, java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> rooms, java.util.HashSet<java.lang.String> cards, java.util.ArrayList<java.lang.String> players)
          Initialize the player's knowledgebase with the suspects, weapons, rooms (and their connectivity), and the cards that this player has
 void knows(ServerConnection server)
          Asks what information this player knows for certain (from the case folder)
 void makeAccusation(ServerConnection server)
          A request for this player to make an accusation, if they wish
 void makeSuggestion(ServerConnection server)
          A request for this player to make a suggestion
 void message(java.lang.String message)
          Notifies the client of some user-specific information
 void refute(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player, ServerConnection server)
          A request for this player to refute the claim, if possible
 void refuted(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          A refuted suggestion overheard
 void shows(java.lang.String player, java.lang.String card)
          A refutation of our suggestion from another player
 void start()
          Creates a new game on a the default board with a GUI player and 5 other JavaClients.
 void suggestion(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          A suggestion overheard by all players
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, 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, 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, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, 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, 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
 

Field Detail

HOST

protected java.lang.String HOST
The host name at which the GUIclient expects to find a Server running


PORT

protected final int PORT
The communication port at which to look for the running Server on the given host

See Also:
Constant Field Values

BACKGROUND

protected java.lang.String BACKGROUND
The background image used by this applet (including path location from CodeBase)


MAP

protected java.lang.String MAP
The map image used by this applet (including path location from CodeBase)


PLAYERS

protected int PLAYERS
The total number of players in the game (GUI player + server players) With a classic setup, there must be between 2 and 6 players per game; the default is 6.

Constructor Detail

GUIclient

public GUIclient()
Method Detail

init

public void init(java.lang.String identity,
                 java.lang.String startRoom,
                 java.util.HashSet<java.lang.String> suspects,
                 java.util.HashSet<java.lang.String> weapons,
                 java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> rooms,
                 java.util.HashSet<java.lang.String> cards,
                 java.util.ArrayList<java.lang.String> players)
Initialize the player's knowledgebase with the suspects, weapons, rooms (and their connectivity), and the cards that this player has

Specified by:
init in interface Client
Parameters:
identity - Our name
startRoom - Our starting location
suspects - The set of all suspect names
weapons - The set of all weapon names
rooms - The map of all rooms to a list of adjacent rooms
cards - The set of all cards this player has
players - A list of suspects who are active in the game, in the order they play (if that's important)

suggestion

public void suggestion(java.lang.String suspect,
                       java.lang.String weapon,
                       java.lang.String room,
                       java.lang.String player)
A suggestion overheard by all players

Specified by:
suggestion in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player making the accusation

makeSuggestion

public void makeSuggestion(ServerConnection server)
A request for this player to make a suggestion

Specified by:
makeSuggestion in interface Client
Parameters:
server - The Glomus Server to reply to

makeAccusation

public void makeAccusation(ServerConnection server)
A request for this player to make an accusation, if they wish

Specified by:
makeAccusation in interface Client
Parameters:
server - The Glomus Server to reply to

refute

public void refute(java.lang.String suspect,
                   java.lang.String weapon,
                   java.lang.String room,
                   java.lang.String player,
                   ServerConnection server)
A request for this player to refute the claim, if possible

Specified by:
refute in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player making the accusation
server - The Glomus Server to reply to

refuted

public void refuted(java.lang.String suspect,
                    java.lang.String weapon,
                    java.lang.String room,
                    java.lang.String player)
A refuted suggestion overheard

Specified by:
refuted in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player who refuted the suggestion

cantRefute

public void cantRefute(java.lang.String suspect,
                       java.lang.String weapon,
                       java.lang.String room,
                       java.lang.String player)
A failed refutation overheard

Specified by:
cantRefute in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player who could not refute the suggestion

shows

public void shows(java.lang.String player,
                  java.lang.String card)
A refutation of our suggestion from another player

Specified by:
shows in interface Client
Parameters:
player - The player who is refuting our suggestion
card - A suspect, weapon, or room that they show to us, refuting our claim

accuse

public void accuse(java.lang.String suspect,
                   java.lang.String weapon,
                   java.lang.String room,
                   java.lang.String player)
A failed accusation overheard (successful ones end the game, and thus do not need to be reported)

Specified by:
accuse in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player who failed their accusation

knows

public void knows(ServerConnection server)
Asks what information this player knows for certain (from the case folder)

Specified by:
knows in interface Client
Parameters:
server - The Glomus Server to reply to

endKnowledge

public void endKnowledge(java.lang.String suspect,
                         java.lang.String weapon,
                         java.lang.String room,
                         java.lang.String player)
Informs the player of what another player in the game knows for certain

Specified by:
endKnowledge in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player who knows the given info

answer

public void answer(java.lang.String suspect,
                   java.lang.String weapon,
                   java.lang.String room,
                   java.lang.String player)
Tells the client who won and what the answer was

Specified by:
answer in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player who won the game

message

public void message(java.lang.String message)
Notifies the client of some user-specific information

Specified by:
message in interface Client
Parameters:
message - The message to pass onto the user

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
The general event listener method for all Action Events generated by this GUI. When an event is received, it will be processed and the appropriate action will be taken

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - The Event generated and received

start

public void start()
Creates a new game on a the default board with a GUI player and 5 other JavaClients. Runs the applet.

Overrides:
start in class java.applet.Applet

init

public void init()
Loads and shows the GUI

Overrides:
init in class java.applet.Applet