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
This commit is contained in:
parent
b86571cf83
commit
ad3b8ecb48
2 changed files with 10 additions and 7 deletions
|
@ -329,7 +329,7 @@ class StonePainter {
|
||||||
boolean selected, boolean hovered) {
|
boolean selected, boolean hovered) {
|
||||||
int width = getStoneWidth();
|
int width = getStoneWidth();
|
||||||
int height = getStoneHeight();
|
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;
|
Map<StoneColor, Map<Integer, BufferedImage>> stoneMap;
|
||||||
|
|
||||||
|
|
|
@ -152,9 +152,11 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Point p) {
|
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);
|
clickAt(p2, 1, false, false);
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
add(stoneCollection);
|
add(stoneCollection);
|
||||||
|
|
||||||
addComponentListener(new ComponentAdapter() {
|
addComponentListener(new ComponentAdapter() {
|
||||||
|
@ -263,8 +265,8 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
.getStoneHeight();
|
.getStoneHeight();
|
||||||
|
|
||||||
// Left connector
|
// Left connector
|
||||||
connectorArea.add(new Area(new Rectangle2D.Float((int) (x * width - width
|
connectorArea.add(new Area(new Rectangle2D.Float(Math.round(x * width)
|
||||||
* CONNECTOR_WIDTH), (int) (pos.getY() * height),
|
- (int) width * CONNECTOR_WIDTH, Math.round(pos.getY() * height),
|
||||||
(int) (width * CONNECTOR_WIDTH), height)));
|
(int) (width * CONNECTOR_WIDTH), height)));
|
||||||
|
|
||||||
for (Stone stone : stoneSet) {
|
for (Stone stone : stoneSet) {
|
||||||
|
@ -274,8 +276,9 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right connector
|
// Right connector
|
||||||
connectorArea.add(new Area(new Rectangle2D.Float((int) (x * width),
|
connectorArea.add(new Area(new Rectangle2D.Float(Math.round(x * width),
|
||||||
(int) (pos.getY() * height), (int) (width * CONNECTOR_WIDTH), height)));
|
Math.round(pos.getY() * height), (int) (width * CONNECTOR_WIDTH),
|
||||||
|
height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Reference in a new issue