org.dartra.standard.visitor
Class ThrowStatisticsVisitor

java.lang.Object
  extended byorg.dartra.standard.visitor.ThrowStatisticsVisitor
All Implemented Interfaces:
GameVisitor

public class ThrowStatisticsVisitor
extends java.lang.Object
implements GameVisitor

A game visitor that gathers throw related statistics for a standard game.

Author:
Erwin Vervaet, Bieke Meeussen

Field Summary
protected  java.util.Hashtable playerStats
           
 
Constructor Summary
ThrowStatisticsVisitor(boolean composed)
          Create a new throw statistics visitor.
 
Method Summary
protected  int countThrowsWhere(Player player, Condition cond)
          Returns the number of throws for given player that comply to given condition.
 double getAverageAccuracy(Player player, boolean includeCalculatedLocations)
          Calculate the average accuracy for given player, expressed in centimeters (cm).
 double getAverageHorizontalAccuracy(Player player, boolean includeCalculatedLocations)
          Calculate the average horizontal accuracy for given player, expressed in centimeters (cm).
 double getAverageVerticalAccuracy(Player player, boolean includeCalculatedLocations)
          Calculate the average vertical accuracy for given player, expressed in centimeters (cm).
 int getNrBounceOuts(Player player)
          Get the total number of bounce-outs given player had in the game.
 int getNrIllegalThrows(Player player)
          Get the total number of illegals throws for given player in the game.
 int getNrOutOfBounds(Player player)
          Get the total number of out-of-bounds throws for given player in the game.
 int getNrThrows(Player player)
          Get the total number of throws for given player in the game.
 int getNrThrowsIn(Player player)
          Get the total number of throws for given player in the game that were in, that is: not out-of-bounds.
 int getNrTurns(Player player)
          Get the total number of turns for given player in the game.
 int getNrZoneHits(Player player, Zone zone)
          Get the total number of times the given player hit specified zone during the game.
 int getTotalNrThrows()
          Get the total number of throws in the game.
 int getTotalNrTurns()
          Get the total number of turns in the game.
 double getZoneAccuracyPercentage(Player player)
          Get the zone accuracy for given player in the game.
 double getZonePercentage(Player player, Zone zone)
          Get the percentage of the throws for given player that hit given zone.
 boolean isComposed()
          Returns whether or not this visitor composes match data.
 void visitGame(Game game)
          Process game data.
 void visitMatch(Match match)
          Process match data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

playerStats

protected java.util.Hashtable playerStats
Constructor Detail

ThrowStatisticsVisitor

public ThrowStatisticsVisitor(boolean composed)

Create a new throw statistics visitor. When composed is set, all the data for all the games in a match will be composed. When not set, only the data directly related to the match will be processed.

Method Detail

isComposed

public boolean isComposed()

Returns whether or not this visitor composes match data.


visitGame

public void visitGame(Game game)
Description copied from interface: GameVisitor

Process game data.

Specified by:
visitGame in interface GameVisitor

visitMatch

public void visitMatch(Match match)
Description copied from interface: GameVisitor

Process match data.

Specified by:
visitMatch in interface GameVisitor

countThrowsWhere

protected int countThrowsWhere(Player player,
                               Condition cond)

Returns the number of throws for given player that comply to given condition.


getTotalNrTurns

public int getTotalNrTurns()

Get the total number of turns in the game.


getTotalNrThrows

public int getTotalNrThrows()

Get the total number of throws in the game.


getNrTurns

public int getNrTurns(Player player)

Get the total number of turns for given player in the game.


getNrThrows

public int getNrThrows(Player player)

Get the total number of throws for given player in the game.


getNrThrowsIn

public int getNrThrowsIn(Player player)

Get the total number of throws for given player in the game that were in, that is: not out-of-bounds.


getNrIllegalThrows

public int getNrIllegalThrows(Player player)

Get the total number of illegals throws for given player in the game.


getNrOutOfBounds

public int getNrOutOfBounds(Player player)

Get the total number of out-of-bounds throws for given player in the game.


getNrBounceOuts

public int getNrBounceOuts(Player player)

Get the total number of bounce-outs given player had in the game.


getNrZoneHits

public int getNrZoneHits(Player player,
                         Zone zone)

Get the total number of times the given player hit specified zone during the game.


getZoneAccuracyPercentage

public double getZoneAccuracyPercentage(Player player)

Get the zone accuracy for given player in the game. This is the percentage of times the player hit the zone that he targetted.


getZonePercentage

public double getZonePercentage(Player player,
                                Zone zone)

Get the percentage of the throws for given player that hit given zone. For instance, if half of the player's throws were targetted at given zone, 50.0 % would be the result.


getAverageHorizontalAccuracy

public double getAverageHorizontalAccuracy(Player player,
                                           boolean includeCalculatedLocations)

Calculate the average horizontal accuracy for given player, expressed in centimeters (cm).

Parameters:
includeCalculatedLocations - If not set, hits with calculated locations will not be taken into account.

getAverageVerticalAccuracy

public double getAverageVerticalAccuracy(Player player,
                                         boolean includeCalculatedLocations)

Calculate the average vertical accuracy for given player, expressed in centimeters (cm).

Parameters:
includeCalculatedLocations - If not set, hits with calculated locations will not be taken into account.

getAverageAccuracy

public double getAverageAccuracy(Player player,
                                 boolean includeCalculatedLocations)

Calculate the average accuracy for given player, expressed in centimeters (cm). This indicates how for on average the player throws from the targetted location.

Parameters:
includeCalculatedLocations - If not set, hits with calculated locations will not be taken into account.