diff options
author | Bennet Gerlach <bennet_gerlach@web.de> | 2011-05-10 03:55:58 +0200 |
---|---|---|
committer | Bennet Gerlach <bennet_gerlach@web.de> | 2011-05-10 03:55:58 +0200 |
commit | 07e2388b95fc58dfa6c053b9384c883fb5dfc8e3 (patch) | |
tree | 6bfd734c94987f8b1b3e158c71c08de5f1c4d31a | |
parent | 3b49b2053e9f9d26b73db0ffc8380a60706ee095 (diff) | |
download | JRummikub-07e2388b95fc58dfa6c053b9384c883fb5dfc8e3.tar JRummikub-07e2388b95fc58dfa6c053b9384c883fb5dfc8e3.zip |
Fixed method lines of code of TurnControl
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@214 72836036-5685-4462-b002-a69064685172
-rw-r--r-- | src/jrummikub/control/TurnControl.java | 86 |
1 files changed, 55 insertions, 31 deletions
diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java index ace201e..d280096 100644 --- a/src/jrummikub/control/TurnControl.java +++ b/src/jrummikub/control/TurnControl.java @@ -77,6 +77,33 @@ public class TurnControl { connections.add(view.getPlayerPanel().getEndTurnEvent() .add(endOfTurnListener)); + addHandPanelHandlers(); + addStoneCollectionHandlers(); + addTablePanelHandlers(); + + connections.add(view.getPlayerPanel().getSortByGroupsEvent() + .add(new IListener() { + @Override + public void handle() { + sortByGroups(); + } + })); + + connections.add(view.getPlayerPanel().getSortByRunsEvent() + .add(new IListener() { + @Override + public void handle() { + sortByRuns(); + } + })); + + view.getPlayerPanel().getHandPanel().setStones(hand.clone()); + view.enableStartTurnPanel(false); + + timer.startTimer(); + } + + private void addHandPanelHandlers() { connections.add(view.getPlayerPanel().getHandPanel().getClickEvent() .add(new IListener1<Position>() { @Override @@ -85,8 +112,8 @@ public class TurnControl { } })); - connections.add(view.getPlayerPanel().getHandPanel() - .getStoneClickEvent().add(new IListener2<Stone, Boolean>() { + connections.add(view.getPlayerPanel().getHandPanel().getStoneClickEvent() + .add(new IListener2<Stone, Boolean>() { @Override public void handle(Stone stone, Boolean collect) { @@ -94,15 +121,17 @@ public class TurnControl { } })); - connections.add(view.getPlayerPanel().getHandPanel() - .getRangeClickEvent().add(new IListener2<Stone, Boolean>() { + connections.add(view.getPlayerPanel().getHandPanel().getRangeClickEvent() + .add(new IListener2<Stone, Boolean>() { @Override public void handle(Stone stone, Boolean collect) { handRangeClick(stone, collect); } })); + } + private void addStoneCollectionHandlers() { connections.add(view.getTablePanel().getStoneCollectionPanel() .getStoneClickEvent().add(new IListener2<Stone, Boolean>() { @@ -111,6 +140,7 @@ public class TurnControl { collectionStoneClick(stone, collect); } })); + connections.add(view.getTablePanel().getStoneCollectionPanel() .getSetClickEvent().add(new IListener2<Stone, Boolean>() { @@ -119,6 +149,9 @@ public class TurnControl { collectionSetClick(stone, collect); } })); + } + + private void addTablePanelHandlers() { connections.add(view.getTablePanel().getStoneClickEvent() .add(new IListener2<Stone, Boolean>() { @@ -127,6 +160,7 @@ public class TurnControl { stoneClick(stone, collect); } })); + connections.add(view.getTablePanel().getSetClickEvent() .add(new IListener2<Stone, Boolean>() { @@ -135,6 +169,7 @@ public class TurnControl { tableSetClick(stone, collect); } })); + connections.add(view.getTablePanel().getRangeClickEvent() .add(new IListener2<Stone, Boolean>() { @@ -151,6 +186,11 @@ public class TurnControl { tableClick(pos); } })); + + addTablePanelConnectorClickHandlers(); + } + + private void addTablePanelConnectorClickHandlers() { connections.add(view.getTablePanel().getLeftConnectorClickEvent() .add(new IListener1<StoneSet>() { @Override @@ -158,6 +198,7 @@ public class TurnControl { connectorClick(set, false); } })); + connections.add(view.getTablePanel().getRightConnectorClickEvent() .add(new IListener1<StoneSet>() { @Override @@ -165,25 +206,6 @@ public class TurnControl { connectorClick(set, true); } })); - connections.add(view.getPlayerPanel().getSortByGroupsEvent() - .add(new IListener() { - @Override - public void handle() { - sortByGroups(); - } - })); - connections.add(view.getPlayerPanel().getSortByRunsEvent() - .add(new IListener() { - @Override - public void handle() { - sortByRuns(); - } - })); - - view.getPlayerPanel().getHandPanel().setStones(hand.clone()); - view.enableStartTurnPanel(false); - - timer.startTimer(); } private void handClick(Position pos) { @@ -226,8 +248,8 @@ public class TurnControl { if (y >= GameControl.HAND_HEIGHT) { throw new ArrayIndexOutOfBoundsException(); // TODO We can't - // handle - // this yet... + // handle + // this yet... } } } @@ -401,12 +423,15 @@ public class TurnControl { table.drop(joinedSet, newPos); } else { StoneSet joinedSet = new StoneSet(selectedStones).join(newSet); - table.drop(joinedSet, new Position(newPos.getX() - - selectedStones.size(), newPos.getY())); + table.drop(joinedSet, + new Position(newPos.getX() - selectedStones.size(), newPos.getY())); } } else { - table.drop(new StoneSet(selectedStones), new Position(pos.getX() - + (set.size() - selectedStones.size()) * 0.5f, pos.getY())); + table.drop( + new StoneSet(selectedStones), + new Position( + pos.getX() + (set.size() - selectedStones.size()) * 0.5f, pos + .getY())); } selectedStones.clear(); @@ -506,8 +531,7 @@ public class TurnControl { static class HandStonePositionComparator implements Comparator<Pair<Stone, Position>> { @Override - public int compare(Pair<Stone, Position> pair1, - Pair<Stone, Position> pair2) { + public int compare(Pair<Stone, Position> pair1, Pair<Stone, Position> pair2) { Position pos1 = pair1.getSecond(), pos2 = pair2.getSecond(); if (pos1.getY() < pos2.getY()) { return -1; |