jrummikub.view.impl
Class StonePainter
java.lang.Object
jrummikub.view.impl.StonePainter
class StonePainter
- extends java.lang.Object
The StonePainter paints stones and converts between pixel and grid
coordinates
Method Summary |
private static java.awt.Color |
brighter(java.awt.Color color)
|
(package private) Position |
calculatePosition(int x,
int y)
|
private static int |
even(double f)
|
(package private) static java.awt.Color |
getColor(StoneColor color)
|
(package private) int |
getStoneHeight()
|
private java.awt.image.BufferedImage |
getStoneImage(StoneColor color,
int value,
StonePainter.StoneState state,
boolean hovered)
|
(package private) int |
getStoneWidth()
|
private static java.awt.Color |
hover(java.awt.Color color)
|
private void |
paintCircle(java.awt.Graphics2D g,
java.awt.Rectangle r,
java.awt.Color background)
|
private void |
paintJoker(java.awt.Graphics2D g,
java.awt.Rectangle r,
java.awt.Color color)
|
private void |
paintJokerFace(java.awt.Graphics2D g,
java.awt.Rectangle r)
|
(package private) void |
paintStone(java.awt.Graphics2D g,
Stone stone,
Position p,
StonePainter.StoneState state,
boolean hovered)
Paints a stone |
private void |
paintStoneBackground(java.awt.Graphics2D g,
java.awt.Rectangle r,
java.awt.Color background)
|
private void |
paintStoneValue(java.awt.Graphics2D g,
java.awt.Rectangle r,
java.awt.Color color,
int v)
|
private java.awt.image.BufferedImage |
prepaintStone(java.awt.Color fg,
java.awt.Color bg,
int value)
|
private static java.awt.Color |
redden(java.awt.Color color)
|
private void |
resetPrepaint()
|
(package private) void |
setScale(double scale)
Sets the new grid scale |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ASPECT_RATIO
private static final double ASPECT_RATIO
- See Also:
- Constant Field Values
DEFAULT_WIDTH
private static final double DEFAULT_WIDTH
- See Also:
- Constant Field Values
TEXT_POS
private static final double TEXT_POS
- See Also:
- Constant Field Values
FACE_WIDTH
private static final double FACE_WIDTH
- See Also:
- Constant Field Values
CIRCLE_POS
private static final double CIRCLE_POS
- See Also:
- Constant Field Values
CIRCLE_WIDTH
private static final double CIRCLE_WIDTH
- See Also:
- Constant Field Values
BACKGROUND_COLOR
private static final java.awt.Color BACKGROUND_COLOR
BRIGHTER_SCALE
private static final double BRIGHTER_SCALE
- See Also:
- Constant Field Values
HOVER_RATIO
private static final double HOVER_RATIO
- See Also:
- Constant Field Values
REDDEN_RATIO
private static final double REDDEN_RATIO
- See Also:
- Constant Field Values
defaultStones
private java.util.Map<StonePainter.StoneState,java.util.Map<StoneColor,java.util.Map<java.lang.Integer,java.awt.image.BufferedImage>>> defaultStones
hoveredStones
private java.util.Map<StonePainter.StoneState,java.util.Map<StoneColor,java.util.Map<java.lang.Integer,java.awt.image.BufferedImage>>> hoveredStones
WIDTH_SCALE
static final double WIDTH_SCALE
- The width of one pixel in the scale of 1.0
- See Also:
- Constant Field Values
HEIGHT_SCALE
static final double HEIGHT_SCALE
- The height of one pixel in the scale of 1.0
- See Also:
- Constant Field Values
scale
private double scale
StonePainter
StonePainter(double scale)
- Parameters:
scale
- the scaling factor for the grid coordinates
even
private static int even(double f)
brighter
private static java.awt.Color brighter(java.awt.Color color)
hover
private static java.awt.Color hover(java.awt.Color color)
redden
private static java.awt.Color redden(java.awt.Color color)
getColor
static java.awt.Color getColor(StoneColor color)
setScale
void setScale(double scale)
- Sets the new grid scale
- Parameters:
scale
- the new scale
calculatePosition
Position calculatePosition(int x,
int y)
- Parameters:
x
- x position in screen coordinatesy
- y position in screen coordinates
- Returns:
- position in grid coordinates
getStoneWidth
int getStoneWidth()
- Returns:
- the width of a stone in the current scale in pixels
getStoneHeight
int getStoneHeight()
- Returns:
- the height of a stone in the current scale in pixels
prepaintStone
private java.awt.image.BufferedImage prepaintStone(java.awt.Color fg,
java.awt.Color bg,
int value)
getStoneImage
private java.awt.image.BufferedImage getStoneImage(StoneColor color,
int value,
StonePainter.StoneState state,
boolean hovered)
resetPrepaint
private void resetPrepaint()
paintStoneBackground
private void paintStoneBackground(java.awt.Graphics2D g,
java.awt.Rectangle r,
java.awt.Color background)
paintJokerFace
private void paintJokerFace(java.awt.Graphics2D g,
java.awt.Rectangle r)
paintJoker
private void paintJoker(java.awt.Graphics2D g,
java.awt.Rectangle r,
java.awt.Color color)
paintStoneValue
private void paintStoneValue(java.awt.Graphics2D g,
java.awt.Rectangle r,
java.awt.Color color,
int v)
paintCircle
private void paintCircle(java.awt.Graphics2D g,
java.awt.Rectangle r,
java.awt.Color background)
paintStone
void paintStone(java.awt.Graphics2D g,
Stone stone,
Position p,
StonePainter.StoneState state,
boolean hovered)
- Paints a stone
- Parameters:
g
- the graphics context to paint the stone onstone
- the stone to paintp
- the position of the stonestate
- if the stone is selected the stone will be painted darker, if
it is invalid it will be painted in redhovered
- if hovered is true the stone will be painted brighter