Show winners in score panel
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@322 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
2b38167087
commit
5406d540d3
1 changed files with 14 additions and 0 deletions
|
@ -2,12 +2,15 @@ package jrummikub.view.impl;
|
|||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
@ -20,6 +23,11 @@ import jrummikub.view.IScorePanel;
|
|||
|
||||
@SuppressWarnings("serial")
|
||||
class ScorePanel extends JPanel implements IScorePanel {
|
||||
private final static ImageIcon STAR_ICON = new ImageIcon(
|
||||
ScorePanel.class.getResource("/jrummikub/resource/star.png"));
|
||||
private final static ImageIcon EMPTY_ICON = new ImageIcon(new BufferedImage(
|
||||
16, 16, BufferedImage.TYPE_INT_ARGB));
|
||||
|
||||
private Iterable<PlayerSettings> players;
|
||||
private Iterable<Score> scores;
|
||||
private Score accumulatedScore;
|
||||
|
@ -136,7 +144,10 @@ class ScorePanel extends JPanel implements IScorePanel {
|
|||
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||
}
|
||||
|
||||
boolean won = score.getWinners().get(i);
|
||||
JLabel scoreLabel = new JLabel(Integer.toString(score.getPoints().get(i)));
|
||||
scoreLabel.setIcon(won ? STAR_ICON : EMPTY_ICON);
|
||||
scoreLabel.setFont(scoreLabel.getFont().deriveFont(won ? Font.BOLD : 0));
|
||||
scoreLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||
innerPanel.add(scoreLabel, c);
|
||||
}
|
||||
|
@ -160,8 +171,11 @@ class ScorePanel extends JPanel implements IScorePanel {
|
|||
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||
}
|
||||
|
||||
boolean won = accumulatedScore.getWinners().get(i);
|
||||
JLabel scoreLabel = new JLabel(Integer.toString(accumulatedScore
|
||||
.getPoints().get(i)));
|
||||
scoreLabel.setIcon(won ? STAR_ICON : EMPTY_ICON);
|
||||
scoreLabel.setFont(scoreLabel.getFont().deriveFont(won ? Font.BOLD : 0));
|
||||
scoreLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||
innerPanel.add(scoreLabel, c);
|
||||
}
|
||||
|
|
Reference in a new issue