diff options
Diffstat (limited to 'src/jrummikub/view/impl/StonePanel.java')
-rw-r--r-- | src/jrummikub/view/impl/StonePanel.java | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/src/jrummikub/view/impl/StonePanel.java b/src/jrummikub/view/impl/StonePanel.java deleted file mode 100644 index 9e84349..0000000 --- a/src/jrummikub/view/impl/StonePanel.java +++ /dev/null @@ -1,82 +0,0 @@ -package jrummikub.view.impl; - -import java.awt.Insets; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import javax.swing.JPanel; - -import jrummikub.model.Position; -import jrummikub.util.Event2; -import jrummikub.view.IClickable; - -/** - * Base class for panels that draw stones - */ -@SuppressWarnings("serial") -abstract class StonePanel extends JPanel implements IClickable { - private StonePainter stonePainter; - - private Event2<Position, Boolean> clickEvent = new Event2<Position, Boolean>(); - private Event2<Position, Boolean> rangeClickEvent = new Event2<Position, Boolean>(); - private Event2<Position, Boolean> setClickEvent = new Event2<Position, Boolean>(); - - /** - * @return the stone painter - */ - protected StonePainter getStonePainter() { - return stonePainter; - } - - /** - * Create a new StonePanel with default scale factor - */ - public StonePanel() { - this(1); - } - - /** - * Create a new StonePanel with a given scale factor - * - * @param scale - * the grid scale - */ - public StonePanel(float scale) { - super(true); // Set double buffered - - stonePainter = new StonePainter(scale); - - addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - Insets insets = getInsets(); - Event2<Position, Boolean> event = clickEvent; - - if (e.isShiftDown()) - event = rangeClickEvent; - else if (e.getClickCount() >= 2) - event = setClickEvent; - - event.fire( - stonePainter.calculatePosition(e.getX() - insets.left, e.getY() - - insets.top), e.isControlDown()); - } - }); - } - - @Override - public Event2<Position, Boolean> getClickEvent() { - return clickEvent; - } - - @Override - public Event2<Position, Boolean> getRangeClickEvent() { - return rangeClickEvent; - } - - @Override - public Event2<Position, Boolean> getSetClickEvent() { - return setClickEvent; - } - -} |