diff options
Diffstat (limited to 'src/jrummikub/view/impl/AbstractStonePanel.java')
-rw-r--r-- | src/jrummikub/view/impl/AbstractStonePanel.java | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/jrummikub/view/impl/AbstractStonePanel.java b/src/jrummikub/view/impl/AbstractStonePanel.java index ba3013c..6f8e06c 100644 --- a/src/jrummikub/view/impl/AbstractStonePanel.java +++ b/src/jrummikub/view/impl/AbstractStonePanel.java @@ -52,7 +52,7 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel, * Create a new StonePanel with a given scale factor * * @param scale - * the grid scale + * the grid scale */ public AbstractStonePanel(float scale) { super(true); // Set double buffered @@ -77,8 +77,9 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel, public void mouseMoved(MouseEvent e) { Insets insets = getInsets(); Pair<Integer, Integer> trans = getTranslation(); - Position pos = stonePainter.calculatePosition(e.getX() - insets.left - - trans.getFirst(), e.getY() - insets.top - trans.getSecond()); + Position pos = stonePainter.calculatePosition(e.getX() + - insets.left - trans.getFirst(), e.getY() - insets.top + - trans.getSecond()); setHoveredStone(getStoneAt(pos)); @@ -91,15 +92,15 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel, * clickAt is called when a click has occurred * * @param p - * the point in component coordinates + * the point in component coordinates * @param clickCount - * the click count + * the click count * @param shift - * is shift down? + * is shift down? * @param control - * is control down? + * is control down? * @param alt - * is alt down? + * is alt down? */ protected void clickAt(Point p, int clickCount, boolean shift, boolean control, boolean alt) { @@ -132,6 +133,12 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel, event.emit(stone, control); } + /** + * Sets the stone over which the cursor hovers + * + * @param stone + * stone under cursor + */ private void setHoveredStone(Stone stone) { Stone oldStone = hoveredStone; hoveredStone = stone; @@ -153,7 +160,7 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel, * Overwrite this method to signal if special zone was clicked * * @param pos - * the clicked position + * the clicked position * * @return special zone clicked */ @@ -165,11 +172,18 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel, * Overwrite this method to signal if special zone was hovered * * @param pos - * the hovered position + * the hovered position */ protected void handleOtherMoveEvent(Position pos) { } + /** + * Gets the stone at the specified position + * + * @param pos + * position + * @return the stone + */ private Stone getStoneAt(Position pos) { for (Pair<Stone, Position> entry : stones) { Stone stone = entry.getFirst(); @@ -187,14 +201,15 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel, * Sets the list of stones that can be clicked on * * @param stones - * the stones and positions + * the stones and positions */ protected void setStones(Iterable<Pair<Stone, Position>> stones) { this.stones = stones; } /** - * Returns the translation in pixels the stones in this panel are painted with + * Returns the translation in pixels the stones in this panel are painted + * with * * @return the translation */ |