summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/StoneCollectionPanel.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-03 17:29:52 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-03 17:29:52 +0200
commitbcc3f95847eafa1b61bb32dac047101c7adc0e64 (patch)
tree992c9f7d3569f3598cf8e1a0f14fa647974bb5e7 /src/jrummikub/view/impl/StoneCollectionPanel.java
parent7edb66d4ff069a40471258a66ef56dac36598665 (diff)
downloadJRummikub-bcc3f95847eafa1b61bb32dac047101c7adc0e64.tar
JRummikub-bcc3f95847eafa1b61bb32dac047101c7adc0e64.zip
Make StonePanel emit Stone click events
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@80 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/StoneCollectionPanel.java')
-rw-r--r--src/jrummikub/view/impl/StoneCollectionPanel.java27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/jrummikub/view/impl/StoneCollectionPanel.java b/src/jrummikub/view/impl/StoneCollectionPanel.java
index e4ca1c6..8729170 100644
--- a/src/jrummikub/view/impl/StoneCollectionPanel.java
+++ b/src/jrummikub/view/impl/StoneCollectionPanel.java
@@ -6,6 +6,8 @@ import java.awt.Graphics2D;
import java.awt.Insets;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import javax.swing.border.EmptyBorder;
@@ -17,7 +19,8 @@ import jrummikub.view.IStoneCollectionPanel;
* Implementation of the stone collection (selection)
*/
@SuppressWarnings("serial")
-class StoneCollectionPanel extends AbstractStonePanel implements IStoneCollectionPanel {
+class StoneCollectionPanel extends AbstractStonePanel implements
+ IStoneCollectionPanel {
private final static int INSET = 7;
private final static float STONE_SCALE = 1.1f;
@@ -37,17 +40,27 @@ class StoneCollectionPanel extends AbstractStonePanel implements IStoneCollectio
/**
* Sets the stones to be shown in the collection
*
- * @param stones
+ * @param selectedStones
* the selected stones
*/
- void setSelectedStones(Collection<Stone> stones) {
- selectedStones = stones;
+ void setSelectedStones(Collection<Stone> selectedStones) {
+ this.selectedStones = selectedStones;
- if (stones.isEmpty()) {
+ Map<Stone, Position> stones = new HashMap<Stone, Position>();
+ float x = 0;
+
+ for (Stone stone : selectedStones) {
+ stones.put(stone, new Position(x, 0));
+ x += stone.getWidth();
+ }
+
+ setStones(stones);
+
+ if (selectedStones.isEmpty()) {
setVisible(false);
} else {
- setSize(getStonePainter().getStoneWidth() * stones.size() + 2 * INSET,
- getStonePainter().getStoneHeight() + 2 * INSET);
+ setSize(getStonePainter().getStoneWidth() * selectedStones.size() + 2
+ * INSET, getStonePainter().getStoneHeight() + 2 * INSET);
setVisible(true);
repaint();