New main
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@127 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
b0a90ad6f0
commit
db7489a5c7
6 changed files with 40 additions and 224 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Reference in a new issue