Rework collection border
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@164 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
367aa6a65c
commit
d6fc29d326
2 changed files with 13 additions and 17 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Reference in a new issue