Noch mehr Kommentare, z.B. alle Methoden im Model und in der IView
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@547 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
e4e66240bf
commit
7899a38fe6
8 changed files with 159 additions and 36 deletions
|
@ -18,6 +18,12 @@ public class DedicatedServer {
|
||||||
String serverPassword;
|
String serverPassword;
|
||||||
String hostName;
|
String hostName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new dedicated server with the specified password
|
||||||
|
*
|
||||||
|
* @param serverPassword
|
||||||
|
* the password
|
||||||
|
*/
|
||||||
public DedicatedServer(String serverPassword) {
|
public DedicatedServer(String serverPassword) {
|
||||||
this.serverPassword = serverPassword;
|
this.serverPassword = serverPassword;
|
||||||
try {
|
try {
|
||||||
|
@ -29,6 +35,11 @@ public class DedicatedServer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for host name
|
||||||
|
*
|
||||||
|
* @return host name
|
||||||
|
*/
|
||||||
public String getHostName() {
|
public String getHostName() {
|
||||||
return hostName;
|
return hostName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,7 +231,8 @@ public interface ISettingsPanel {
|
||||||
public void setPlayerNamesEditable(List<Boolean> editable);
|
public void setPlayerNamesEditable(List<Boolean> editable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when a new game is started and looking for players
|
* The offer new game event is emitted when a new game is started and
|
||||||
|
* looking for players
|
||||||
*
|
*
|
||||||
* @return the event
|
* @return the event
|
||||||
*/
|
*/
|
||||||
|
@ -245,6 +246,12 @@ public interface ISettingsPanel {
|
||||||
*/
|
*/
|
||||||
public void setPlayerColors(Set<Color> colors);
|
public void setPlayerColors(Set<Color> colors);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The change see hand size event is emitted when the player chooses to see
|
||||||
|
* the other players hand sizes
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent1<Boolean> getChangeSeeHandSizeEvent();
|
public IEvent1<Boolean> getChangeSeeHandSizeEvent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,14 +5,42 @@ import java.util.List;
|
||||||
import jrummikub.model.GameSettings;
|
import jrummikub.model.GameSettings;
|
||||||
import jrummikub.model.IPlayer;
|
import jrummikub.model.IPlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Side panel to show all players and relevant player information in round
|
||||||
|
* order, game settings and stone heap size
|
||||||
|
*/
|
||||||
public interface ISidePanel {
|
public interface ISidePanel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the game settings to top of side panel
|
||||||
|
*
|
||||||
|
* @param settings
|
||||||
|
* current game settings
|
||||||
|
*/
|
||||||
public void setGameSettings(GameSettings settings);
|
public void setGameSettings(GameSettings settings);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the total heap size for progress bar
|
||||||
|
*
|
||||||
|
* @param capacity
|
||||||
|
* total heap size
|
||||||
|
*/
|
||||||
void setHeapCapacity(int capacity);
|
void setHeapCapacity(int capacity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current heap size
|
||||||
|
*
|
||||||
|
* @param size
|
||||||
|
* number of stones in current heap
|
||||||
|
*/
|
||||||
void setHeapSize(int size);
|
void setHeapSize(int size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the player information in order of turns
|
||||||
|
*
|
||||||
|
* @param players
|
||||||
|
* players in current game
|
||||||
|
*/
|
||||||
void setPlayers(List<IPlayer> players);
|
void setPlayers(List<IPlayer> players);
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@ public interface IStoneCollectionPanel extends IStonePanel {
|
||||||
* Hide stone collection
|
* Hide stone collection
|
||||||
*
|
*
|
||||||
* @param enable
|
* @param enable
|
||||||
|
* see stone collection
|
||||||
*/
|
*/
|
||||||
void setHidden(boolean enable);
|
void setHidden(boolean enable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public interface IView {
|
||||||
* Sets the current player's name
|
* Sets the current player's name
|
||||||
*
|
*
|
||||||
* @param playerName
|
* @param playerName
|
||||||
* the player name
|
* the player name
|
||||||
*/
|
*/
|
||||||
public void setCurrentPlayerName(String playerName);
|
public void setCurrentPlayerName(String playerName);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public interface IView {
|
||||||
* Sets the stones that are to be painted selected
|
* Sets the stones that are to be painted selected
|
||||||
*
|
*
|
||||||
* @param stones
|
* @param stones
|
||||||
* the stones to be painted selected
|
* the stones to be painted selected
|
||||||
*/
|
*/
|
||||||
public void setSelectedStones(Collection<Stone> stones);
|
public void setSelectedStones(Collection<Stone> stones);
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ public interface IView {
|
||||||
* Shows or hides the game settings panel
|
* Shows or hides the game settings panel
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* specifies if the panel shall be shown or hidden
|
* specifies if the panel shall be shown or hidden
|
||||||
*/
|
*/
|
||||||
public void showSettingsPanel(boolean show);
|
public void showSettingsPanel(boolean show);
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ public interface IView {
|
||||||
* Shows or hides the score panel
|
* Shows or hides the score panel
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* specifies if the panel shall be shown or hidden
|
* specifies if the panel shall be shown or hidden
|
||||||
*/
|
*/
|
||||||
public void showScorePanel(boolean show);
|
public void showScorePanel(boolean show);
|
||||||
|
|
||||||
|
@ -119,16 +119,16 @@ public interface IView {
|
||||||
* along with the name
|
* along with the name
|
||||||
*
|
*
|
||||||
* @param color
|
* @param color
|
||||||
* the current player's color
|
* the current player's color
|
||||||
*/
|
*/
|
||||||
public void setCurrentPlayerColor(Color color);
|
public void setCurrentPlayerColor(Color color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is used for the PlayerPanel to display if a player has laid out along with
|
* Is used for the PlayerPanel to display if a player has laid out along
|
||||||
* the name
|
* with the name
|
||||||
*
|
*
|
||||||
* @param hasLaidOut
|
* @param hasLaidOut
|
||||||
* specifies if the current player has laid out or not
|
* specifies if the current player has laid out or not
|
||||||
*/
|
*/
|
||||||
public void setCurrentPlayerHasLaidOut(boolean hasLaidOut);
|
public void setCurrentPlayerHasLaidOut(boolean hasLaidOut);
|
||||||
|
|
||||||
|
@ -143,13 +143,13 @@ public interface IView {
|
||||||
* Sets the bottom panels type
|
* Sets the bottom panels type
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* the type of the bottom panel
|
* the type of the bottom panel
|
||||||
*/
|
*/
|
||||||
public void setBottomPanel(BottomPanelType type);
|
public void setBottomPanel(BottomPanelType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The menu new game event is emitted when the user selects the new game menu
|
* The menu new game event is emitted when the user selects the new game
|
||||||
* entry
|
* menu entry
|
||||||
*
|
*
|
||||||
* @return the event
|
* @return the event
|
||||||
*/
|
*/
|
||||||
|
@ -217,7 +217,7 @@ public interface IView {
|
||||||
* Show/hide login panel
|
* Show/hide login panel
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* true = login panel is shown
|
* true = login panel is shown
|
||||||
*/
|
*/
|
||||||
public void showLoginPanel(boolean show);
|
public void showLoginPanel(boolean show);
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ public interface IView {
|
||||||
* Enable/disable pause mode
|
* Enable/disable pause mode
|
||||||
*
|
*
|
||||||
* @param enable
|
* @param enable
|
||||||
* true = enable
|
* true = enable
|
||||||
*/
|
*/
|
||||||
public void enablePauseMode(boolean enable);
|
public void enablePauseMode(boolean enable);
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ public interface IView {
|
||||||
* Show/hide game list panel
|
* Show/hide game list panel
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* true = show
|
* true = show
|
||||||
*/
|
*/
|
||||||
public void showGameListPanel(boolean show);
|
public void showGameListPanel(boolean show);
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ public interface IView {
|
||||||
* Show/hide side panel
|
* Show/hide side panel
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* true to show
|
* true to show
|
||||||
*/
|
*/
|
||||||
void showSidePanel(boolean show);
|
void showSidePanel(boolean show);
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ public interface IView {
|
||||||
* Is set if a player tried to lay out less than initial meld threshold
|
* Is set if a player tried to lay out less than initial meld threshold
|
||||||
*
|
*
|
||||||
* @param points
|
* @param points
|
||||||
* initial meld threshold
|
* initial meld threshold
|
||||||
*/
|
*/
|
||||||
public void setInitialMeldError(int points);
|
public void setInitialMeldError(int points);
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ public interface IView {
|
||||||
* Show stone collection
|
* Show stone collection
|
||||||
*
|
*
|
||||||
* @param enable
|
* @param enable
|
||||||
* showing collection
|
* showing collection
|
||||||
*/
|
*/
|
||||||
public void setStoneCollectionHidden(boolean enable);
|
public void setStoneCollectionHidden(boolean enable);
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ public interface IView {
|
||||||
* Set invalid sets to enable showing
|
* Set invalid sets to enable showing
|
||||||
*
|
*
|
||||||
* @param sets
|
* @param sets
|
||||||
* invalid sets on table
|
* invalid sets on table
|
||||||
*/
|
*/
|
||||||
public void setInvalidStoneSets(Collection<StoneSet> sets);
|
public void setInvalidStoneSets(Collection<StoneSet> sets);
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ public interface IView {
|
||||||
* Enables/disables saving in menu bar
|
* Enables/disables saving in menu bar
|
||||||
*
|
*
|
||||||
* @param enable
|
* @param enable
|
||||||
* saving possible
|
* saving possible
|
||||||
*/
|
*/
|
||||||
public void enableSave(boolean enable);
|
public void enableSave(boolean enable);
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ public interface IView {
|
||||||
* Sets the quit warning panel visible
|
* Sets the quit warning panel visible
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* is visible
|
* is visible
|
||||||
*/
|
*/
|
||||||
public void showQuitWarningPanel(boolean show);
|
public void showQuitWarningPanel(boolean show);
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ public interface IView {
|
||||||
* Set the connect panel visible
|
* Set the connect panel visible
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* is visible
|
* is visible
|
||||||
*/
|
*/
|
||||||
public void showConnectPanel(boolean show);
|
public void showConnectPanel(boolean show);
|
||||||
|
|
||||||
|
@ -337,6 +337,13 @@ public interface IView {
|
||||||
*/
|
*/
|
||||||
public IConnectPanel getConnectPanel();
|
public IConnectPanel getConnectPanel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the pause button if pausing should be possible in the current
|
||||||
|
* situation
|
||||||
|
*
|
||||||
|
* @param mayPause
|
||||||
|
* pausing possible
|
||||||
|
*/
|
||||||
public void setMayPause(boolean mayPause);
|
public void setMayPause(boolean mayPause);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -52,7 +52,7 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel,
|
||||||
* Create a new StonePanel with a given scale factor
|
* Create a new StonePanel with a given scale factor
|
||||||
*
|
*
|
||||||
* @param scale
|
* @param scale
|
||||||
* the grid scale
|
* the grid scale
|
||||||
*/
|
*/
|
||||||
public AbstractStonePanel(float scale) {
|
public AbstractStonePanel(float scale) {
|
||||||
super(true); // Set double buffered
|
super(true); // Set double buffered
|
||||||
|
@ -77,8 +77,9 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel,
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
Insets insets = getInsets();
|
Insets insets = getInsets();
|
||||||
Pair<Integer, Integer> trans = getTranslation();
|
Pair<Integer, Integer> trans = getTranslation();
|
||||||
Position pos = stonePainter.calculatePosition(e.getX() - insets.left
|
Position pos = stonePainter.calculatePosition(e.getX()
|
||||||
- trans.getFirst(), e.getY() - insets.top - trans.getSecond());
|
- insets.left - trans.getFirst(), e.getY() - insets.top
|
||||||
|
- trans.getSecond());
|
||||||
|
|
||||||
setHoveredStone(getStoneAt(pos));
|
setHoveredStone(getStoneAt(pos));
|
||||||
|
|
||||||
|
@ -91,15 +92,15 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel,
|
||||||
* clickAt is called when a click has occurred
|
* clickAt is called when a click has occurred
|
||||||
*
|
*
|
||||||
* @param p
|
* @param p
|
||||||
* the point in component coordinates
|
* the point in component coordinates
|
||||||
* @param clickCount
|
* @param clickCount
|
||||||
* the click count
|
* the click count
|
||||||
* @param shift
|
* @param shift
|
||||||
* is shift down?
|
* is shift down?
|
||||||
* @param control
|
* @param control
|
||||||
* is control down?
|
* is control down?
|
||||||
* @param alt
|
* @param alt
|
||||||
* is alt down?
|
* is alt down?
|
||||||
*/
|
*/
|
||||||
protected void clickAt(Point p, int clickCount, boolean shift,
|
protected void clickAt(Point p, int clickCount, boolean shift,
|
||||||
boolean control, boolean alt) {
|
boolean control, boolean alt) {
|
||||||
|
@ -132,6 +133,12 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel,
|
||||||
event.emit(stone, control);
|
event.emit(stone, control);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the stone over which the cursor hovers
|
||||||
|
*
|
||||||
|
* @param stone
|
||||||
|
* stone under cursor
|
||||||
|
*/
|
||||||
private void setHoveredStone(Stone stone) {
|
private void setHoveredStone(Stone stone) {
|
||||||
Stone oldStone = hoveredStone;
|
Stone oldStone = hoveredStone;
|
||||||
hoveredStone = stone;
|
hoveredStone = stone;
|
||||||
|
@ -153,7 +160,7 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel,
|
||||||
* Overwrite this method to signal if special zone was clicked
|
* Overwrite this method to signal if special zone was clicked
|
||||||
*
|
*
|
||||||
* @param pos
|
* @param pos
|
||||||
* the clicked position
|
* the clicked position
|
||||||
*
|
*
|
||||||
* @return special zone clicked
|
* @return special zone clicked
|
||||||
*/
|
*/
|
||||||
|
@ -165,11 +172,18 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel,
|
||||||
* Overwrite this method to signal if special zone was hovered
|
* Overwrite this method to signal if special zone was hovered
|
||||||
*
|
*
|
||||||
* @param pos
|
* @param pos
|
||||||
* the hovered position
|
* the hovered position
|
||||||
*/
|
*/
|
||||||
protected void handleOtherMoveEvent(Position pos) {
|
protected void handleOtherMoveEvent(Position pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the stone at the specified position
|
||||||
|
*
|
||||||
|
* @param pos
|
||||||
|
* position
|
||||||
|
* @return the stone
|
||||||
|
*/
|
||||||
private Stone getStoneAt(Position pos) {
|
private Stone getStoneAt(Position pos) {
|
||||||
for (Pair<Stone, Position> entry : stones) {
|
for (Pair<Stone, Position> entry : stones) {
|
||||||
Stone stone = entry.getFirst();
|
Stone stone = entry.getFirst();
|
||||||
|
@ -187,14 +201,15 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel,
|
||||||
* Sets the list of stones that can be clicked on
|
* Sets the list of stones that can be clicked on
|
||||||
*
|
*
|
||||||
* @param stones
|
* @param stones
|
||||||
* the stones and positions
|
* the stones and positions
|
||||||
*/
|
*/
|
||||||
protected void setStones(Iterable<Pair<Stone, Position>> stones) {
|
protected void setStones(Iterable<Pair<Stone, Position>> stones) {
|
||||||
this.stones = stones;
|
this.stones = stones;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the translation in pixels the stones in this panel are painted with
|
* Returns the translation in pixels the stones in this panel are painted
|
||||||
|
* with
|
||||||
*
|
*
|
||||||
* @return the translation
|
* @return the translation
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -49,6 +49,9 @@ class GameListPanel extends JPanel implements IGameListPanel {
|
||||||
|
|
||||||
private List<GameData> games = Collections.emptyList();
|
private List<GameData> games = Collections.emptyList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new game list panel
|
||||||
|
*/
|
||||||
GameListPanel() {
|
GameListPanel() {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
@ -70,10 +73,13 @@ class GameListPanel extends JPanel implements IGameListPanel {
|
||||||
|
|
||||||
addButtons(c);
|
addButtons(c);
|
||||||
|
|
||||||
setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(
|
setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
|
||||||
10, 10, 10, 10)));
|
new EmptyBorder(10, 10, 10, 10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the game list to be displayed in the panel
|
||||||
|
*/
|
||||||
private void createGameList() {
|
private void createGameList() {
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.BOTH;
|
c.fill = GridBagConstraints.BOTH;
|
||||||
|
@ -113,6 +119,12 @@ class GameListPanel extends JPanel implements IGameListPanel {
|
||||||
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), c);
|
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds all three buttons to the panel
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* constraints for button positioning
|
||||||
|
*/
|
||||||
private void addButtons(GridBagConstraints c) {
|
private void addButtons(GridBagConstraints c) {
|
||||||
joinButton = new JButton("Beitreten");
|
joinButton = new JButton("Beitreten");
|
||||||
c.gridwidth = 1;
|
c.gridwidth = 1;
|
||||||
|
@ -154,6 +166,9 @@ class GameListPanel extends JPanel implements IGameListPanel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets panel if all games have been removed from list
|
||||||
|
*/
|
||||||
void reset() {
|
void reset() {
|
||||||
games.clear();
|
games.clear();
|
||||||
}
|
}
|
||||||
|
@ -193,6 +208,9 @@ class GameListPanel extends JPanel implements IGameListPanel {
|
||||||
return cancelEvent;
|
return cancelEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits a join event if a user selects a game and dedides to join it
|
||||||
|
*/
|
||||||
private void join() {
|
private void join() {
|
||||||
Object data = gameList.getSelectedValue();
|
Object data = gameList.getSelectedValue();
|
||||||
|
|
||||||
|
@ -201,6 +219,13 @@ class GameListPanel extends JPanel implements IGameListPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the empty slots for network players in a game
|
||||||
|
*
|
||||||
|
* @param gameData
|
||||||
|
* of the game
|
||||||
|
* @return Pair of occupied spaces and vacant spaces
|
||||||
|
*/
|
||||||
private static Pair<Integer, Integer> getPlayerSlotCount(GameData gameData) {
|
private static Pair<Integer, Integer> getPlayerSlotCount(GameData gameData) {
|
||||||
int total = gameData.getGameSettings().getPlayerList().size();
|
int total = gameData.getGameSettings().getPlayerList().size();
|
||||||
int occupied = total;
|
int occupied = total;
|
||||||
|
@ -214,11 +239,17 @@ class GameListPanel extends JPanel implements IGameListPanel {
|
||||||
return new Pair<Integer, Integer>(occupied, total);
|
return new Pair<Integer, Integer>(occupied, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class presenting the game data in a readable way
|
||||||
|
*/
|
||||||
private static class GameDataCellRenderer extends JPanel implements
|
private static class GameDataCellRenderer extends JPanel implements
|
||||||
ListCellRenderer {
|
ListCellRenderer {
|
||||||
private static final long serialVersionUID = -892701906163443927L;
|
private static final long serialVersionUID = -892701906163443927L;
|
||||||
JLabel hostLabel, playerCountLabel;
|
JLabel hostLabel, playerCountLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new game data cell renderer
|
||||||
|
*/
|
||||||
GameDataCellRenderer() {
|
GameDataCellRenderer() {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
|
|
@ -140,6 +140,9 @@ class HandPanel extends AbstractStonePanel implements IHandPanel {
|
||||||
playerPanel.updateButtons();
|
playerPanel.updateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates panel after visible row changed
|
||||||
|
*/
|
||||||
void rowUp() {
|
void rowUp() {
|
||||||
currentRow--;
|
currentRow--;
|
||||||
repaintAll = true;
|
repaintAll = true;
|
||||||
|
@ -148,6 +151,9 @@ class HandPanel extends AbstractStonePanel implements IHandPanel {
|
||||||
playerPanel.updateButtons();
|
playerPanel.updateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates panel after visible row changed
|
||||||
|
*/
|
||||||
void rowDown() {
|
void rowDown() {
|
||||||
currentRow++;
|
currentRow++;
|
||||||
repaintAll = true;
|
repaintAll = true;
|
||||||
|
@ -163,10 +169,20 @@ class HandPanel extends AbstractStonePanel implements IHandPanel {
|
||||||
playerPanel.updateButtons();
|
playerPanel.updateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there a higher row than the current row
|
||||||
|
*
|
||||||
|
* @return higher row present
|
||||||
|
*/
|
||||||
boolean canRowUp() {
|
boolean canRowUp() {
|
||||||
return (currentRow > 0);
|
return (currentRow > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there a lower row than the current row
|
||||||
|
*
|
||||||
|
* @return higher row present
|
||||||
|
*/
|
||||||
boolean canRowDown() {
|
boolean canRowDown() {
|
||||||
return (currentRow < maxRow);
|
return (currentRow < maxRow);
|
||||||
}
|
}
|
||||||
|
@ -188,6 +204,13 @@ class HandPanel extends AbstractStonePanel implements IHandPanel {
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rescales the hand panel according to window size
|
||||||
|
*
|
||||||
|
* @param height
|
||||||
|
* of hand panel
|
||||||
|
* @return width of hand panel
|
||||||
|
*/
|
||||||
int rescale(int height) {
|
int rescale(int height) {
|
||||||
Insets insets = getInsets();
|
Insets insets = getInsets();
|
||||||
int size = (height - insets.top - insets.bottom) / HEIGHT;
|
int size = (height - insets.top - insets.bottom) / HEIGHT;
|
||||||
|
|
Reference in a new issue