Renamed everything in the view
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@75 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
e7b428c019
commit
3e257e3979
13 changed files with 60 additions and 60 deletions
|
@ -33,9 +33,9 @@ public class JRummikub {
|
|||
|
||||
view.getPlayerPanel().setCurrentPlayerName("Player 1");
|
||||
view.getPlayerPanel().setTimeLeft(42);
|
||||
view.getTable().setLeftPlayerName("Player 2");
|
||||
view.getTable().setTopPlayerName("Player 3");
|
||||
view.getTable().setRightPlayerName("Player 4");
|
||||
view.getTablePanel().setLeftPlayerName("Player 2");
|
||||
view.getTablePanel().setTopPlayerName("Player 3");
|
||||
view.getTablePanel().setRightPlayerName("Player 4");
|
||||
|
||||
view.getPlayerPanel().getSortByNumberEvent().add(new IListener() {
|
||||
@Override
|
||||
|
@ -67,9 +67,9 @@ public class JRummikub {
|
|||
stones.put(stoneJoker, new Position(2.5f, 0));
|
||||
stones.put(new Stone(StoneColor.BLACK), new Position(3.5f, 0));
|
||||
|
||||
view.getPlayerPanel().getBoard().setStones(stones);
|
||||
view.getPlayerPanel().getHandPanel().setStones(stones);
|
||||
|
||||
view.getPlayerPanel().getBoard().getClickEvent()
|
||||
view.getPlayerPanel().getHandPanel().getClickEvent()
|
||||
.add(new IListener2<Position, Boolean>() {
|
||||
@Override
|
||||
public void fire(Position p, Boolean collect) {
|
||||
|
@ -78,7 +78,7 @@ public class JRummikub {
|
|||
|
||||
}
|
||||
});
|
||||
view.getPlayerPanel().getBoard().getRangeClickEvent()
|
||||
view.getPlayerPanel().getHandPanel().getRangeClickEvent()
|
||||
.add(new IListener2<Position, Boolean>() {
|
||||
@Override
|
||||
public void fire(Position p, Boolean collect) {
|
||||
|
@ -87,7 +87,7 @@ public class JRummikub {
|
|||
|
||||
}
|
||||
});
|
||||
view.getPlayerPanel().getBoard().getSetClickEvent()
|
||||
view.getPlayerPanel().getHandPanel().getSetClickEvent()
|
||||
.add(new IListener2<Position, Boolean>() {
|
||||
@Override
|
||||
public void fire(Position p, Boolean collect) {
|
||||
|
@ -97,7 +97,7 @@ public class JRummikub {
|
|||
}
|
||||
});
|
||||
|
||||
view.getTable().getClickEvent().add(new IListener2<Position, Boolean>() {
|
||||
view.getTablePanel().getClickEvent().add(new IListener2<Position, Boolean>() {
|
||||
@Override
|
||||
public void fire(Position p, Boolean collect) {
|
||||
System.out.println("Table clicked at " + p
|
||||
|
@ -105,7 +105,7 @@ public class JRummikub {
|
|||
|
||||
}
|
||||
});
|
||||
view.getTable().getRangeClickEvent()
|
||||
view.getTablePanel().getRangeClickEvent()
|
||||
.add(new IListener2<Position, Boolean>() {
|
||||
@Override
|
||||
public void fire(Position p, Boolean collect) {
|
||||
|
@ -114,7 +114,7 @@ public class JRummikub {
|
|||
|
||||
}
|
||||
});
|
||||
view.getTable().getSetClickEvent().add(new IListener2<Position, Boolean>() {
|
||||
view.getTablePanel().getSetClickEvent().add(new IListener2<Position, Boolean>() {
|
||||
@Override
|
||||
public void fire(Position p, Boolean collect) {
|
||||
System.out.println("Table set-clicked at " + p
|
||||
|
@ -123,7 +123,7 @@ public class JRummikub {
|
|||
}
|
||||
});
|
||||
|
||||
view.getTable().getStoneCollection().getClickEvent()
|
||||
view.getTablePanel().getStoneCollectionPanel().getClickEvent()
|
||||
.add(new IListener2<Position, Boolean>() {
|
||||
@Override
|
||||
public void fire(Position p, Boolean collect) {
|
||||
|
@ -132,7 +132,7 @@ public class JRummikub {
|
|||
|
||||
}
|
||||
});
|
||||
view.getTable().getStoneCollection().getRangeClickEvent()
|
||||
view.getTablePanel().getStoneCollectionPanel().getRangeClickEvent()
|
||||
.add(new IListener2<Position, Boolean>() {
|
||||
@Override
|
||||
public void fire(Position p, Boolean collect) {
|
||||
|
@ -141,7 +141,7 @@ public class JRummikub {
|
|||
|
||||
}
|
||||
});
|
||||
view.getTable().getStoneCollection().getSetClickEvent()
|
||||
view.getTablePanel().getStoneCollectionPanel().getSetClickEvent()
|
||||
.add(new IListener2<Position, Boolean>() {
|
||||
@Override
|
||||
public void fire(Position p, Boolean collect) {
|
||||
|
@ -167,7 +167,7 @@ public class JRummikub {
|
|||
|
||||
stoneSets.put(new StoneSet(stoneList), new Position(3.5f, 4));
|
||||
|
||||
view.getTable().setStoneSets(stoneSets);
|
||||
view.getTablePanel().setStoneSets(stoneSets);
|
||||
|
||||
view.setSelectedStones(Arrays.asList(stoneJoker, stone8));
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ import jrummikub.model.Position;
|
|||
import jrummikub.model.Stone;
|
||||
|
||||
/**
|
||||
* The view for a player's board that displayed his stones
|
||||
* The view for a player's hand that displays his stones
|
||||
*/
|
||||
public interface IBoard extends IClickable {
|
||||
public interface IHandPanel extends IClickable {
|
||||
/**
|
||||
* Set the player's stones to display on the board
|
||||
*
|
|
@ -9,7 +9,7 @@ public interface IPlayerPanel {
|
|||
/**
|
||||
* @return the board where the players hand stones are displayed
|
||||
*/
|
||||
public IBoard getBoard();
|
||||
public IHandPanel getHandPanel();
|
||||
|
||||
/**
|
||||
* Sets the current player's name
|
||||
|
|
|
@ -3,5 +3,5 @@ package jrummikub.view;
|
|||
/**
|
||||
* The view of the collection that shows the stones a player has selected
|
||||
*/
|
||||
public interface IStoneCollection extends IClickable {
|
||||
public interface IStoneCollectionPanel extends IClickable {
|
||||
}
|
|
@ -8,7 +8,7 @@ import jrummikub.model.StoneSet;
|
|||
/**
|
||||
* The view of the table, where the stone sets lie
|
||||
*/
|
||||
public interface ITable extends IClickable {
|
||||
public interface ITablePanel extends IClickable {
|
||||
/**
|
||||
* Sets the player name on the left label
|
||||
*
|
||||
|
@ -47,5 +47,5 @@ public interface ITable extends IClickable {
|
|||
*
|
||||
* @return the stone collection
|
||||
*/
|
||||
IStoneCollection getStoneCollection();
|
||||
IStoneCollectionPanel getStoneCollectionPanel();
|
||||
}
|
|
@ -13,7 +13,7 @@ public interface IView {
|
|||
*
|
||||
* @return the table
|
||||
*/
|
||||
public ITable getTable();
|
||||
public ITablePanel getTablePanel();
|
||||
|
||||
/**
|
||||
* Returns the player panel
|
||||
|
|
|
@ -14,7 +14,7 @@ import jrummikub.view.IClickable;
|
|||
* Base class for panels that draw stones
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
abstract class StonePanel extends JPanel implements IClickable {
|
||||
abstract class AbstractStonePanel extends JPanel implements IClickable {
|
||||
private StonePainter stonePainter;
|
||||
|
||||
private Event2<Position, Boolean> clickEvent = new Event2<Position, Boolean>();
|
||||
|
@ -31,7 +31,7 @@ abstract class StonePanel extends JPanel implements IClickable {
|
|||
/**
|
||||
* Create a new StonePanel with default scale factor
|
||||
*/
|
||||
public StonePanel() {
|
||||
public AbstractStonePanel() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ abstract class StonePanel extends JPanel implements IClickable {
|
|||
* @param scale
|
||||
* the grid scale
|
||||
*/
|
||||
public StonePanel(float scale) {
|
||||
public AbstractStonePanel(float scale) {
|
||||
super(true); // Set double buffered
|
||||
|
||||
stonePainter = new StonePainter(scale);
|
|
@ -18,20 +18,20 @@ import javax.swing.border.MatteBorder;
|
|||
|
||||
import jrummikub.model.Position;
|
||||
import jrummikub.model.Stone;
|
||||
import jrummikub.view.IBoard;
|
||||
import jrummikub.view.IHandPanel;
|
||||
|
||||
/**
|
||||
* Implementation of the board
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
class Board extends StonePanel implements IBoard {
|
||||
private final static int BOARD_HEIGHT = 2;
|
||||
private final static int BOARD_WIDTH = 14;
|
||||
class HandPanel extends AbstractStonePanel implements IHandPanel {
|
||||
private final static int HAND_HEIGHT = 2;
|
||||
private final static int HAND_WIDTH = 14;
|
||||
|
||||
private final static BufferedImage BACKGROUND;
|
||||
static {
|
||||
ImageIcon image = new ImageIcon(
|
||||
Board.class.getResource("/jrummikub/resource/wood.png"));
|
||||
HandPanel.class.getResource("/jrummikub/resource/wood.png"));
|
||||
BACKGROUND = new BufferedImage(image.getIconWidth(), image.getIconHeight(),
|
||||
BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
|
@ -45,7 +45,7 @@ class Board extends StonePanel implements IBoard {
|
|||
/**
|
||||
* Creates a new Board instance
|
||||
*/
|
||||
Board() {
|
||||
HandPanel() {
|
||||
setBorder(new MatteBorder(0, 1, 0, 1, Color.DARK_GRAY));
|
||||
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
|
@ -53,11 +53,11 @@ class Board extends StonePanel implements IBoard {
|
|||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
Insets insets = getInsets();
|
||||
int size = (getHeight() - insets.top - insets.bottom) / BOARD_HEIGHT;
|
||||
int size = (getHeight() - insets.top - insets.bottom) / HAND_HEIGHT;
|
||||
|
||||
getStonePainter().setScale(size * StonePainter.HEIGHT_SCALE);
|
||||
|
||||
setSize(new Dimension(BOARD_WIDTH * getStonePainter().getStoneWidth()
|
||||
setSize(new Dimension(HAND_WIDTH * getStonePainter().getStoneWidth()
|
||||
+ insets.left + insets.right, getHeight()));
|
||||
}
|
||||
});
|
||||
|
@ -81,12 +81,12 @@ class Board extends StonePanel implements IBoard {
|
|||
int x = insets.left, y = insets.top, width = getWidth() - insets.left
|
||||
- insets.right, height = getHeight() - insets.top - insets.bottom;
|
||||
Graphics2D g = (Graphics2D) g1.create(x, y, width, height);
|
||||
int size = height / BOARD_HEIGHT;
|
||||
int size = height / HAND_HEIGHT;
|
||||
|
||||
if (scaledBackground.getHeight() != size)
|
||||
scaledBackground = getScaledBackground(size);
|
||||
|
||||
for (int i = 0; i < BOARD_HEIGHT; ++i) {
|
||||
for (int i = 0; i < HAND_HEIGHT; ++i) {
|
||||
for (int xpos = -size * i / 3; xpos < width; xpos += size) {
|
||||
g.drawImage(scaledBackground, xpos, size * i, null);
|
||||
}
|
|
@ -31,7 +31,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
|
|||
|
||||
private final static DecimalFormat secondFormat = new DecimalFormat("00");
|
||||
|
||||
private Board board;
|
||||
private HandPanel hand;
|
||||
|
||||
private JPanel leftPanel, rightPanel;
|
||||
|
||||
|
@ -46,8 +46,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
|
|||
private Event endTurnEvent = new Event();
|
||||
|
||||
@Override
|
||||
public Board getBoard() {
|
||||
return board;
|
||||
public HandPanel getHandPanel() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,11 +144,11 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
|
|||
Insets insets = getInsets();
|
||||
int x = insets.left, y = insets.top, width = getWidth() - insets.left
|
||||
- insets.right, height = getHeight() - insets.top - insets.bottom;
|
||||
int boardWidth = board.getWidth();
|
||||
int boardWidth = hand.getWidth();
|
||||
int panelWidth = (width - boardWidth) / 2;
|
||||
|
||||
leftPanel.setBounds(x, y, panelWidth, height);
|
||||
board.setBounds(x + panelWidth, y, boardWidth, height);
|
||||
hand.setBounds(x + panelWidth, y, boardWidth, height);
|
||||
rightPanel.setBounds(x + panelWidth + boardWidth, y, panelWidth, height);
|
||||
|
||||
leftPanel.validate();
|
||||
|
@ -164,8 +164,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
|
|||
createLeftPanel();
|
||||
add(leftPanel);
|
||||
|
||||
board = new Board();
|
||||
add(board);
|
||||
hand = new HandPanel();
|
||||
add(hand);
|
||||
|
||||
createRightPanel();
|
||||
add(rightPanel);
|
||||
|
@ -178,7 +178,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
|
|||
};
|
||||
|
||||
addComponentListener(rescaleListener);
|
||||
board.addComponentListener(rescaleListener);
|
||||
hand.addComponentListener(rescaleListener);
|
||||
}
|
||||
|
||||
private class LeftPanelResizeListener extends ComponentAdapter {
|
||||
|
|
|
@ -11,13 +11,13 @@ import javax.swing.border.EmptyBorder;
|
|||
|
||||
import jrummikub.model.Position;
|
||||
import jrummikub.model.Stone;
|
||||
import jrummikub.view.IStoneCollection;
|
||||
import jrummikub.view.IStoneCollectionPanel;
|
||||
|
||||
/**
|
||||
* Implementation of the stone collection (selection)
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
class StoneCollection extends StonePanel implements IStoneCollection {
|
||||
class StoneCollectionPanel extends AbstractStonePanel implements IStoneCollectionPanel {
|
||||
private final static int INSET = 7;
|
||||
private final static float STONE_SCALE = 1.1f;
|
||||
|
||||
|
@ -26,7 +26,7 @@ class StoneCollection extends StonePanel implements IStoneCollection {
|
|||
/**
|
||||
* Creates a new StoneCollection instance
|
||||
*/
|
||||
StoneCollection() {
|
||||
StoneCollectionPanel() {
|
||||
super(STONE_SCALE);
|
||||
|
||||
setOpaque(false);
|
|
@ -207,7 +207,7 @@ class StonePainter {
|
|||
- faceSize / 2, faceSize, faceSize));
|
||||
}
|
||||
|
||||
private void paintStoneNumber(Graphics2D g, Rectangle r, Color color, int v) {
|
||||
private void paintStoneValue(Graphics2D g, Rectangle r, Color color, int v) {
|
||||
int pos = r.y + (int) (TEXT_POS * r.height);
|
||||
|
||||
g.setFont(new Font("SansSerif", Font.BOLD, r.height / 4));
|
||||
|
@ -266,7 +266,7 @@ class StonePainter {
|
|||
if (stone.isJoker()) {
|
||||
paintJoker(g, rect, color);
|
||||
} else {
|
||||
paintStoneNumber(g, rect, color, stone.getValue());
|
||||
paintStoneValue(g, rect, color, stone.getValue());
|
||||
}
|
||||
|
||||
paintCircle(g, rect, background);
|
||||
|
|
|
@ -18,22 +18,22 @@ import javax.swing.JLabel;
|
|||
import jrummikub.model.Position;
|
||||
import jrummikub.model.Stone;
|
||||
import jrummikub.model.StoneSet;
|
||||
import jrummikub.view.IStoneCollection;
|
||||
import jrummikub.view.ITable;
|
||||
import jrummikub.view.IStoneCollectionPanel;
|
||||
import jrummikub.view.ITablePanel;
|
||||
|
||||
/**
|
||||
* The implementation of the table
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
class Table extends StonePanel implements ITable {
|
||||
class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||
private final static ImageIcon background = new ImageIcon(
|
||||
Board.class.getResource("/jrummikub/resource/felt.png"));
|
||||
HandPanel.class.getResource("/jrummikub/resource/felt.png"));
|
||||
|
||||
private final static float DEFAULT_SCALE = 1;
|
||||
private final int COLLECTION_GAP = 5;
|
||||
|
||||
private JLabel leftPlayerLabel, topPlayerLabel, rightPlayerLabel;
|
||||
private StoneCollection stoneCollection;
|
||||
private StoneCollectionPanel stoneCollection;
|
||||
|
||||
private Map<StoneSet, Position> stoneSets = Collections.emptyMap();
|
||||
private Collection<Stone> selectedStones = Collections.emptyList();
|
||||
|
@ -60,7 +60,7 @@ class Table extends StonePanel implements ITable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IStoneCollection getStoneCollection() {
|
||||
public IStoneCollectionPanel getStoneCollectionPanel() {
|
||||
return stoneCollection;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ class Table extends StonePanel implements ITable {
|
|||
/**
|
||||
* Creates a new Table instance
|
||||
*/
|
||||
Table() {
|
||||
TablePanel() {
|
||||
super(DEFAULT_SCALE);
|
||||
|
||||
setLayout(null);
|
||||
|
@ -117,7 +117,7 @@ class Table extends StonePanel implements ITable {
|
|||
rightPlayerLabel.setHorizontalTextPosition(JLabel.RIGHT);
|
||||
add(rightPlayerLabel);
|
||||
|
||||
stoneCollection = new StoneCollection();
|
||||
stoneCollection = new StoneCollectionPanel();
|
||||
add(stoneCollection);
|
||||
|
||||
ComponentListener rescaleListener = new ComponentAdapter() {
|
|
@ -11,7 +11,7 @@ import javax.swing.border.MatteBorder;
|
|||
|
||||
import jrummikub.model.Stone;
|
||||
import jrummikub.view.IPlayerPanel;
|
||||
import jrummikub.view.ITable;
|
||||
import jrummikub.view.ITablePanel;
|
||||
import jrummikub.view.IView;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ import jrummikub.view.IView;
|
|||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class View extends JFrame implements IView {
|
||||
private Table table;
|
||||
private TablePanel table;
|
||||
private PlayerPanel playerPanel;
|
||||
|
||||
private final static float PLAYER_PANEL_RATIO = 0.14f;
|
||||
|
@ -30,7 +30,7 @@ public class View extends JFrame implements IView {
|
|||
return 2 * (int) (d / 2);
|
||||
}
|
||||
|
||||
public ITable getTable() {
|
||||
public ITablePanel getTablePanel() {
|
||||
return table;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class View extends JFrame implements IView {
|
|||
setSize(800, 600);
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
|
||||
table = new Table();
|
||||
table = new TablePanel();
|
||||
add(table);
|
||||
|
||||
playerPanel = new PlayerPanel();
|
||||
|
@ -83,6 +83,6 @@ public class View extends JFrame implements IView {
|
|||
@Override
|
||||
public void setSelectedStones(Collection<Stone> stones) {
|
||||
table.setSelectedStones(stones);
|
||||
playerPanel.getBoard().setSelectedStones(stones);
|
||||
playerPanel.getHandPanel().setSelectedStones(stones);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue