Implemented direct placing of stones via alt-key
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@209 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
201c40a399
commit
9c056cfef7
2 changed files with 21 additions and 8 deletions
|
@ -63,7 +63,7 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel,
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
clickAt(e.getPoint(), e.getClickCount(), e.isShiftDown(),
|
clickAt(e.getPoint(), e.getClickCount(), e.isShiftDown(),
|
||||||
e.isControlDown());
|
e.isControlDown(), e.isAltDown());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,19 +86,31 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clickAt is called when a click has occured
|
* clickAt is called when a click has occurred
|
||||||
*
|
*
|
||||||
* @param p the point in component coordinates
|
* @param p
|
||||||
* @param clickCount the click count
|
* the point in component coordinates
|
||||||
* @param shift is shift down?
|
* @param clickCount
|
||||||
* @param control is control down?
|
* the click count
|
||||||
|
* @param shift
|
||||||
|
* is shift down?
|
||||||
|
* @param control
|
||||||
|
* is control down?
|
||||||
|
* @param alt
|
||||||
|
* is alt down?
|
||||||
*/
|
*/
|
||||||
protected void clickAt(Point p, int clickCount, boolean shift, boolean control) {
|
protected void clickAt(Point p, int clickCount, boolean shift,
|
||||||
|
boolean control, boolean alt) {
|
||||||
Insets insets = getInsets();
|
Insets insets = getInsets();
|
||||||
Pair<Integer, Integer> trans = getTranslation();
|
Pair<Integer, Integer> trans = getTranslation();
|
||||||
Position pos = stonePainter.calculatePosition(
|
Position pos = stonePainter.calculatePosition(
|
||||||
p.x - insets.left - trans.getFirst(),
|
p.x - insets.left - trans.getFirst(),
|
||||||
p.y - insets.top - trans.getSecond());
|
p.y - insets.top - trans.getSecond());
|
||||||
|
if (alt) {
|
||||||
|
clickEvent.emit(pos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Stone stone = getStoneAt(pos);
|
Stone stone = getStoneAt(pos);
|
||||||
|
|
||||||
if (stone == null) {
|
if (stone == null) {
|
||||||
|
|
|
@ -156,7 +156,8 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
public void handle(Point p) {
|
public void handle(Point p) {
|
||||||
Point p2 = SwingUtilities.convertPoint(stoneCollection, p,
|
Point p2 = SwingUtilities.convertPoint(stoneCollection, p,
|
||||||
TablePanel.this);
|
TablePanel.this);
|
||||||
clickAt(p2, 1, false, false);
|
// theres nothing below here
|
||||||
|
clickAt(p2, 1, false, false, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(stoneCollection);
|
add(stoneCollection);
|
||||||
|
|
Reference in a new issue