diff options
author | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-21 13:47:15 +0200 |
---|---|---|
committer | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-21 13:47:15 +0200 |
commit | 5e3ce21569f5adc92c969735c88af488cf581916 (patch) | |
tree | 08216e061937a4672fffefcf1054caadb92b568e /src/jrummikub/control/AbstractSettingsControl.java | |
parent | fcd7af76285a58aa8e2ba645b8380c2c86f66908 (diff) | |
download | JRummikub-5e3ce21569f5adc92c969735c88af488cf581916.tar JRummikub-5e3ce21569f5adc92c969735c88af488cf581916.zip |
Das reine control-package ist vollständig kommentiert
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@545 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/AbstractSettingsControl.java')
-rw-r--r-- | src/jrummikub/control/AbstractSettingsControl.java | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/src/jrummikub/control/AbstractSettingsControl.java b/src/jrummikub/control/AbstractSettingsControl.java index ee0c96c..2904df4 100644 --- a/src/jrummikub/control/AbstractSettingsControl.java +++ b/src/jrummikub/control/AbstractSettingsControl.java @@ -49,6 +49,9 @@ public abstract class AbstractSettingsControl { .asList(ISettingsPanel.PLAYER_COLORS))); } + /** + * Add event listeners to abstract settings control + */ protected void addListeners() { addPlayerSettingsListeners(); @@ -57,6 +60,9 @@ public abstract class AbstractSettingsControl { addVariantListeners(); } + /** + * Add event listeners to the player settings panel + */ private void addPlayerSettingsListeners() { connections.add(view.getSettingsPanel().getAddPlayerEvent() .add(new IListener() { @@ -95,6 +101,9 @@ public abstract class AbstractSettingsControl { })); } + /** + * Add the first half of event listeners to option panel + */ private void addOptionListeners1() { connections.add(view.getSettingsPanel() .getChangeInitialMeldThresholdEvent() @@ -134,6 +143,9 @@ public abstract class AbstractSettingsControl { })); } + /** + * Add the second half of event listeners to option panel + */ private void addOptionListeners2() { connections.add(view.getSettingsPanel().getChangeHighestValueEvent() .add(new IListener1<Integer>() { @@ -168,7 +180,7 @@ public abstract class AbstractSettingsControl { update(); } })); - + connections.add(view.getSettingsPanel().getChangeSeeHandSizeEvent() .add(new IListener1<Boolean>() { @Override @@ -212,6 +224,11 @@ public abstract class AbstractSettingsControl { view.showSettingsPanel(true); } + /** + * Finds the next unused player color + * + * @return an unused color + */ protected Color findUnusedColor() { Color color = null; colorLoop: for (Color c : ISettingsPanel.PLAYER_COLORS) { @@ -226,6 +243,14 @@ public abstract class AbstractSettingsControl { return color; } + /** + * Sets a player's color + * + * @param i + * index of player + * @param color + * color to be set + */ private void setPlayerColor(int i, Color color) { PlayerSettings player = settings.getPlayerList().get(i); @@ -244,16 +269,36 @@ public abstract class AbstractSettingsControl { update(); } + /** + * Sets a player's name + * + * @param i + * index of player + * @param name + * name to be set + */ private void setPlayerName(int i, String name) { settings.getPlayerList().get(i).setName(name); update(); } + /** + * Removes a player from the planned game + * + * @param i + * index of player + */ private void removePlayer(int i) { settings.getPlayerList().remove(i); update(); } + /** + * Checks the settings for ambiguous or missing data and sets error/warning + * if necessary + * + * @return boolean check correct + */ protected boolean checkSettings() { if (!checkName()) { return false; @@ -270,6 +315,11 @@ public abstract class AbstractSettingsControl { return true; } + /** + * Checks if unique player name is present for each player + * + * @return is player name ok + */ private boolean checkName() { for (PlayerSettings player : settings.getPlayerList()) { if (player.getName().isEmpty()) { @@ -302,6 +352,11 @@ public abstract class AbstractSettingsControl { return true; } + /** + * Check options leading to errors + * + * @return options ok + */ private boolean checkErrors() { int totalStonesDealt = settings.getNumberOfStonesDealt() * settings.getPlayerList().size(); @@ -324,6 +379,9 @@ public abstract class AbstractSettingsControl { return true; } + /** + * Check all options and player settings for entries causing warnings + */ private void checkWarnings() { if (settings.getInitialMeldThreshold() >= 100) { view.getSettingsPanel().setError( @@ -356,10 +414,24 @@ public abstract class AbstractSettingsControl { } } + /** + * Add new player to the planned game + */ abstract protected void addPlayer(); + /** + * Set the type of a player + * + * @param i + * index of player + * @param type + * type to be set + */ abstract protected void setPlayerType(int i, Type type); + /** + * Show newly chosen options in view + */ abstract protected void update(); } |