diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-09 01:46:41 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-09 01:46:41 +0200 |
commit | ad3b8ecb48d4d18a79691e111e2875725b3b94e9 (patch) | |
tree | 59e7d9b90bde60c0810811baee70a34fdc42506f /src | |
parent | b86571cf832ff13010798f3607eea6ad0ef039d0 (diff) | |
download | JRummikub-ad3b8ecb48d4d18a79691e111e2875725b3b94e9.tar JRummikub-ad3b8ecb48d4d18a79691e111e2875725b3b94e9.zip |
Fix rounding errors in stone positioning on table
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@181 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src')
-rw-r--r-- | src/jrummikub/view/impl/StonePainter.java | 2 | ||||
-rw-r--r-- | src/jrummikub/view/impl/TablePanel.java | 15 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/jrummikub/view/impl/StonePainter.java b/src/jrummikub/view/impl/StonePainter.java index 0812beb..dccb01d 100644 --- a/src/jrummikub/view/impl/StonePainter.java +++ b/src/jrummikub/view/impl/StonePainter.java @@ -329,7 +329,7 @@ class StonePainter { boolean selected, boolean hovered) { int width = getStoneWidth(); int height = getStoneHeight(); - int x = (int) (p.getX() * width), y = (int) (p.getY() * height); + int x = Math.round(p.getX() * width), y = Math.round(p.getY() * height); Map<StoneColor, Map<Integer, BufferedImage>> stoneMap; diff --git a/src/jrummikub/view/impl/TablePanel.java b/src/jrummikub/view/impl/TablePanel.java index 7eb798d..7e2dfdb 100644 --- a/src/jrummikub/view/impl/TablePanel.java +++ b/src/jrummikub/view/impl/TablePanel.java @@ -152,9 +152,11 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { @Override public void handle(Point p) { - Point p2 = SwingUtilities.convertPoint(stoneCollection, p, TablePanel.this); + Point p2 = SwingUtilities.convertPoint(stoneCollection, p, + TablePanel.this); clickAt(p2, 1, false, false); - }}); + } + }); add(stoneCollection); addComponentListener(new ComponentAdapter() { @@ -263,8 +265,8 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { .getStoneHeight(); // Left connector - connectorArea.add(new Area(new Rectangle2D.Float((int) (x * width - width - * CONNECTOR_WIDTH), (int) (pos.getY() * height), + connectorArea.add(new Area(new Rectangle2D.Float(Math.round(x * width) + - (int) width * CONNECTOR_WIDTH, Math.round(pos.getY() * height), (int) (width * CONNECTOR_WIDTH), height))); for (Stone stone : stoneSet) { @@ -274,8 +276,9 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { } // Right connector - connectorArea.add(new Area(new Rectangle2D.Float((int) (x * width), - (int) (pos.getY() * height), (int) (width * CONNECTOR_WIDTH), height))); + connectorArea.add(new Area(new Rectangle2D.Float(Math.round(x * width), + Math.round(pos.getY() * height), (int) (width * CONNECTOR_WIDTH), + height))); } @Override |