View Methoden-Sichtbarkeit korrigiert
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@574 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
3e028004d9
commit
9ced7cf953
6 changed files with 71 additions and 62 deletions
|
@ -35,7 +35,7 @@ public class ConnectPanel extends JPanel implements IConnectPanel {
|
||||||
/**
|
/**
|
||||||
* Creates new connection panel
|
* Creates new connection panel
|
||||||
*/
|
*/
|
||||||
public ConnectPanel() {
|
ConnectPanel() {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
|
|
@ -21,7 +21,7 @@ import jrummikub.view.IQuitWarningPanel;
|
||||||
/**
|
/**
|
||||||
* Warning panel to inform users if their actions would end the current game
|
* Warning panel to inform users if their actions would end the current game
|
||||||
*/
|
*/
|
||||||
public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private JButton cancelButton;
|
private JButton cancelButton;
|
||||||
private JButton quitButton;
|
private JButton quitButton;
|
||||||
|
@ -33,7 +33,7 @@ public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
||||||
/**
|
/**
|
||||||
* Creates new quit warning panel
|
* Creates new quit warning panel
|
||||||
*/
|
*/
|
||||||
public QuitWarningPanel() {
|
QuitWarningPanel() {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ScorePanel extends JPanel implements IScorePanel {
|
||||||
private JScrollPane scrollPane;
|
private JScrollPane scrollPane;
|
||||||
private JPanel innerPanel;
|
private JPanel innerPanel;
|
||||||
|
|
||||||
public ScorePanel() {
|
ScorePanel() {
|
||||||
setBorder(new LineBorder(Color.BLACK));
|
setBorder(new LineBorder(Color.BLACK));
|
||||||
setLayout(new BorderLayout(0, 5));
|
setLayout(new BorderLayout(0, 5));
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class SidePanel extends JPanel implements ISidePanel {
|
||||||
private JProgressBar heapBar;
|
private JProgressBar heapBar;
|
||||||
private GameSettings gameSettings;
|
private GameSettings gameSettings;
|
||||||
|
|
||||||
public SidePanel() {
|
SidePanel() {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
@ -214,7 +214,7 @@ class SidePanel extends JPanel implements ISidePanel {
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollToBottom() {
|
void scrollToBottom() {
|
||||||
scrollToBottom = true;
|
scrollToBottom = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ class SidePanel extends JPanel implements ISidePanel {
|
||||||
JCheckBox showRules;
|
JCheckBox showRules;
|
||||||
JProgressBar heapBar;
|
JProgressBar heapBar;
|
||||||
|
|
||||||
public InfoPanel(JPanel gameInfo, JPanel ruleInfo) {
|
InfoPanel(JPanel gameInfo, JPanel ruleInfo) {
|
||||||
ruleInfoPanel = ruleInfo;
|
ruleInfoPanel = ruleInfo;
|
||||||
gameInfoPanel = gameInfo;
|
gameInfoPanel = gameInfo;
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
@ -321,7 +321,7 @@ class SidePanel extends JPanel implements ISidePanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
class PlayerListItem extends JPanel {
|
class PlayerListItem extends JPanel {
|
||||||
public PlayerListItem(IPlayer player) {
|
PlayerListItem(IPlayer player) {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
setBorder(new EmptyBorder(0, 4, 0, 4));
|
setBorder(new EmptyBorder(0, 4, 0, 4));
|
||||||
PlayerSettings settings = player.getPlayerSettings();
|
PlayerSettings settings = player.getPlayerSettings();
|
||||||
|
@ -402,7 +402,7 @@ class SidePanel extends JPanel implements ISidePanel {
|
||||||
JPanel startSpacer;
|
JPanel startSpacer;
|
||||||
List<PlayerListItem> listItems = new ArrayList<PlayerListItem>();
|
List<PlayerListItem> listItems = new ArrayList<PlayerListItem>();
|
||||||
|
|
||||||
public PlayerListPanel() {
|
PlayerListPanel() {
|
||||||
setBackground(Color.GRAY);
|
setBackground(Color.GRAY);
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ class SidePanel extends JPanel implements ISidePanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayers(List<IPlayer> players) {
|
void setPlayers(List<IPlayer> players) {
|
||||||
for (PlayerListItem item : listItems) {
|
for (PlayerListItem item : listItems) {
|
||||||
remove(item);
|
remove(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,11 +46,11 @@ class StonePainter {
|
||||||
/**
|
/**
|
||||||
* The width of one pixel in the scale of 1.0
|
* The width of one pixel in the scale of 1.0
|
||||||
*/
|
*/
|
||||||
public static final double WIDTH_SCALE = 1 / DEFAULT_WIDTH;
|
static final double WIDTH_SCALE = 1 / DEFAULT_WIDTH;
|
||||||
/**
|
/**
|
||||||
* The height of one pixel in the scale of 1.0
|
* The height of one pixel in the scale of 1.0
|
||||||
*/
|
*/
|
||||||
public static final double HEIGHT_SCALE = ASPECT_RATIO / DEFAULT_WIDTH;
|
static final double HEIGHT_SCALE = ASPECT_RATIO / DEFAULT_WIDTH;
|
||||||
|
|
||||||
private double scale;
|
private double scale;
|
||||||
|
|
||||||
|
@ -63,7 +63,8 @@ class StonePainter {
|
||||||
int g = (int) (color.getGreen() * BRIGHTER_SCALE);
|
int g = (int) (color.getGreen() * BRIGHTER_SCALE);
|
||||||
int b = (int) (color.getBlue() * BRIGHTER_SCALE);
|
int b = (int) (color.getBlue() * BRIGHTER_SCALE);
|
||||||
|
|
||||||
return new Color(r > 255 ? 255 : r, g > 255 ? 255 : g, b > 255 ? 255 : b);
|
return new Color(r > 255 ? 255 : r, g > 255 ? 255 : g, b > 255 ? 255
|
||||||
|
: b);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Color hover(Color color) {
|
private static Color hover(Color color) {
|
||||||
|
@ -71,7 +72,8 @@ class StonePainter {
|
||||||
int g = (int) (color.getGreen() * HOVER_RATIO + 255 * (1 - HOVER_RATIO));
|
int g = (int) (color.getGreen() * HOVER_RATIO + 255 * (1 - HOVER_RATIO));
|
||||||
int b = (int) (color.getBlue() * HOVER_RATIO + 255 * (1 - HOVER_RATIO));
|
int b = (int) (color.getBlue() * HOVER_RATIO + 255 * (1 - HOVER_RATIO));
|
||||||
|
|
||||||
return new Color(r > 255 ? 255 : r, g > 255 ? 255 : g, b > 255 ? 255 : b);
|
return new Color(r > 255 ? 255 : r, g > 255 ? 255 : g, b > 255 ? 255
|
||||||
|
: b);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Color redden(Color color) {
|
private static Color redden(Color color) {
|
||||||
|
@ -79,10 +81,11 @@ class StonePainter {
|
||||||
int g = (int) (color.getGreen() * REDDEN_RATIO + 128 * (1 - REDDEN_RATIO));
|
int g = (int) (color.getGreen() * REDDEN_RATIO + 128 * (1 - REDDEN_RATIO));
|
||||||
int b = (int) (color.getBlue() * REDDEN_RATIO + 128 * (1 - REDDEN_RATIO));
|
int b = (int) (color.getBlue() * REDDEN_RATIO + 128 * (1 - REDDEN_RATIO));
|
||||||
|
|
||||||
return new Color(r > 255 ? 255 : r, g > 255 ? 255 : g, b > 255 ? 255 : b);
|
return new Color(r > 255 ? 255 : r, g > 255 ? 255 : g, b > 255 ? 255
|
||||||
|
: b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Color getColor(StoneColor color) {
|
static Color getColor(StoneColor color) {
|
||||||
switch (color) {
|
switch (color) {
|
||||||
case BLACK:
|
case BLACK:
|
||||||
return new Color(0.0f, 0.0f, 0.0f);
|
return new Color(0.0f, 0.0f, 0.0f);
|
||||||
|
@ -111,7 +114,7 @@ class StonePainter {
|
||||||
* @param scale
|
* @param scale
|
||||||
* the new scale
|
* the new scale
|
||||||
*/
|
*/
|
||||||
public void setScale(double scale) {
|
void setScale(double scale) {
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
|
|
||||||
if (this.scale == 0) {
|
if (this.scale == 0) {
|
||||||
|
@ -128,7 +131,7 @@ class StonePainter {
|
||||||
* y position in screen coordinates
|
* y position in screen coordinates
|
||||||
* @return position in grid coordinates
|
* @return position in grid coordinates
|
||||||
*/
|
*/
|
||||||
public Position calculatePosition(int x, int y) {
|
Position calculatePosition(int x, int y) {
|
||||||
double width = getStoneWidth();
|
double width = getStoneWidth();
|
||||||
double height = getStoneHeight();
|
double height = getStoneHeight();
|
||||||
|
|
||||||
|
@ -138,14 +141,14 @@ class StonePainter {
|
||||||
/**
|
/**
|
||||||
* @return the width of a stone in the current scale in pixels
|
* @return the width of a stone in the current scale in pixels
|
||||||
*/
|
*/
|
||||||
public int getStoneWidth() {
|
int getStoneWidth() {
|
||||||
return Math.max(even(DEFAULT_WIDTH * scale), 1);
|
return Math.max(even(DEFAULT_WIDTH * scale), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the height of a stone in the current scale in pixels
|
* @return the height of a stone in the current scale in pixels
|
||||||
*/
|
*/
|
||||||
public int getStoneHeight() {
|
int getStoneHeight() {
|
||||||
return Math.max((int) (DEFAULT_WIDTH * scale / ASPECT_RATIO), 1);
|
return Math.max((int) (DEFAULT_WIDTH * scale / ASPECT_RATIO), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,8 +222,10 @@ class StonePainter {
|
||||||
hoveredStones.put(state, hoveredStateStones);
|
hoveredStones.put(state, hoveredStateStones);
|
||||||
|
|
||||||
for (StoneColor color : StoneColor.values()) {
|
for (StoneColor color : StoneColor.values()) {
|
||||||
defaultStateStones.put(color, new HashMap<Integer, BufferedImage>());
|
defaultStateStones.put(color,
|
||||||
hoveredStateStones.put(color, new HashMap<Integer, BufferedImage>());
|
new HashMap<Integer, BufferedImage>());
|
||||||
|
hoveredStateStones.put(color,
|
||||||
|
new HashMap<Integer, BufferedImage>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,7 +238,8 @@ class StonePainter {
|
||||||
setScale(scale);
|
setScale(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void paintStoneBackground(Graphics2D g, Rectangle r, Color background) {
|
private void paintStoneBackground(Graphics2D g, Rectangle r,
|
||||||
|
Color background) {
|
||||||
// Paint background
|
// Paint background
|
||||||
g.setColor(background);
|
g.setColor(background);
|
||||||
g.fillRect(r.x, r.y, r.width, r.height);
|
g.fillRect(r.x, r.y, r.width, r.height);
|
||||||
|
@ -334,8 +340,9 @@ class StonePainter {
|
||||||
pos + (fm.getAscent() - fm.getDescent()) / 2 + 1);
|
pos + (fm.getAscent() - fm.getDescent()) / 2 + 1);
|
||||||
}
|
}
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
g.drawString(value, (int) (r.x + r.width / 2 - stringRect.getWidth() / 2),
|
g.drawString(value,
|
||||||
pos + (fm.getAscent() - fm.getDescent()) / 2);
|
(int) (r.x + r.width / 2 - stringRect.getWidth() / 2), pos
|
||||||
|
+ (fm.getAscent() - fm.getDescent()) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void paintCircle(Graphics2D g, Rectangle r, Color background) {
|
private void paintCircle(Graphics2D g, Rectangle r, Color background) {
|
||||||
|
@ -344,11 +351,12 @@ class StonePainter {
|
||||||
|
|
||||||
// Paint circle
|
// Paint circle
|
||||||
g.setColor(background.darker());
|
g.setColor(background.darker());
|
||||||
g.drawArc(r.x + r.width / 2 - size / 2, pos - size / 2, size, size, 50, 170);
|
g.drawArc(r.x + r.width / 2 - size / 2, pos - size / 2, size, size, 50,
|
||||||
|
170);
|
||||||
|
|
||||||
g.setColor(brighter(background));
|
g.setColor(brighter(background));
|
||||||
g.drawArc((int) (r.x + r.width / 2 - size / 2), pos - size / 2, size, size,
|
g.drawArc((int) (r.x + r.width / 2 - size / 2), pos - size / 2, size,
|
||||||
-130, 170);
|
size, -130, 170);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -361,25 +369,25 @@ class StonePainter {
|
||||||
* @param p
|
* @param p
|
||||||
* the position of the stone
|
* the position of the stone
|
||||||
* @param state
|
* @param state
|
||||||
* if the stone is selected the stone will be painted darker, if it
|
* if the stone is selected the stone will be painted darker, if
|
||||||
* is invalid it will be painted in red
|
* it is invalid it will be painted in red
|
||||||
* @param hovered
|
* @param hovered
|
||||||
* if hovered is true the stone will be painted brighter
|
* if hovered is true the stone will be painted brighter
|
||||||
*/
|
*/
|
||||||
public void paintStone(Graphics2D g, Stone stone, Position p,
|
void paintStone(Graphics2D g, Stone stone, Position p, StoneState state,
|
||||||
StoneState state, boolean hovered) {
|
boolean hovered) {
|
||||||
int width = getStoneWidth();
|
int width = getStoneWidth();
|
||||||
int height = getStoneHeight();
|
int height = getStoneHeight();
|
||||||
int x = (int) Math.round(p.getX() * width), y = (int) Math.round(p.getY()
|
int x = (int) Math.round(p.getX() * width), y = (int) Math.round(p
|
||||||
* height);
|
.getY() * height);
|
||||||
|
|
||||||
if (stone.isJoker()) {
|
if (stone.isJoker()) {
|
||||||
g.drawImage(getStoneImage(stone.getColor(), 0, state, hovered), x, y,
|
g.drawImage(getStoneImage(stone.getColor(), 0, state, hovered), x,
|
||||||
null);
|
y, null);
|
||||||
} else {
|
} else {
|
||||||
g.drawImage(
|
g.drawImage(
|
||||||
getStoneImage(stone.getColor(), stone.getValue(), state, hovered), x,
|
getStoneImage(stone.getColor(), stone.getValue(), state,
|
||||||
y, null);
|
hovered), x, y, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -538,6 +538,7 @@ public class View extends JFrame implements IView {
|
||||||
rescale();
|
rescale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showQuitWarningPanel(boolean show) {
|
public void showQuitWarningPanel(boolean show) {
|
||||||
quitWarningFrame.setLocationRelativeTo(this);
|
quitWarningFrame.setLocationRelativeTo(this);
|
||||||
quitWarningFrame.setVisible(show);
|
quitWarningFrame.setVisible(show);
|
||||||
|
|
Reference in a new issue