summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-06 02:55:22 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-06 02:55:22 +0200
commitd6fc29d32619f3a0e5db09bf4739f49e78a60fa1 (patch)
treedba6beab826625002645e26d6b9820d7167fc758
parent367aa6a65cd7b593e4f3628db246e1460e25326b (diff)
downloadJRummikub-d6fc29d32619f3a0e5db09bf4739f49e78a60fa1.tar
JRummikub-d6fc29d32619f3a0e5db09bf4739f49e78a60fa1.zip
Rework collection border
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@164 72836036-5685-4462-b002-a69064685172
-rw-r--r--src/jrummikub/view/impl/StoneCollectionPanel.java25
-rw-r--r--src/jrummikub/view/impl/TablePanel.java5
2 files changed, 13 insertions, 17 deletions
diff --git a/src/jrummikub/view/impl/StoneCollectionPanel.java b/src/jrummikub/view/impl/StoneCollectionPanel.java
index a3453d1..e4a9c94 100644
--- a/src/jrummikub/view/impl/StoneCollectionPanel.java
+++ b/src/jrummikub/view/impl/StoneCollectionPanel.java
@@ -2,16 +2,15 @@ package jrummikub.view.impl;
import java.awt.Graphics;
import java.awt.Graphics2D;
-import java.awt.Insets;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
+import java.awt.geom.RoundRectangle2D;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.swing.ImageIcon;
-import javax.swing.border.EmptyBorder;
import jrummikub.model.Position;
import jrummikub.model.Stone;
@@ -28,10 +27,7 @@ class StoneCollectionPanel extends AbstractStonePanel implements
HandPanel.class.getResource("/jrummikub/resource/felt.png"));
private final static ImageIcon DARK_BACKGROUND = new ImageIcon(
HandPanel.class.getResource("/jrummikub/resource/dark_felt.png"));
- /**
- * The width of the border of the collection panel
- */
- public final static int INSET = 7;
+ private final static float INSET_RATIO = 0.1f;
private Collection<Stone> selectedStones = Collections.emptyList();
@@ -39,8 +35,6 @@ class StoneCollectionPanel extends AbstractStonePanel implements
* Creates a new StoneCollection instance
*/
StoneCollectionPanel() {
- setBorder(new EmptyBorder(INSET, INSET, INSET, INSET));
-
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
@@ -50,8 +44,7 @@ class StoneCollectionPanel extends AbstractStonePanel implements
}
private void rescale() {
- Insets insets = getInsets();
- int height = getHeight() - insets.top - insets.bottom;
+ int height = getHeight() - 2 * (int) (getHeight() * INSET_RATIO);
getStonePainter().setScale(height * StonePainter.HEIGHT_SCALE);
repaint();
@@ -80,11 +73,12 @@ class StoneCollectionPanel extends AbstractStonePanel implements
@Override
protected Pair<Integer, Integer> getTranslation() {
+ int inset = (int) (getHeight() * INSET_RATIO);
int width = getStonePainter().getStoneWidth() * selectedStones.size() + 2
- * INSET;
+ * inset;
int x = (getWidth() - width) / 2;
- return new Pair<Integer, Integer>(x + INSET, INSET);
+ return new Pair<Integer, Integer>(x + inset, inset);
}
@Override
@@ -95,10 +89,13 @@ class StoneCollectionPanel extends AbstractStonePanel implements
}
}
+ int inset = (int) (getHeight() * INSET_RATIO);
int width = getStonePainter().getStoneWidth() * selectedStones.size() + 2
- * INSET, height = getHeight();
+ * inset, height = getHeight();
int x = (getWidth() - width) / 2;
Graphics2D g = (Graphics2D) g1.create(x, 0, width, height);
+ g.setClip(new RoundRectangle2D.Float(0, 0, width, height, inset * 1.5f,
+ inset * 1.5f));
if (!selectedStones.isEmpty()) {
for (int xpos = 0; xpos < width; xpos += DARK_BACKGROUND.getIconWidth()) {
@@ -108,7 +105,7 @@ class StoneCollectionPanel extends AbstractStonePanel implements
}
}
- g.translate(INSET, INSET);
+ g.translate(inset, inset);
float xpos = 0;
diff --git a/src/jrummikub/view/impl/TablePanel.java b/src/jrummikub/view/impl/TablePanel.java
index 2c7d899..19489f2 100644
--- a/src/jrummikub/view/impl/TablePanel.java
+++ b/src/jrummikub/view/impl/TablePanel.java
@@ -37,7 +37,7 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
private final static float HORIZONTAL_MARGIN = 1.5f;
private final static float VERTICAL_MARGIN = 1;
private final static float CONNECTOR_WIDTH = 0.25f;
- private final float COLLECTION_RATIO = 0.1f;
+ private final float COLLECTION_RATIO = 0.12f;
private final int COLLECTION_GAP = 5;
private JLabel leftPlayerLabel, topPlayerLabel, rightPlayerLabel;
@@ -191,8 +191,7 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
getStonePainter().setScale(Math.min(widthScale, heightScale));
- int collectionHeight = (int) (height * COLLECTION_RATIO) + 2
- * StoneCollectionPanel.INSET;
+ int collectionHeight = (int) (height * COLLECTION_RATIO);
stoneCollection
.setBounds(x, y + height - collectionHeight - COLLECTION_GAP, width,
collectionHeight);