Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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

Field Summary
`static float` | `HEIGHT_SCALE` The height of one pixel in the scale of 1.0
`static float` | `WIDTH_SCALE` The width of one pixel in the scale of 1.0

Constructor Summary
`StonePainter(float scale)`

Method Summary
`Position` | `calculatePosition(int x, int y)`
`int` | `getStoneHeight()`
`int` | `getStoneWidth()`
`void` | `paintStone(java.awt.Graphics2D g, Stone stone, Position p, boolean selected, boolean hovered)` Paints a stone
`void` | `setScale(float scale)` Sets the new grid scale

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### WIDTH_SCALE

    public static final float WIDTH_SCALE

  The width of one pixel in the scale of 1.0

  See Also:
    Constant Field Values

### HEIGHT_SCALE

    public static final float HEIGHT_SCALE

  The height of one pixel in the scale of 1.0

  See Also:
    Constant Field Values

Constructor Detail

### StonePainter

    StonePainter(float scale)

Parameters:
  `scale` - the scaling factor for the grid coordinates

Method Detail

### setScale

    public void setScale(float scale)

  Sets the new grid scale

  Parameters:
    `scale` - the new scale

### calculatePosition

    public Position calculatePosition(int x,
                                      int y)

  Parameters:
    `x` - x position in screen coordinates
    `y` - y position in screen coordinates
  Returns:
    position in grid coordinates

### getStoneWidth

    public int getStoneWidth()

  Returns:
    the width of a stone in the current scale in pixels

### getStoneHeight

    public int getStoneHeight()

  Returns:
    the height of a stone in the current scale in pixels

### paintStone

    public void paintStone(java.awt.Graphics2D g,
                           Stone stone,
                           Position p,
                           boolean selected,
                           boolean hovered)

  Paints a stone

  Parameters:
    `g` - the graphics context to paint the stone on
    `stone` - the stone to paint
    `p` - the position of the stone
    `selected` - if selected is true the stone will be painted darker
    `hovered` - if hovered is true the stone will be painted brighter

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD