Make score panel look nice
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@316 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
43ace4c18a
commit
d9b651828a
1 changed files with 57 additions and 25 deletions
|
@ -1,12 +1,16 @@
|
||||||
package jrummikub.view.impl;
|
package jrummikub.view.impl;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JSeparator;
|
import javax.swing.JSeparator;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
|
|
||||||
|
@ -20,9 +24,26 @@ class ScorePanel extends JPanel implements IScorePanel {
|
||||||
private Iterable<Score> scores;
|
private Iterable<Score> scores;
|
||||||
private Score accumulatedScore;
|
private Score accumulatedScore;
|
||||||
|
|
||||||
|
private JScrollPane scrollPane;
|
||||||
|
private JPanel innerPanel;
|
||||||
|
|
||||||
public ScorePanel() {
|
public ScorePanel() {
|
||||||
setLayout(new GridBagLayout());
|
|
||||||
setBorder(new LineBorder(Color.BLACK));
|
setBorder(new LineBorder(Color.BLACK));
|
||||||
|
setLayout(new BorderLayout(0, 5));
|
||||||
|
|
||||||
|
JLabel titleLabel = new JLabel("Auswertung");
|
||||||
|
titleLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
titleLabel.setFont(titleLabel.getFont().deriveFont(20.0f));
|
||||||
|
add(titleLabel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
innerPanel = new JPanel();
|
||||||
|
innerPanel.setLayout(new GridBagLayout());
|
||||||
|
|
||||||
|
scrollPane = new JScrollPane(innerPanel,
|
||||||
|
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
|
||||||
|
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||||
|
|
||||||
|
add(scrollPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,35 +63,41 @@ class ScorePanel extends JPanel implements IScorePanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
this.removeAll();
|
innerPanel.removeAll();
|
||||||
|
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.BOTH;
|
c.fill = GridBagConstraints.BOTH;
|
||||||
c.weightx = 1.0;
|
c.weightx = 1.0;
|
||||||
|
c.weighty = 0.0;
|
||||||
c.gridwidth = GridBagConstraints.REMAINDER;
|
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||||
|
|
||||||
addPlayerNames();
|
addPlayerNames();
|
||||||
|
|
||||||
add(new JSeparator(), c);
|
innerPanel.add(new JSeparator(), c);
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (Iterator<Score> it = scores.iterator(); it.hasNext();) {
|
for (Iterator<Score> it = scores.iterator(); it.hasNext();) {
|
||||||
addScoreRow(it.next(), ++n);
|
addScoreRow(it.next(), ++n);
|
||||||
}
|
}
|
||||||
|
|
||||||
add(new JSeparator(), c);
|
innerPanel.add(new JSeparator(), c);
|
||||||
|
|
||||||
addAccumulatedScore();
|
addAccumulatedScore();
|
||||||
|
|
||||||
|
c.weighty = 1;
|
||||||
|
innerPanel.add(Box.createVerticalGlue(), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPlayerNames() {
|
private void addPlayerNames() {
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.BOTH;
|
c.fill = GridBagConstraints.BOTH;
|
||||||
c.weightx = 1.0;
|
c.weightx = 1.0;
|
||||||
|
c.weighty = 0.0;
|
||||||
|
c.insets = new Insets(0, 7, 0, 7);
|
||||||
|
|
||||||
JLabel roundHead = new JLabel("Runde");
|
JLabel roundHead = new JLabel("Runde");
|
||||||
roundHead.setHorizontalAlignment(JLabel.CENTER);
|
roundHead.setHorizontalAlignment(JLabel.CENTER);
|
||||||
add(roundHead, c);
|
innerPanel.add(roundHead, c);
|
||||||
|
|
||||||
for (Iterator<PlayerSettings> it = players.iterator(); it.hasNext();) {
|
for (Iterator<PlayerSettings> it = players.iterator(); it.hasNext();) {
|
||||||
PlayerSettings player = it.next();
|
PlayerSettings player = it.next();
|
||||||
|
@ -84,7 +111,7 @@ class ScorePanel extends JPanel implements IScorePanel {
|
||||||
1));
|
1));
|
||||||
playerNameLabel.setHorizontalAlignment(JLabel.CENTER);
|
playerNameLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
|
||||||
add(playerNameLabel, c);
|
innerPanel.add(playerNameLabel, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,11 +119,13 @@ class ScorePanel extends JPanel implements IScorePanel {
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.BOTH;
|
c.fill = GridBagConstraints.BOTH;
|
||||||
c.weightx = 1.0;
|
c.weightx = 1.0;
|
||||||
|
c.weighty = 0.0;
|
||||||
c.gridwidth = 1;
|
c.gridwidth = 1;
|
||||||
|
c.insets = new Insets(0, 7, 0, 7);
|
||||||
|
|
||||||
JLabel roundLabel = new JLabel(Integer.toString(n));
|
JLabel roundLabel = new JLabel(Integer.toString(n));
|
||||||
roundLabel.setHorizontalAlignment(JLabel.CENTER);
|
roundLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
add(roundLabel, c);
|
innerPanel.add(roundLabel, c);
|
||||||
|
|
||||||
for (int i = 0; i < score.getPoints().size(); ++i) {
|
for (int i = 0; i < score.getPoints().size(); ++i) {
|
||||||
if (i == score.getPoints().size() - 1) {
|
if (i == score.getPoints().size() - 1) {
|
||||||
|
@ -105,7 +134,7 @@ class ScorePanel extends JPanel implements IScorePanel {
|
||||||
|
|
||||||
JLabel scoreLabel = new JLabel(Integer.toString(score.getPoints().get(i)));
|
JLabel scoreLabel = new JLabel(Integer.toString(score.getPoints().get(i)));
|
||||||
scoreLabel.setHorizontalAlignment(JLabel.CENTER);
|
scoreLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
add(scoreLabel, c);
|
innerPanel.add(scoreLabel, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,19 +142,22 @@ class ScorePanel extends JPanel implements IScorePanel {
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.BOTH;
|
c.fill = GridBagConstraints.BOTH;
|
||||||
c.weightx = 1.0;
|
c.weightx = 1.0;
|
||||||
|
c.weighty = 0.0;
|
||||||
|
c.insets = new Insets(0, 7, 0, 7);
|
||||||
|
|
||||||
JLabel accumLabel = new JLabel("Gesamt");
|
JLabel accumLabel = new JLabel("Gesamt");
|
||||||
accumLabel.setHorizontalAlignment(JLabel.CENTER);
|
accumLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
add(accumLabel, c);
|
innerPanel.add(accumLabel, c);
|
||||||
|
|
||||||
for (int i = 0; i < accumulatedScore.getPoints().size(); ++i) {
|
for (int i = 0; i < accumulatedScore.getPoints().size(); ++i) {
|
||||||
if (i == accumulatedScore.getPoints().size() - 1) {
|
if (i == accumulatedScore.getPoints().size() - 1) {
|
||||||
c.gridwidth = GridBagConstraints.REMAINDER;
|
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
JLabel scoreLabel = new JLabel(Integer.toString(accumulatedScore.getPoints().get(i)));
|
JLabel scoreLabel = new JLabel(Integer.toString(accumulatedScore
|
||||||
|
.getPoints().get(i)));
|
||||||
scoreLabel.setHorizontalAlignment(JLabel.CENTER);
|
scoreLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
add(scoreLabel, c);
|
innerPanel.add(scoreLabel, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue