diff options
Diffstat (limited to 'src/jrummikub/view')
-rw-r--r-- | src/jrummikub/view/ITablePanel.java | 3 | ||||
-rw-r--r-- | src/jrummikub/view/impl/TablePanel.java | 26 |
2 files changed, 15 insertions, 14 deletions
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<StoneSet, Position> stoneSets); + public void setStoneSets(Iterable<Pair<StoneSet, Position>> 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<StoneSet, Position> stoneSets = Collections.emptyMap(); + private Iterable<Pair<StoneSet, Position>> stoneSets = Collections.emptySet(); private Collection<Stone> selectedStones = Collections.emptyList(); private Event1<StoneSet> leftConnectorClickEvent = new Event1<StoneSet>(); @@ -77,13 +77,13 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { } @Override - public void setStoneSets(Map<StoneSet, Position> stoneSets) { + public void setStoneSets(Iterable<Pair<StoneSet, Position>> stoneSets) { Map<Stone, Position> stones = new HashMap<Stone, Position>(); - for (Map.Entry<StoneSet, Position> entry : stoneSets.entrySet()) { - float x = entry.getValue().getX(), y = entry.getValue().getY(); + for (Pair<StoneSet, Position> 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<StoneSet, Position> entry : stoneSets.entrySet()) { - Position p = entry.getValue(); - StoneSet stoneSet = entry.getKey(); + for (Pair<StoneSet, Position> 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<StoneSet, Position> entry : stoneSets.entrySet()) { - Position p = entry.getValue(); - StoneSet stoneSet = entry.getKey(); + for (Pair<StoneSet, Position> 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<StoneSet, Position> entry : stoneSets.entrySet()) { - paintStoneSet(g, entry.getKey(), entry.getValue()); + for (Pair<StoneSet, Position> entry : stoneSets) { + paintStoneSet(g, entry.getFirst(), entry.getSecond()); } g.setTransform(oldTransform); |