diff options
Diffstat (limited to 'src/jrummikub/view/impl')
-rw-r--r-- | src/jrummikub/view/impl/AbstractStonePanel.java (renamed from src/jrummikub/view/impl/StonePanel.java) | 6 | ||||
-rw-r--r-- | src/jrummikub/view/impl/HandPanel.java (renamed from src/jrummikub/view/impl/Board.java) | 20 | ||||
-rw-r--r-- | src/jrummikub/view/impl/PlayerPanel.java | 16 | ||||
-rw-r--r-- | src/jrummikub/view/impl/StoneCollectionPanel.java (renamed from src/jrummikub/view/impl/StoneCollection.java) | 6 | ||||
-rw-r--r-- | src/jrummikub/view/impl/StonePainter.java | 4 | ||||
-rw-r--r-- | src/jrummikub/view/impl/TablePanel.java (renamed from src/jrummikub/view/impl/Table.java) | 16 | ||||
-rw-r--r-- | src/jrummikub/view/impl/View.java | 10 |
7 files changed, 39 insertions, 39 deletions
diff --git a/src/jrummikub/view/impl/StonePanel.java b/src/jrummikub/view/impl/AbstractStonePanel.java index 9e84349..8ab18d8 100644 --- a/src/jrummikub/view/impl/StonePanel.java +++ b/src/jrummikub/view/impl/AbstractStonePanel.java @@ -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); diff --git a/src/jrummikub/view/impl/Board.java b/src/jrummikub/view/impl/HandPanel.java index 94571e0..1610c00 100644 --- a/src/jrummikub/view/impl/Board.java +++ b/src/jrummikub/view/impl/HandPanel.java @@ -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); } diff --git a/src/jrummikub/view/impl/PlayerPanel.java b/src/jrummikub/view/impl/PlayerPanel.java index 9136e85..0a7e64a 100644 --- a/src/jrummikub/view/impl/PlayerPanel.java +++ b/src/jrummikub/view/impl/PlayerPanel.java @@ -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 { diff --git a/src/jrummikub/view/impl/StoneCollection.java b/src/jrummikub/view/impl/StoneCollectionPanel.java index a374dd2..e4ca1c6 100644 --- a/src/jrummikub/view/impl/StoneCollection.java +++ b/src/jrummikub/view/impl/StoneCollectionPanel.java @@ -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); diff --git a/src/jrummikub/view/impl/StonePainter.java b/src/jrummikub/view/impl/StonePainter.java index 47c0e9b..b901e78 100644 --- a/src/jrummikub/view/impl/StonePainter.java +++ b/src/jrummikub/view/impl/StonePainter.java @@ -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); diff --git a/src/jrummikub/view/impl/Table.java b/src/jrummikub/view/impl/TablePanel.java index 1d78ac1..b02a9a9 100644 --- a/src/jrummikub/view/impl/Table.java +++ b/src/jrummikub/view/impl/TablePanel.java @@ -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() { diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java index a257034..7ef0e18 100644 --- a/src/jrummikub/view/impl/View.java +++ b/src/jrummikub/view/impl/View.java @@ -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); } } |