From db7489a5c78551e4db52acd11656f2b872740f89 Mon Sep 17 00:00:00 2001 From: Bennet Gerlach Date: Wed, 4 May 2011 23:14:10 +0200 Subject: New main git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@127 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/ITablePanel.java | 3 ++- src/jrummikub/view/impl/TablePanel.java | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'src/jrummikub/view') diff --git a/src/jrummikub/view/ITablePanel.java b/src/jrummikub/view/ITablePanel.java index f17d1fe..5c4198c 100644 --- a/src/jrummikub/view/ITablePanel.java +++ b/src/jrummikub/view/ITablePanel.java @@ -5,6 +5,7 @@ import java.util.Map; import jrummikub.model.Position; import jrummikub.model.StoneSet; import jrummikub.util.Event1; +import jrummikub.util.Pair; /** * The view of the table, where the stone sets lie @@ -40,7 +41,7 @@ public interface ITablePanel extends IStonePanel, IClickable { * @param stoneSets * set stone sets on the table */ - public void setStoneSets(Map stoneSets); + public void setStoneSets(Iterable> stoneSets); /** * Returns the stone collection (the panel showing the stones currently diff --git a/src/jrummikub/view/impl/TablePanel.java b/src/jrummikub/view/impl/TablePanel.java index abbb867..f400fac 100644 --- a/src/jrummikub/view/impl/TablePanel.java +++ b/src/jrummikub/view/impl/TablePanel.java @@ -45,7 +45,7 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { private JLabel leftPlayerLabel, topPlayerLabel, rightPlayerLabel; private StoneCollectionPanel stoneCollection; - private Map stoneSets = Collections.emptyMap(); + private Iterable> stoneSets = Collections.emptySet(); private Collection selectedStones = Collections.emptyList(); private Event1 leftConnectorClickEvent = new Event1(); @@ -77,13 +77,13 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { } @Override - public void setStoneSets(Map stoneSets) { + public void setStoneSets(Iterable> stoneSets) { Map stones = new HashMap(); - for (Map.Entry entry : stoneSets.entrySet()) { - float x = entry.getValue().getX(), y = entry.getValue().getY(); + for (Pair entry : stoneSets) { + float x = entry.getSecond().getX(), y = entry.getSecond().getY(); - for (Stone stone : entry.getKey()) { + for (Stone stone : entry.getFirst()) { stones.put(stone, new Position(x, y)); x++; } @@ -156,9 +156,9 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { float minx = -MIN_VISIBLE_WIDTH / 2, maxx = MIN_VISIBLE_WIDTH / 2; float miny = -MIN_VISIBLE_HEIGHT / 2, maxy = MIN_VISIBLE_HEIGHT / 2; - for (Map.Entry entry : stoneSets.entrySet()) { - Position p = entry.getValue(); - StoneSet stoneSet = entry.getKey(); + for (Pair entry : stoneSets) { + Position p = entry.getSecond(); + StoneSet stoneSet = entry.getFirst(); if (p.getX() < minx) minx = p.getX(); @@ -205,9 +205,9 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { } protected boolean handleOtherClickEvent(Position pos) { - for (Map.Entry entry : stoneSets.entrySet()) { - Position p = entry.getValue(); - StoneSet stoneSet = entry.getKey(); + for (Pair entry : stoneSets) { + Position p = entry.getSecond(); + StoneSet stoneSet = entry.getFirst(); float x = p.getX(), y = p.getY(); // left connector @@ -281,8 +281,8 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - for (Map.Entry entry : stoneSets.entrySet()) { - paintStoneSet(g, entry.getKey(), entry.getValue()); + for (Pair entry : stoneSets) { + paintStoneSet(g, entry.getFirst(), entry.getSecond()); } g.setTransform(oldTransform); -- cgit v1.2.3