public class ResultOverlay
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
ResultOverlay.AveragePlayer
Dummy player instance that averages play results.
|
Modifier and Type | Field and Description |
---|---|
private Player |
average
Dummy player returning average player data.
|
private static int |
BAR_HEIGHT
Maximum height of a bar in the bar chart.
|
private static int |
BAR_WIDTH
Width of a bar chart bar.
|
private static int |
BORDER_GAP
Space between titled borders.
|
private static int |
CROWN_GAP
Gap between the crown and the winning player name.
|
private boolean |
enabled
Whether or not this overlay is enabled and currently showing.
|
private static int |
GAP
Gap between main result screen components (title, bars, stats, graph).
|
private static int |
GRAPH_HEIGHT
Height of the graph.
|
private static double |
GRAPH_MARKER_INTERVAL
Score interval at which score markers are placed in the graph.
|
private static double |
GRAPH_MARKER_OFFSET
The minimum score a player score has to be past a marker for a
new top marker to be generated.
|
static int |
MAX_WIDTH
Maximum width of the information part of the menu.
|
private java.awt.geom.Rectangle2D |
menuBounds
The bounds of the main menu button if present.
|
private static int |
ROUND_RADIUS
Bar chart bar corner rounding radius.
|
private java.awt.geom.Rectangle2D |
seedBounds
The bounds of the seed display field.
|
private GameState |
state
The active/completed game.
|
private static int |
TEXT_OFFSET
Internal titled border offset to the text inside.
|
private Player |
winner
The player that is currently winning.
|
Modifier | Constructor and Description |
---|---|
protected |
ResultOverlay(GameState state)
Constructs a new result overlay for the given game.
|
Modifier and Type | Method and Description |
---|---|
private float |
computeBarStart(int i,
int players,
int width)
Computes the horizontal offset the left edge of the bar
for the player with the given index is at.
|
private java.lang.String |
formatTime(long ms)
Formats the given time in milliseconds to something
human readable with seconds as the smallest unit and
milliseconds as the precision.
|
protected boolean |
handleMouseClick(java.awt.geom.Point2D loc)
Handles a mouse click on the result screen.
|
boolean |
isEnabled()
Checks if this overlay is enabled and showing.
|
protected boolean |
render(java.awt.Graphics2D g,
int width,
int height,
java.awt.geom.Point2D mouseLoc)
Renders this overlay if it is enabled.
|
private void |
renderBars(java.awt.Graphics2D g,
int width)
Renders the bar chart shown on the result screen.
|
private void |
renderBorder(java.awt.Graphics2D g,
float x,
float y,
float w,
float h,
java.lang.String title)
Renders a titled border with the given location, dimensions and title.
|
private void |
renderGraph(java.awt.Graphics2D g,
int size)
Renders the graph shown on the result screen.
|
private void |
renderStats(java.awt.Graphics2D g,
int width)
Renders the statistics shown on the result screen.
|
protected void |
setEnabled(boolean enabled)
Enables or disables this overlay.
|
public static final int MAX_WIDTH
private static final int GAP
private static final int BAR_HEIGHT
private static final int BAR_WIDTH
private static final int ROUND_RADIUS
private static final int CROWN_GAP
private static final int BORDER_GAP
private static final int TEXT_OFFSET
private static final int GRAPH_HEIGHT
private static final double GRAPH_MARKER_INTERVAL
private static final double GRAPH_MARKER_OFFSET
private boolean enabled
private Player winner
private GameState state
private Player average
private java.awt.geom.Rectangle2D menuBounds
private java.awt.geom.Rectangle2D seedBounds
protected ResultOverlay(GameState state)
state
- The game to show results for.protected boolean handleMouseClick(java.awt.geom.Point2D loc)
loc
- The point to check.protected void setEnabled(boolean enabled)
enabled
- True if the overlay should be shown,
false otherwise.public boolean isEnabled()
protected boolean render(java.awt.Graphics2D g, int width, int height, java.awt.geom.Point2D mouseLoc)
g
- The graphics to use for rendering.width
- The current width of the viewport.height
- The current height of the viewport.mouseLoc
- The current location of the cursor.isEnabled()
private void renderBars(java.awt.Graphics2D g, int width)
g
- The graphics context to use.width
- The width of the results section.private float computeBarStart(int i, int players, int width)
i
- The index of the player to compute the offset for.players
- The total number of players in the game.width
- The width of the results section.private void renderStats(java.awt.Graphics2D g, int width)
g
- The graphics context to use.width
- The width of the results section.private java.lang.String formatTime(long ms)
ms
- The millisecond time to format.private void renderBorder(java.awt.Graphics2D g, float x, float y, float w, float h, java.lang.String title)
g
- The graphics context to use.x
- The x-coordinate of the upper left corner of the border to render.y
- The y-coordinate of the upper left corner of the border to render.w
- The width of the border.h
- The height of the border.title
- The title to display on the border.private void renderGraph(java.awt.Graphics2D g, int size)
g
- The graphics context to use.size
- The width of the results section.