summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/TablePanel.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-06 01:35:21 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-06 01:35:21 +0200
commit794e3573f6d96775b76cfeb1c833d343a52d2055 (patch)
tree7f1bb9d9cbdb9577910355774f9d7392f67921c1 /src/jrummikub/view/impl/TablePanel.java
parent193e9247fac9d10e3c32cc7cacb65406ef9d19c8 (diff)
downloadJRummikub-794e3573f6d96775b76cfeb1c833d343a52d2055.tar
JRummikub-794e3573f6d96775b76cfeb1c833d343a52d2055.zip
A lot of view performance optimizations
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@162 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/TablePanel.java')
-rw-r--r--src/jrummikub/view/impl/TablePanel.java29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/jrummikub/view/impl/TablePanel.java b/src/jrummikub/view/impl/TablePanel.java
index 080d476..2c7d899 100644
--- a/src/jrummikub/view/impl/TablePanel.java
+++ b/src/jrummikub/view/impl/TablePanel.java
@@ -4,10 +4,8 @@ import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
-import java.awt.RenderingHints;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
@@ -31,7 +29,7 @@ import jrummikub.view.ITablePanel;
*/
@SuppressWarnings("serial")
class TablePanel extends AbstractStonePanel implements ITablePanel {
- private final static ImageIcon background = new ImageIcon(
+ private final static ImageIcon BACKGROUND = new ImageIcon(
HandPanel.class.getResource("/jrummikub/resource/felt.png"));
private final static float MIN_VISIBLE_WIDTH = 15;
@@ -141,15 +139,12 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
stoneCollection = new StoneCollectionPanel();
add(stoneCollection);
- ComponentListener rescaleListener = new ComponentAdapter() {
+ addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
rescale();
}
- };
-
- addComponentListener(rescaleListener);
- stoneCollection.addComponentListener(rescaleListener);
+ });
}
private Rectangle2D calculateTableExtent() {
@@ -187,9 +182,6 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
topPlayerLabel.setBounds(x, y, width, height);
rightPlayerLabel.setBounds(x, y, width, height);
- stoneCollection.setLocation(x + width / 2 - stoneCollection.getWidth() / 2,
- y + height - stoneCollection.getHeight() - COLLECTION_GAP);
-
Rectangle2D extent = calculateTableExtent();
float widthScale = width / (float) extent.getWidth()
@@ -199,7 +191,11 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
getStonePainter().setScale(Math.min(widthScale, heightScale));
- stoneCollection.setStoneHeight((int) (height * COLLECTION_RATIO));
+ int collectionHeight = (int) (height * COLLECTION_RATIO) + 2
+ * StoneCollectionPanel.INSET;
+ stoneCollection
+ .setBounds(x, y + height - collectionHeight - COLLECTION_GAP, width,
+ collectionHeight);
repaint();
}
@@ -267,9 +263,9 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
protected void paintComponent(Graphics g1) {
Graphics2D g = (Graphics2D) g1;
- for (int x = 0; x < getWidth(); x += background.getIconWidth()) {
- for (int y = 0; y < getHeight(); y += background.getIconHeight()) {
- background.paintIcon(this, g, x, y);
+ for (int x = 0; x < getWidth(); x += BACKGROUND.getIconWidth()) {
+ for (int y = 0; y < getHeight(); y += BACKGROUND.getIconHeight()) {
+ BACKGROUND.paintIcon(this, g, x, y);
}
}
@@ -278,9 +274,6 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
Pair<Integer, Integer> translation = getTranslation();
g.translate(translation.getFirst(), translation.getSecond());
- g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
-
for (Pair<StoneSet, Position> entry : stoneSets) {
paintStoneSet(g, entry.getFirst(), entry.getSecond());
}