net.curre.prefcount.gui
Class ScoreBoardLocationsMap

java.lang.Object
  extended by net.curre.prefcount.gui.ScoreBoardLocationsMap

public class ScoreBoardLocationsMap
extends java.lang.Object

This class is a utility to determine locaitons of all items on the score board given the current dimensions of the table/board.

Created date: Jun 16, 2007

Author:
Yevgeny Nyden

Field Summary
 int centerX
          Center's current X coordinate.
 int centerY
          Center's current X coordinate.
 int height
          Current board height.
static int MARGIN
          Number of pixels to leave near the borders.
 int oneFifthY
          Computed 1/5 of the half height value.
 int poolMountDividerX
          Computed pool-mount divider X coordinate.
 int poolMountDividerY
          Computed pool-mount divider Y coordinate.
 int threeFifthX
          Computed 3/5 of the half width value.
 int threeFifthY
          Computed 3/5 of the half height value.
 int twoFifthX
          Computed 2/5 of half width value.
 int twoFifthY
          Computed 2/5 of the half height value.
 int whistDividerX1
          Computed value for whist division lines.
 int whistDividerX2
          Computed value for whist division lines.
 int whistDividerY1
          Computed value for whist division lines.
 int whistDividerY2
          Computed value for whist division lines.
 int whistPoolDividerX
          Computed whist-pool divider X coordinate.
 int whistPoolDividerY
          Computed whist-pool divider Y coordinate.
 int width
          Current board width.
 
Constructor Summary
ScoreBoardLocationsMap(ScoreBoardPanel scoreBoard)
          Constructor.
 
Method Summary
 void computeLocations(int newWidth, int newHeight, int offsetX, int offsetY, boolean force)
          Computes or recomputes if necessary locations of all items on the score board and stores the values in the locationsMap map.
 java.util.Map<ScoreItem,java.awt.geom.Point2D.Double> getLocationsMap(Place place)
          Getter for the locations maps for the given player.
 ScoreItem[] getOtherWhistItems(Place place)
          Gets whist score items for all other players relative to the given player.
 ScoreItem[] getOtherWhistSaldoItems(Place place)
          Gets whist saldo score items for all other players relative to the given player.
 void initialize(int numberOfPlayers)
          Method that initializes properties and computes the locations for the first time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MARGIN

public static final int MARGIN
Number of pixels to leave near the borders.

See Also:
Constant Field Values

width

public int width
Current board width.


height

public int height
Current board height.


centerX

public int centerX
Center's current X coordinate.


centerY

public int centerY
Center's current X coordinate.


twoFifthX

public int twoFifthX
Computed 2/5 of half width value.


threeFifthX

public int threeFifthX
Computed 3/5 of the half width value.


oneFifthY

public int oneFifthY
Computed 1/5 of the half height value.


twoFifthY

public int twoFifthY
Computed 2/5 of the half height value.


threeFifthY

public int threeFifthY
Computed 3/5 of the half height value.


whistPoolDividerX

public int whistPoolDividerX
Computed whist-pool divider X coordinate.


whistPoolDividerY

public int whistPoolDividerY
Computed whist-pool divider Y coordinate.


poolMountDividerX

public int poolMountDividerX
Computed pool-mount divider X coordinate.


poolMountDividerY

public int poolMountDividerY
Computed pool-mount divider Y coordinate.


whistDividerX1

public int whistDividerX1
Computed value for whist division lines.


whistDividerX2

public int whistDividerX2
Computed value for whist division lines.


whistDividerY1

public int whistDividerY1
Computed value for whist division lines.


whistDividerY2

public int whistDividerY2
Computed value for whist division lines.

Constructor Detail

ScoreBoardLocationsMap

public ScoreBoardLocationsMap(ScoreBoardPanel scoreBoard)
Constructor. After the number of players in the game is known (scoreBoard.results.getPlayerStats() is created), the initialize() method must be called.

Parameters:
scoreBoard - Reference to the score board panel.
Method Detail

initialize

public void initialize(int numberOfPlayers)
Method that initializes properties and computes the locations for the first time. This method must be called as soon as the number of players is set (scoreBoard.results.getPlayerStats() is created).

Parameters:
numberOfPlayers - Number of players in the game.
Throws:
java.lang.IllegalArgumentException - If number of players is not supported.

getLocationsMap

public java.util.Map<ScoreItem,java.awt.geom.Point2D.Double> getLocationsMap(Place place)
Getter for the locations maps for the given player.

Parameters:
place - Players place.
Returns:
The locations maps for the given player.

computeLocations

public void computeLocations(int newWidth,
                             int newHeight,
                             int offsetX,
                             int offsetY,
                             boolean force)
Computes or recomputes if necessary locations of all items on the score board and stores the values in the locationsMap map.

Parameters:
newWidth - new width of the score board.
newHeight - new height of the score board.
offsetX - canvas X coordinate.
offsetY - canvas Y coordinate.
force - true will ensure that all locations will get recomputed; when false, the method does nothing if the scoreboard width.

getOtherWhistItems

public ScoreItem[] getOtherWhistItems(Place place)
Gets whist score items for all other players relative to the given player.

Parameters:
place - player's place.
Returns:
whist score items for all opponents of the given player.

getOtherWhistSaldoItems

public ScoreItem[] getOtherWhistSaldoItems(Place place)
Gets whist saldo score items for all other players relative to the given player.

Parameters:
place - player's place.
Returns:
whist saldo score items for all opponents of the given player.


Copyright © 2008. All Rights Reserved.