From 51f70cafe316a1284db82a4cfb3c09cba8c12293 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 3 May 2011 21:34:59 +0200 Subject: Translate table origin git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@98 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/AbstractStonePanel.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/jrummikub/view/impl/AbstractStonePanel.java') diff --git a/src/jrummikub/view/impl/AbstractStonePanel.java b/src/jrummikub/view/impl/AbstractStonePanel.java index 68818cf..e858662 100644 --- a/src/jrummikub/view/impl/AbstractStonePanel.java +++ b/src/jrummikub/view/impl/AbstractStonePanel.java @@ -13,6 +13,7 @@ import jrummikub.model.Position; import jrummikub.model.Stone; import jrummikub.util.Event1; import jrummikub.util.Event2; +import jrummikub.util.Pair; import jrummikub.view.IClickable; import jrummikub.view.IStonePanel; @@ -60,8 +61,9 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel, @Override public void mouseClicked(MouseEvent e) { Insets insets = getInsets(); - Position pos = stonePainter.calculatePosition(e.getX() - insets.left, - e.getY() - insets.top); + Pair trans = getTranslation(); + Position pos = stonePainter.calculatePosition(e.getX() - insets.left + - trans.getFirst(), e.getY() - insets.top - trans.getSecond()); Stone stone = getStoneAt(pos); if (stone == null) { @@ -85,7 +87,9 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel, /** * *Overwrite this method* to signal if special zone was clicked - * @param pos the clicked position + * + * @param pos + * the clicked position * * @return special zone clicked */ @@ -116,6 +120,15 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel, this.stones = stones; } + /** + * Returns the translation in pixels the stones in this panel are painted with + * + * @return the translation + */ + protected Pair getTranslation() { + return new Pair(0, 0); + } + /** * Returns the list of stones and positions currently set * -- cgit v1.2.3