ks.client.gamefactory
Class PlayerRanking

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--ks.client.gamefactory.PlayerRanking
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class PlayerRanking
extends java.awt.Canvas

See Also:
Serialized Form

Field Summary
protected  int barHeight
           
protected  int[] gamesWon
          num Games Won (no more than six players per table)
static int maxNameSize
          Maximum name size.
protected  int nameOffset
           
protected  int nameWidth
          Default visual parameters
 int numPlayers
          The number of players in the game.
protected  int padding
           
protected  java.lang.String[] players
          User info (no more than six players per table)
protected  int[] points
          points info (no more than six players per table)
 
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
PlayerRanking()
          PlayerRanking constructor comment.
PlayerRanking(int width, int height)
          PlayerRanking constructor.
 
Method Summary
 void addUser(java.lang.String name)
          Add to this display the player with specific name.
 int getBarHeight()
          Return the height of each bar showing player scores.
 int getNameOffset()
          Return the offset where players' names can be drawn.
 int getNameWidth()
          Return the width (in pixels) of each player's name Creation date: (9/25/01 10:29:35 PM)
 int getNumPlayers()
          Return the number of players.
 int getPadding()
          Return the padding between player name and score Creation date: (9/25/01 10:54:54 PM)
 void paint(java.awt.Graphics g)
          Paint this object.
 void removeUser(java.lang.String name)
          Remove user from display Creation date: (9/25/01 9:29:43 PM)
 void setBarHeight(int newBarHeight)
          Set the height of each bar.
 void setNameOffset(int newNameOffset)
          Set the offset for names.
 void setNameWidth(int newNameWidth)
          Set the allowed width for each name.
 void setPadding(int newPadding)
          Set the padding to use between name and scores.
protected  void sortPlayers()
          Sort all players in reverse order.
 void updatePlayerInfo(java.lang.String name, int numHandsWon, int points)
          Update the points for this player, including points (accumulated), number of hands won.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

players

protected java.lang.String[] players
User info (no more than six players per table)


points

protected int[] points
points info (no more than six players per table)


gamesWon

protected int[] gamesWon
num Games Won (no more than six players per table)


numPlayers

public int numPlayers
The number of players in the game.


maxNameSize

public static final int maxNameSize
Maximum name size.

See Also:
Constant Field Values

nameWidth

protected int nameWidth
Default visual parameters


nameOffset

protected int nameOffset

barHeight

protected int barHeight

padding

protected int padding
Constructor Detail

PlayerRanking

public PlayerRanking()
PlayerRanking constructor comment.


PlayerRanking

public PlayerRanking(int width,
                     int height)
PlayerRanking constructor. Pass in width/height and setCanvas size accordingly.

Method Detail

addUser

public void addUser(java.lang.String name)
Add to this display the player with specific name. Creation date: (9/25/01 9:29:43 PM)

Parameters:
name - java.lang.String

getBarHeight

public int getBarHeight()
Return the height of each bar showing player scores. Creation date: (9/25/01 10:34:37 PM)

Returns:
int

getNameOffset

public int getNameOffset()
Return the offset where players' names can be drawn. Creation date: (9/25/01 10:33:26 PM)

Returns:
int

getNameWidth

public int getNameWidth()
Return the width (in pixels) of each player's name Creation date: (9/25/01 10:29:35 PM)

Returns:
int

getNumPlayers

public int getNumPlayers()
Return the number of players. Creation date: (9/25/01 9:36:22 PM)

Returns:
int

getPadding

public int getPadding()
Return the padding between player name and score Creation date: (9/25/01 10:54:54 PM)

Returns:
int

paint

public void paint(java.awt.Graphics g)
Paint this object. A list of rows, each of the form User (pts) followed by a box proportional to 1.5 times the largest point count so far. The rows are ordered by games won, followed next by points. Creation date: (9/25/01 9:32:14 PM)

Overrides:
paint in class java.awt.Canvas
Parameters:
g - java.awt.Graphics

removeUser

public void removeUser(java.lang.String name)
Remove user from display Creation date: (9/25/01 9:29:43 PM)

Parameters:
name - java.lang.String

setBarHeight

public void setBarHeight(int newBarHeight)
Set the height of each bar. Creation date: (9/25/01 10:34:37 PM)

Parameters:
newBarHeight - int

setNameOffset

public void setNameOffset(int newNameOffset)
Set the offset for names. Creation date: (9/25/01 10:33:26 PM)

Parameters:
newNameOffset - int

setNameWidth

public void setNameWidth(int newNameWidth)
Set the allowed width for each name. Creation date: (9/25/01 10:29:35 PM)

Parameters:
newNameWidth - int

setPadding

public void setPadding(int newPadding)
Set the padding to use between name and scores. Creation date: (9/25/01 10:54:54 PM)

Parameters:
newPadding - int

sortPlayers

protected void sortPlayers()
Sort all players in reverse order. First by num games won (descending), then by total points (descending), then by name (ascending) Creation date: (9/25/01 9:35:30 PM)


updatePlayerInfo

public void updatePlayerInfo(java.lang.String name,
                             int numHandsWon,
                             int points)
Update the points for this player, including points (accumulated), number of hands won. After each update, sort (may be inefficient, but number of entries will be <= 6 Creation date: (9/25/01 9:30:44 PM)

Parameters:
name - java.lang.String
numHandsWon - int
points - int