diff options
-rw-r--r-- | src/jrummikub/view/Board.java | 12 | ||||
-rw-r--r-- | src/jrummikub/view/PlayerPanel.java | 6 | ||||
-rw-r--r-- | src/jrummikub/view/StonePainter.java | 5 | ||||
-rw-r--r-- | src/jrummikub/view/View.java | 4 | ||||
-rw-r--r-- | src/jrummikub/view/resource/wood.png | bin | 35308 -> 17920 bytes |
5 files changed, 18 insertions, 9 deletions
diff --git a/src/jrummikub/view/Board.java b/src/jrummikub/view/Board.java index d0a3173..5fc0390 100644 --- a/src/jrummikub/view/Board.java +++ b/src/jrummikub/view/Board.java @@ -2,6 +2,7 @@ package jrummikub.view; import java.awt.Color; import java.awt.Graphics; +import java.awt.Insets; import javax.swing.ImageIcon; import javax.swing.JPanel; @@ -21,8 +22,15 @@ public class Board extends JPanel implements IBoard { @Override protected void paintComponent(Graphics g) { - for(int x = 0; x < getWidth(); x += background.getIconWidth()) { - background.paintIcon(this, g, x, 0); + Insets insets = getInsets(); + int x = insets.left, y = insets.top, width = getWidth()-insets.left-insets.right, height = getHeight()-insets.top-insets.bottom; + g = g.create(x, y, width, height); + + for(int xpos = 0; xpos < width; xpos += background.getIconWidth()) { + background.paintIcon(this, g, xpos, 0); + } + for(int xpos = -32; xpos < width; xpos += background.getIconWidth()) { + background.paintIcon(this, g, xpos, 75); } // TODO Rest of painting code diff --git a/src/jrummikub/view/PlayerPanel.java b/src/jrummikub/view/PlayerPanel.java index 1688d7c..e9ffff3 100644 --- a/src/jrummikub/view/PlayerPanel.java +++ b/src/jrummikub/view/PlayerPanel.java @@ -65,7 +65,7 @@ public class PlayerPanel extends JPanel implements IPlayerPanel { layout.setConstraints(currentPlayerNameLabel, c); panel.add(currentPlayerNameLabel); - sortByNumberButton = new JButton("<html>Sort by<br>number"); + sortByNumberButton = new JButton("<html><center>Sort by<br>number"); sortByNumberButton.setPreferredSize(new Dimension(85, 50)); c.gridwidth = GridBagConstraints.RELATIVE; c.gridheight = GridBagConstraints.REMAINDER; @@ -73,14 +73,13 @@ public class PlayerPanel extends JPanel implements IPlayerPanel { layout.setConstraints(sortByNumberButton, c); panel.add(sortByNumberButton); - sortByColorButton = new JButton("<html>Sort by<br>color"); + sortByColorButton = new JButton("<html><center>Sort by<br>color"); sortByColorButton.setPreferredSize(new Dimension(85, 50)); c.gridwidth = GridBagConstraints.REMAINDER; c.insets = new Insets(15, 5, 20, 0); layout.setConstraints(sortByColorButton, c); panel.add(sortByColorButton); - return panel; } @@ -118,7 +117,6 @@ public class PlayerPanel extends JPanel implements IPlayerPanel { GridBagConstraints c = new GridBagConstraints(); setLayout(layout); - setBorder(new CustomBorder(Color.BLACK, 1, 0, 0, 0)); setBackground(Color.LIGHT_GRAY); JPanel leftPanel = createLeftPanel(); diff --git a/src/jrummikub/view/StonePainter.java b/src/jrummikub/view/StonePainter.java index dbdf3c8..8b104df 100644 --- a/src/jrummikub/view/StonePainter.java +++ b/src/jrummikub/view/StonePainter.java @@ -18,7 +18,7 @@ class StonePainter { private static final Color BACKGROUND_COLOR = new Color(0.9f, 0.9f, 0.6f); - public static final float BOARD_SCALE = 75.0f/DEFAULT_WIDTH*ASPECT_RATIO; + public static final float BOARD_SCALE = 75.0f*ASPECT_RATIO/DEFAULT_WIDTH; private static Color getColor(StoneColor color) { @@ -43,7 +43,7 @@ class StonePainter { } int width = (int)(DEFAULT_WIDTH*scale); - int height = (int)(width/ASPECT_RATIO); + int height = (int)(DEFAULT_WIDTH*scale/ASPECT_RATIO); int xpos = (int)(x*width); int ypos = (int)(y*height); @@ -84,6 +84,7 @@ class StonePainter { g.setColor(getColor(stone.getColor())); g.drawString(value, (int)(xpos+width/2-stringRect.getWidth()/2), ypos+height/4+(fm.getAscent()-fm.getDescent())/2); + // Paint circle g.setColor(BACKGROUND_COLOR.darker()); g.drawArc((int)(xpos+width/2-width*CIRCLE_WIDTH/2), (int)(ypos+height*0.65f-width*CIRCLE_WIDTH/2), (int)(width*CIRCLE_WIDTH), (int)(width*CIRCLE_WIDTH), 50, 170); diff --git a/src/jrummikub/view/View.java b/src/jrummikub/view/View.java index e2fd037..65e26b5 100644 --- a/src/jrummikub/view/View.java +++ b/src/jrummikub/view/View.java @@ -1,6 +1,7 @@ package jrummikub.view; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Dimension; import javax.swing.JFrame; @@ -35,7 +36,8 @@ public class View extends JFrame implements IView { add(table, BorderLayout.CENTER); playerPanel = new PlayerPanel(); - playerPanel.setPreferredSize(new Dimension(0, PLAYER_PANEL_HEIGHT)); + playerPanel.setBorder(new CustomBorder(Color.BLACK, 1, 0, 0, 0)); + playerPanel.setPreferredSize(new Dimension(0, PLAYER_PANEL_HEIGHT+1)); add(playerPanel, BorderLayout.SOUTH); } diff --git a/src/jrummikub/view/resource/wood.png b/src/jrummikub/view/resource/wood.png Binary files differindex 424ec6d..ed9cf14 100644 --- a/src/jrummikub/view/resource/wood.png +++ b/src/jrummikub/view/resource/wood.png |