checkstyle and refactor

This commit is contained in:
jendave
2011-11-01 15:40:07 +00:00
parent 75bdb07ea6
commit 2618c18536
8 changed files with 422 additions and 185 deletions

View File

@@ -22,11 +22,13 @@ import forge.AllZone;
public class FButton extends JButton { public class FButton extends JButton {
/** The img r. */ /** The img r. */
protected Image imgL, imgM, imgR; private Image imgL;
private Image imgM;
private Image imgR;
private int w, h = 0; private int w, h = 0;
private boolean allImagesPresent = false; private boolean allImagesPresent = false;
private FSkin skin; private final FSkin skin;
private AlphaComposite disabledComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25f); private final AlphaComposite disabledComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25f);
/** /**
* Instantiates a new f button. * Instantiates a new f button.
@@ -34,45 +36,48 @@ public class FButton extends JButton {
* @param msg * @param msg
* the msg * the msg
*/ */
public FButton(String msg) { public FButton(final String msg) {
super(msg); super(msg);
this.skin = AllZone.getSkin(); this.skin = AllZone.getSkin();
this.setOpaque(false); this.setOpaque(false);
this.setForeground(skin.txt1a); this.setForeground(this.skin.getTxt1a());
this.setBackground(Color.red); this.setBackground(Color.red);
this.setContentAreaFilled(false); this.setContentAreaFilled(false);
this.setMargin(new Insets(0, 25, 0, 25)); this.setMargin(new Insets(0, 25, 0, 25));
this.setFont(skin.font1.deriveFont(Font.BOLD, 15)); this.setFont(this.skin.getFont1().deriveFont(Font.BOLD, 15));
this.imgL = skin.btnLup.getImage(); this.imgL = this.skin.getBtnLup().getImage();
this.imgM = skin.btnMup.getImage(); this.imgM = this.skin.getBtnMup().getImage();
this.imgR = skin.btnRup.getImage(); this.imgR = this.skin.getBtnRup().getImage();
if (this.imgL != null && this.imgM != null && this.imgR != null) { if ((this.imgL != null) && (this.imgM != null) && (this.imgR != null)) {
allImagesPresent = true; this.allImagesPresent = true;
} }
this.addMouseListener(new java.awt.event.MouseAdapter() { this.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) { @Override
if (isEnabled()) { public void mouseEntered(final java.awt.event.MouseEvent evt) {
imgL = skin.btnLover.getImage(); if (FButton.this.isEnabled()) {
imgM = skin.btnMover.getImage(); FButton.this.imgL = FButton.this.skin.getBtnLover().getImage();
imgR = skin.btnRover.getImage(); FButton.this.imgM = FButton.this.skin.getBtnMover().getImage();
FButton.this.imgR = FButton.this.skin.getBtnRover().getImage();
} }
} }
public void mouseExited(java.awt.event.MouseEvent evt) { @Override
if (isEnabled()) { public void mouseExited(final java.awt.event.MouseEvent evt) {
imgL = skin.btnLup.getImage(); if (FButton.this.isEnabled()) {
imgM = skin.btnMup.getImage(); FButton.this.imgL = FButton.this.skin.getBtnLup().getImage();
imgR = skin.btnRup.getImage(); FButton.this.imgM = FButton.this.skin.getBtnMup().getImage();
FButton.this.imgR = FButton.this.skin.getBtnRup().getImage();
} }
} }
public void mousePressed(java.awt.event.MouseEvent evt) { @Override
if (isEnabled()) { public void mousePressed(final java.awt.event.MouseEvent evt) {
imgL = skin.btnLdown.getImage(); if (FButton.this.isEnabled()) {
imgM = skin.btnMdown.getImage(); FButton.this.imgL = FButton.this.skin.getBtnLdown().getImage();
imgR = skin.btnRdown.getImage(); FButton.this.imgM = FButton.this.skin.getBtnMdown().getImage();
FButton.this.imgR = FButton.this.skin.getBtnRdown().getImage();
} }
} }
}); });
@@ -83,27 +88,28 @@ public class FButton extends JButton {
* *
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics) * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/ */
protected void paintComponent(Graphics g) { @Override
if (!allImagesPresent) { protected void paintComponent(final Graphics g) {
if (!this.allImagesPresent) {
return; return;
} }
Graphics2D g2d = (Graphics2D) g; final Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
if (!isEnabled()) { if (!this.isEnabled()) {
g2d.setComposite(disabledComposite); g2d.setComposite(this.disabledComposite);
} }
w = this.getWidth(); this.w = this.getWidth();
h = this.getHeight(); this.h = this.getHeight();
g2d.drawImage(imgL, 0, 0, h, h, null); g2d.drawImage(this.imgL, 0, 0, this.h, this.h, null);
g2d.drawImage(imgM, h, 0, w - 2 * h, h, null); g2d.drawImage(this.imgM, this.h, 0, this.w - (2 * this.h), this.h, null);
g2d.drawImage(imgR, w - h, 0, h, h, null); g2d.drawImage(this.imgR, this.w - this.h, 0, this.h, this.h, null);
super.paintComponent(g); super.paintComponent(g);
} }

View File

@@ -28,34 +28,38 @@ public class FPanel extends JPanel {
/** /**
* Instantiates a new f panel. * Instantiates a new f panel.
* *
* @param lm the lm * @param lm
* the lm
*/ */
public FPanel(LayoutManager lm) { public FPanel(final LayoutManager lm) {
this(); this();
this.setLayout(lm); this.setLayout(lm);
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics) * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/ */
protected void paintComponent(Graphics g) { @Override
protected void paintComponent(final Graphics g) {
// System.out.print("\nRepainting. "); // System.out.print("\nRepainting. ");
if (this.bgImg != null) { if (this.bgImg != null) {
w = getWidth(); this.w = this.getWidth();
h = getHeight(); this.h = this.getHeight();
iw = this.bgImg.getIconWidth(); this.iw = this.bgImg.getIconWidth();
ih = this.bgImg.getIconHeight(); this.ih = this.bgImg.getIconHeight();
while (x < w) { while (this.x < this.w) {
while (y < h) { while (this.y < this.h) {
g.drawImage(bgImg.getImage(), x, y, null); g.drawImage(this.bgImg.getImage(), this.x, this.y, null);
y += ih; this.y += this.ih;
} }
x += iw; this.x += this.iw;
y = 0; this.y = 0;
} }
x = 0; this.x = 0;
} }
super.paintComponent(g); super.paintComponent(g);
@@ -63,10 +67,11 @@ public class FPanel extends JPanel {
/** /**
* Sets the bG img. * Sets the bG img.
* *
* @param icon the new bG img * @param icon
* the new bG img
*/ */
public void setBGImg(ImageIcon icon) { public void setBGImg(final ImageIcon icon) {
this.bgImg = icon; this.bgImg = icon;
if (this.bgImg != null) { if (this.bgImg != null) {
this.setOpaque(false); this.setOpaque(false);

View File

@@ -22,7 +22,7 @@ import javax.swing.JPanel;
public class FRoundedPanel extends JPanel { public class FRoundedPanel extends JPanel {
/** The corners. */ /** The corners. */
public boolean[] corners = { true, true, true, true }; // NW, SW, SE, NE private boolean[] corners = { true, true, true, true }; // NW, SW, SE, NE
private Color shadowColor = new Color(150, 150, 150, 150); private Color shadowColor = new Color(150, 150, 150, 150);
private Color borderColor = Color.black; private Color borderColor = Color.black;
@@ -52,7 +52,7 @@ public class FRoundedPanel extends JPanel {
* @param lm * @param lm
* the lm * the lm
*/ */
public FRoundedPanel(LayoutManager lm) { public FRoundedPanel(final LayoutManager lm) {
this(); this();
this.setLayout(lm); this.setLayout(lm);
} }
@@ -67,45 +67,46 @@ public class FRoundedPanel extends JPanel {
* @param g * @param g
* the g * the g
*/ */
protected void paintComponent(Graphics g) { @Override
protected void paintComponent(final Graphics g) {
super.paintComponent(g); super.paintComponent(g);
int w = getWidth(); final int w = this.getWidth();
int h = getHeight(); final int h = this.getHeight();
int so = shadowOffset; int so = this.shadowOffset;
int r = cornerRadius; final int r = this.cornerRadius;
Graphics2D g2d = (Graphics2D) g; final Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (showShadow) { if (this.showShadow) {
// Mid, left, right rectangles: shadow // Mid, left, right rectangles: shadow
g2d.setColor(shadowColor); g2d.setColor(this.shadowColor);
g2d.fillRect(r + so, so, w - 2 * r - so, h - so); g2d.fillRect(r + so, so, w - (2 * r) - so, h - so);
g2d.fillRect(so, r + so, r, h - 2 * r - so); g2d.fillRect(so, r + so, r, h - (2 * r) - so);
g2d.fillRect(w - r, r + so, r, h - 2 * r - so); g2d.fillRect(w - r, r + so, r, h - (2 * r) - so);
// Corners: shadow // Corners: shadow
// NW // NW
if (corners[0]) { if (this.corners[0]) {
g2d.fillArc(so, so, 2 * r, 2 * r, 90, 90); g2d.fillArc(so, so, 2 * r, 2 * r, 90, 90);
} else { } else {
g2d.fillRect(so, so, r, r); g2d.fillRect(so, so, r, r);
} }
// SW // SW
if (corners[1]) { if (this.corners[1]) {
g2d.fillArc(so, h - 2 * r, 2 * r, 2 * r, 180, 90); g2d.fillArc(so, h - (2 * r), 2 * r, 2 * r, 180, 90);
} else { } else {
g2d.fillRect(so, h - r, r, r); g2d.fillRect(so, h - r, r, r);
} }
// SE // SE
if (corners[2]) { if (this.corners[2]) {
g2d.fillArc(w - 2 * r, h - 2 * r, 2 * r, 2 * r, 270, 90); g2d.fillArc(w - (2 * r), h - (2 * r), 2 * r, 2 * r, 270, 90);
} else { } else {
g2d.fillRect(w - r, h - r, r, r); g2d.fillRect(w - r, h - r, r, r);
} }
// NE // NE
if (corners[3]) { if (this.corners[3]) {
g2d.fillArc(w - 2 * r, so, 2 * r, 2 * r, 0, 90); g2d.fillArc(w - (2 * r), so, 2 * r, 2 * r, 0, 90);
} else { } else {
g2d.fillRect(w - r, so, r, r); g2d.fillRect(w - r, so, r, r);
} }
@@ -116,33 +117,33 @@ public class FRoundedPanel extends JPanel {
} }
// Mid, left, right rectangles: content // Mid, left, right rectangles: content
g2d.setColor(getBackground()); g2d.setColor(this.getBackground());
g2d.fillRect(r, 0, w - 2 * r - so, h - so); g2d.fillRect(r, 0, w - (2 * r) - so, h - so);
g2d.fillRect(0, r, r, h - 2 * r - so); g2d.fillRect(0, r, r, h - (2 * r) - so);
g2d.fillRect(w - r - so, r, r, h - 2 * r - so); g2d.fillRect(w - r - so, r, r, h - (2 * r) - so);
// Corners: content // Corners: content
// NW // NW
if (corners[0]) { if (this.corners[0]) {
g2d.fillArc(0, 0, 2 * r, 2 * r, 90, 90); g2d.fillArc(0, 0, 2 * r, 2 * r, 90, 90);
} else { } else {
g2d.fillRect(0, 0, r, r); g2d.fillRect(0, 0, r, r);
} }
// SW // SW
if (corners[1]) { if (this.corners[1]) {
g2d.fillArc(0, h - 2 * r - so, 2 * r, 2 * r, 180, 90); g2d.fillArc(0, h - (2 * r) - so, 2 * r, 2 * r, 180, 90);
} else { } else {
g2d.fillRect(0, h - r - so, r, r); g2d.fillRect(0, h - r - so, r, r);
} }
// SE // SE
if (corners[2]) { if (this.corners[2]) {
g2d.fillArc(w - 2 * r - so, h - 2 * r - so, 2 * r, 2 * r, 270, 90); g2d.fillArc(w - (2 * r) - so, h - (2 * r) - so, 2 * r, 2 * r, 270, 90);
} else { } else {
g2d.fillRect(w - r - so, h - r - so, r, r); g2d.fillRect(w - r - so, h - r - so, r, r);
} }
// NE // NE
if (corners[3]) { if (this.corners[3]) {
g2d.fillArc(w - 2 * r - so, 0, 2 * r, 2 * r, 0, 90); g2d.fillArc(w - (2 * r) - so, 0, 2 * r, 2 * r, 0, 90);
} else { } else {
g2d.fillRect(w - r - so, 0, r, r); g2d.fillRect(w - r - so, 0, r, r);
} }
@@ -156,29 +157,29 @@ public class FRoundedPanel extends JPanel {
// Corners: border // Corners: border
// NW // NW
if (corners[0]) { if (this.corners[0]) {
g2d.drawArc(0, 0, 2 * r, 2 * r, 90, 90); g2d.drawArc(0, 0, 2 * r, 2 * r, 90, 90);
} else { } else {
g2d.drawLine(0, 0, r, 0); g2d.drawLine(0, 0, r, 0);
g2d.drawLine(0, 0, 0, r); g2d.drawLine(0, 0, 0, r);
} }
// SW // SW
if (corners[1]) { if (this.corners[1]) {
g2d.drawArc(0, h - 2 * r - so, 2 * r, 2 * r - 1, 180, 90); g2d.drawArc(0, h - (2 * r) - so, 2 * r, (2 * r) - 1, 180, 90);
} else { } else {
g2d.drawLine(0, h - so - 1, 0, h - r - so - 1); g2d.drawLine(0, h - so - 1, 0, h - r - so - 1);
g2d.drawLine(0, h - so - 1, r, h - so - 1); g2d.drawLine(0, h - so - 1, r, h - so - 1);
} }
// SE // SE
if (corners[2]) { if (this.corners[2]) {
g2d.drawArc(w - 2 * r - so, h - 2 * r - so, 2 * r - 1, 2 * r - 1, 270, 90); g2d.drawArc(w - (2 * r) - so, h - (2 * r) - so, (2 * r) - 1, (2 * r) - 1, 270, 90);
} else { } else {
g2d.drawLine(w - so - 1, h - so - 1, w - so - 1, h - r - so); g2d.drawLine(w - so - 1, h - so - 1, w - so - 1, h - r - so);
g2d.drawLine(w - so - 1, h - so - 1, w - r - so, h - so - 1); g2d.drawLine(w - so - 1, h - so - 1, w - r - so, h - so - 1);
} }
// NE // NE
if (corners[3]) { if (this.corners[3]) {
g2d.drawArc(w - 2 * r - so, 0, 2 * r - 1, 2 * r - 1, 0, 90); g2d.drawArc(w - (2 * r) - so, 0, (2 * r) - 1, (2 * r) - 1, 0, 90);
} else { } else {
g2d.drawLine(w - so - 1, 0, w - so - r, 0); g2d.drawLine(w - so - 1, 0, w - so - r, 0);
g2d.drawLine(w - so - 1, 0, w - so - 1, r); g2d.drawLine(w - so - 1, 0, w - so - 1, r);
@@ -194,7 +195,7 @@ public class FRoundedPanel extends JPanel {
* @param c * @param c
* the new shadow color * the new shadow color
*/ */
public void setShadowColor(Color c) { public void setShadowColor(final Color c) {
this.shadowColor = c; this.shadowColor = c;
} }
@@ -207,7 +208,7 @@ public class FRoundedPanel extends JPanel {
* @param c * @param c
* the new border color * the new border color
*/ */
public void setBorderColor(Color c) { public void setBorderColor(final Color c) {
this.borderColor = c; this.borderColor = c;
} }
@@ -254,12 +255,12 @@ public class FRoundedPanel extends JPanel {
* @param vals * @param vals
* the new corners * the new corners
*/ */
public void setCorners(boolean vals[]) { public void setCorners(final boolean[] vals) {
if (vals.length != 4) { if (vals.length != 4) {
throw new IllegalArgumentException("FRoundedPanel > setCorners requires an array of booleans of length 4."); throw new IllegalArgumentException("FRoundedPanel > setCorners requires an array of booleans of length 4.");
} }
corners = vals; this.corners = vals;
} }
/** /**
@@ -268,7 +269,7 @@ public class FRoundedPanel extends JPanel {
* @param b * @param b
* the new show shadow * the new show shadow
*/ */
public void setShowShadow(boolean b) { public void setShowShadow(final boolean b) {
showShadow = b; this.showShadow = b;
} }
} }

View File

@@ -20,88 +20,88 @@ import forge.gui.GuiUtils;
public class FSkin { public class FSkin {
// ===== Public fields // ===== Public fields
/** The font1. */ /** The font1. */
public Font font1 = null; private Font font1 = null;
/** The font2. */ /** The font2. */
public Font font2 = null; private Font font2 = null;
/** The texture1. */ /** The texture1. */
public ImageIcon texture1 = null; private ImageIcon texture1 = null;
/** The texture2. */ /** The texture2. */
public ImageIcon texture2 = null; private ImageIcon texture2 = null;
/** The texture3. */ /** The texture3. */
public ImageIcon texture3 = null; private ImageIcon texture3 = null;
/** The btn lup. */ /** The btn lup. */
public ImageIcon btnLup = null; private ImageIcon btnLup = null;
/** The btn mup. */ /** The btn mup. */
public ImageIcon btnMup = null; private ImageIcon btnMup = null;
/** The btn rup. */ /** The btn rup. */
public ImageIcon btnRup = null; private ImageIcon btnRup = null;
/** The btn lover. */ /** The btn lover. */
public ImageIcon btnLover = null; private ImageIcon btnLover = null;
/** The btn mover. */ /** The btn mover. */
public ImageIcon btnMover = null; private ImageIcon btnMover = null;
/** The btn rover. */ /** The btn rover. */
public ImageIcon btnRover = null; private ImageIcon btnRover = null;
/** The btn ldown. */ /** The btn ldown. */
public ImageIcon btnLdown = null; private ImageIcon btnLdown = null;
/** The btn mdown. */ /** The btn mdown. */
public ImageIcon btnMdown = null; private ImageIcon btnMdown = null;
/** The btn rdown. */ /** The btn rdown. */
public ImageIcon btnRdown = null; private ImageIcon btnRdown = null;
/** The splash. */ /** The splash. */
public ImageIcon splash = null; private ImageIcon splash = null;
/** The bg1a. */ /** The bg1a. */
public Color bg1a = Color.red; private Color bg1a = Color.red;
/** The bg1b. */ /** The bg1b. */
public Color bg1b = Color.red; private Color bg1b = Color.red;
/** The bg2a. */ /** The bg2a. */
public Color bg2a = Color.red; private Color bg2a = Color.red;
/** The bg2b. */ /** The bg2b. */
public Color bg2b = Color.red; private Color bg2b = Color.red;
/** The bg3a. */ /** The bg3a. */
public Color bg3a = Color.red; private Color bg3a = Color.red;
/** The bg3b. */ /** The bg3b. */
public Color bg3b = Color.red; private Color bg3b = Color.red;
/** The txt1a. */ /** The txt1a. */
public Color txt1a = Color.red; private Color txt1a = Color.red;
/** The txt1b. */ /** The txt1b. */
public Color txt1b = Color.red; private Color txt1b = Color.red;
/** The txt2a. */ /** The txt2a. */
public Color txt2a = Color.red; private Color txt2a = Color.red;
/** The txt2b. */ /** The txt2b. */
public Color txt2b = Color.red; private Color txt2b = Color.red;
/** The txt3a. */ /** The txt3a. */
public Color txt3a = Color.red; private Color txt3a = Color.red;
/** The txt3b. */ /** The txt3b. */
public Color txt3b = Color.red; private Color txt3b = Color.red;
/** The name. */ /** The name. */
public String name = "default"; private String name = "default";
// ===== Private fields // ===== Private fields
private final String paletteFile = "palette.jpg"; private final String paletteFile = "palette.jpg";
@@ -124,7 +124,7 @@ public class FSkin {
private ImageIcon tempImg; private ImageIcon tempImg;
private Font tempFont; private Font tempFont;
private String skin; private String skin;
private String notfound = "FSkin.java: \"" + skin + "\" skin can't find "; private final String notfound = "FSkin.java: \"" + this.skin + "\" skin can't find ";
/** /**
* FSkin constructor. No arguments, will generate default skin settings, * FSkin constructor. No arguments, will generate default skin settings,
@@ -146,11 +146,11 @@ public class FSkin {
* @throws Exception * @throws Exception
* the exception * the exception
*/ */
public FSkin(String skinName) throws Exception { public FSkin(final String skinName) throws Exception {
loadFontAndImages("default"); this.loadFontAndImages("default");
if (!skinName.equals("default")) { if (!skinName.equals("default")) {
loadFontAndImages(skinName); this.loadFontAndImages(skinName);
} }
} }
@@ -159,48 +159,48 @@ public class FSkin {
* *
* @param skinName * @param skinName
*/ */
private void loadFontAndImages(String skinName) { private void loadFontAndImages(final String skinName) {
String dirName = "res/images/skins/" + skinName + "/"; final String dirName = "res/images/skins/" + skinName + "/";
// Fonts // Fonts
font1 = retrieveFont(dirName + font1file); this.setFont1(this.retrieveFont(dirName + this.font1file));
font2 = retrieveFont(dirName + font2file); this.setFont2(this.retrieveFont(dirName + this.font2file));
// Images // Images
texture1 = retrieveImage(dirName + texture1file); this.setTexture1(this.retrieveImage(dirName + this.texture1file));
texture2 = retrieveImage(dirName + texture2file); this.texture2 = this.retrieveImage(dirName + this.texture2file);
texture3 = retrieveImage(dirName + texture3file); this.texture3 = this.retrieveImage(dirName + this.texture3file);
btnLup = retrieveImage(dirName + btnLupfile); this.setBtnLup(this.retrieveImage(dirName + this.btnLupfile));
btnMup = retrieveImage(dirName + btnMupfile); this.setBtnMup(this.retrieveImage(dirName + this.btnMupfile));
btnRup = retrieveImage(dirName + btnRupfile); this.setBtnRup(this.retrieveImage(dirName + this.btnRupfile));
btnLover = retrieveImage(dirName + btnLoverfile); this.setBtnLover(this.retrieveImage(dirName + this.btnLoverfile));
btnMover = retrieveImage(dirName + btnMoverfile); this.setBtnMover(this.retrieveImage(dirName + this.btnMoverfile));
btnRover = retrieveImage(dirName + btnRoverfile); this.setBtnRover(this.retrieveImage(dirName + this.btnRoverfile));
btnLdown = retrieveImage(dirName + btnLdownfile); this.setBtnLdown(this.retrieveImage(dirName + this.btnLdownfile));
btnMdown = retrieveImage(dirName + btnMdownfile); this.setBtnMdown(this.retrieveImage(dirName + this.btnMdownfile));
btnRdown = retrieveImage(dirName + btnRdownfile); this.setBtnRdown(this.retrieveImage(dirName + this.btnRdownfile));
splash = retrieveImage(dirName + splashfile); this.setSplash(this.retrieveImage(dirName + this.splashfile));
// Color palette // Color palette
File file = new File(dirName + paletteFile); final File file = new File(dirName + this.paletteFile);
BufferedImage image; BufferedImage image;
try { try {
image = ImageIO.read(file); image = ImageIO.read(file);
bg1a = getColorFromPixel(image.getRGB(10, 30)); this.setBg1a(this.getColorFromPixel(image.getRGB(10, 30)));
bg1b = getColorFromPixel(image.getRGB(30, 30)); this.setBg1b(this.getColorFromPixel(image.getRGB(30, 30)));
bg2a = getColorFromPixel(image.getRGB(50, 30)); this.bg2a = this.getColorFromPixel(image.getRGB(50, 30));
bg2b = getColorFromPixel(image.getRGB(70, 30)); this.bg2b = this.getColorFromPixel(image.getRGB(70, 30));
bg3a = getColorFromPixel(image.getRGB(90, 30)); this.bg3a = this.getColorFromPixel(image.getRGB(90, 30));
bg3b = getColorFromPixel(image.getRGB(110, 30)); this.bg3b = this.getColorFromPixel(image.getRGB(110, 30));
txt1a = getColorFromPixel(image.getRGB(10, 70)); this.setTxt1a(this.getColorFromPixel(image.getRGB(10, 70)));
txt1b = getColorFromPixel(image.getRGB(30, 70)); this.txt1b = this.getColorFromPixel(image.getRGB(30, 70));
txt2a = getColorFromPixel(image.getRGB(50, 70)); this.txt2a = this.getColorFromPixel(image.getRGB(50, 70));
txt2b = getColorFromPixel(image.getRGB(70, 70)); this.txt2b = this.getColorFromPixel(image.getRGB(70, 70));
txt3a = getColorFromPixel(image.getRGB(90, 70)); this.txt3a = this.getColorFromPixel(image.getRGB(90, 70));
txt3b = getColorFromPixel(image.getRGB(110, 70)); this.txt3b = this.getColorFromPixel(image.getRGB(110, 70));
} catch (IOException e) { } catch (final IOException e) {
System.err.println(notfound + paletteFile); System.err.println(this.notfound + this.paletteFile);
} }
} }
@@ -215,13 +215,13 @@ public class FSkin {
* @param {@link java.lang.String} address * @param {@link java.lang.String} address
* @return a ImageIcon * @return a ImageIcon
*/ */
private ImageIcon retrieveImage(String address) { private ImageIcon retrieveImage(final String address) {
tempImg = new ImageIcon(address); this.tempImg = new ImageIcon(address);
if (tempImg.getIconWidth() == -1) { if (this.tempImg.getIconWidth() == -1) {
System.err.println(notfound + address); System.err.println(this.notfound + address);
} }
return tempImg; return this.tempImg;
} }
/** /**
@@ -235,10 +235,10 @@ public class FSkin {
* @param {@link java.lang.String} address * @param {@link java.lang.String} address
* @return a Font * @return a Font
*/ */
private Font retrieveFont(String address) { private Font retrieveFont(final String address) {
tempFont = GuiUtils.newFont(address); this.tempFont = GuiUtils.newFont(address);
return tempFont; return this.tempFont;
} }
/** /**
@@ -248,7 +248,231 @@ public class FSkin {
* *
* @param {@link java.lang.Integer} pixel information * @param {@link java.lang.Integer} pixel information
*/ */
private Color getColorFromPixel(int pixel) { private Color getColorFromPixel(final int pixel) {
return new Color((pixel & 0x00ff0000) >> 16, (pixel & 0x0000ff00) >> 8, (pixel & 0x000000ff)); return new Color((pixel & 0x00ff0000) >> 16, (pixel & 0x0000ff00) >> 8, (pixel & 0x000000ff));
} }
/**
* @return the font1
*/
public Font getFont1() {
return font1;
}
/**
* @param font1 the font1 to set
*/
public void setFont1(Font font1) {
this.font1 = font1; // TODO: Add 0 to parameter's name.
}
/**
* @return the font2
*/
public Font getFont2() {
return font2;
}
/**
* @param font2 the font2 to set
*/
public void setFont2(Font font2) {
this.font2 = font2; // TODO: Add 0 to parameter's name.
}
/**
* @return the bg1a
*/
public Color getBg1a() {
return bg1a;
}
/**
* @param bg1a the bg1a to set
*/
public void setBg1a(Color bg1a) {
this.bg1a = bg1a; // TODO: Add 0 to parameter's name.
}
/**
* @return the splash
*/
public ImageIcon getSplash() {
return splash;
}
/**
* @param splash the splash to set
*/
public void setSplash(ImageIcon splash) {
this.splash = splash; // TODO: Add 0 to parameter's name.
}
/**
* @return the btnRdown
*/
public ImageIcon getBtnRdown() {
return btnRdown;
}
/**
* @param btnRdown the btnRdown to set
*/
public void setBtnRdown(ImageIcon btnRdown) {
this.btnRdown = btnRdown; // TODO: Add 0 to parameter's name.
}
/**
* @return the bg1b
*/
public Color getBg1b() {
return bg1b;
}
/**
* @param bg1b the bg1b to set
*/
public void setBg1b(Color bg1b) {
this.bg1b = bg1b; // TODO: Add 0 to parameter's name.
}
/**
* @return the texture1
*/
public ImageIcon getTexture1() {
return texture1;
}
/**
* @param texture1 the texture1 to set
*/
public void setTexture1(ImageIcon texture1) {
this.texture1 = texture1; // TODO: Add 0 to parameter's name.
}
/**
* @return the txt1a
*/
public Color getTxt1a() {
return txt1a;
}
/**
* @param txt1a the txt1a to set
*/
public void setTxt1a(Color txt1a) {
this.txt1a = txt1a; // TODO: Add 0 to parameter's name.
}
/**
* @return the btnLup
*/
public ImageIcon getBtnLup() {
return btnLup;
}
/**
* @param btnLup the btnLup to set
*/
public void setBtnLup(ImageIcon btnLup) {
this.btnLup = btnLup; // TODO: Add 0 to parameter's name.
}
/**
* @return the btnMup
*/
public ImageIcon getBtnMup() {
return btnMup;
}
/**
* @param btnMup the btnMup to set
*/
public void setBtnMup(ImageIcon btnMup) {
this.btnMup = btnMup; // TODO: Add 0 to parameter's name.
}
/**
* @return the btnLover
*/
public ImageIcon getBtnLover() {
return btnLover;
}
/**
* @param btnLover the btnLover to set
*/
public void setBtnLover(ImageIcon btnLover) {
this.btnLover = btnLover; // TODO: Add 0 to parameter's name.
}
/**
* @return the btnRup
*/
public ImageIcon getBtnRup() {
return btnRup;
}
/**
* @param btnRup the btnRup to set
*/
public void setBtnRup(ImageIcon btnRup) {
this.btnRup = btnRup; // TODO: Add 0 to parameter's name.
}
/**
* @return the btnMover
*/
public ImageIcon getBtnMover() {
return btnMover;
}
/**
* @param btnMover the btnMover to set
*/
public void setBtnMover(ImageIcon btnMover) {
this.btnMover = btnMover; // TODO: Add 0 to parameter's name.
}
/**
* @return the btnRover
*/
public ImageIcon getBtnRover() {
return btnRover;
}
/**
* @param btnRover the btnRover to set
*/
public void setBtnRover(ImageIcon btnRover) {
this.btnRover = btnRover; // TODO: Add 0 to parameter's name.
}
/**
* @return the btnLdown
*/
public ImageIcon getBtnLdown() {
return btnLdown;
}
/**
* @param btnLdown the btnLdown to set
*/
public void setBtnLdown(ImageIcon btnLdown) {
this.btnLdown = btnLdown; // TODO: Add 0 to parameter's name.
}
/**
* @return the btnMdown
*/
public ImageIcon getBtnMdown() {
return btnMdown;
}
/**
* @param btnMdown the btnMdown to set
*/
public void setBtnMdown(ImageIcon btnMdown) {
this.btnMdown = btnMdown; // TODO: Add 0 to parameter's name.
}
} }

View File

@@ -1,2 +1,3 @@
/** Forge Card Game. */ /** Forge Card Game. */
package forge.gui.skin; package forge.gui.skin;

View File

@@ -365,7 +365,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
lblTemp2 = new JLabel(sb.toString()); lblTemp2 = new JLabel(sb.toString());
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER); lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
lblTemp2.setFont(AllZone.getSkin().font2.deriveFont(Font.PLAIN, 14)); lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
lblTemp2.setForeground(Color.white); lblTemp2.setForeground(Color.white);
lblTemp2.setIcon(icoTemp); lblTemp2.setIcon(icoTemp);
lblTemp2.setIconTextGap(50); lblTemp2.setIconTextGap(50);
@@ -467,7 +467,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
lblTemp1 = new TitleLabel("Challenge Rewards for \"" + ((QuestChallenge) model.qEvent).getTitle() + "\""); lblTemp1 = new TitleLabel("Challenge Rewards for \"" + ((QuestChallenge) model.qEvent).getTitle() + "\"");
lblTemp2 = new JLabel(sb.toString()); lblTemp2 = new JLabel(sb.toString());
lblTemp2.setFont(AllZone.getSkin().font2.deriveFont(Font.PLAIN, 14)); lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
lblTemp2.setForeground(Color.white); lblTemp2.setForeground(Color.white);
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER); lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
lblTemp2.setIconTextGap(50); lblTemp2.setIconTextGap(50);
@@ -489,7 +489,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
lblTemp1 = new TitleLabel("Gameplay Results"); lblTemp1 = new TitleLabel("Gameplay Results");
lblTemp2 = new JLabel("You lose! You have lost 15 credits."); lblTemp2 = new JLabel("You lose! You have lost 15 credits.");
lblTemp2.setFont(AllZone.getSkin().font2.deriveFont(Font.PLAIN, 14)); lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
lblTemp2.setForeground(Color.white); lblTemp2.setForeground(Color.white);
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER); lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
lblTemp2.setIconTextGap(50); lblTemp2.setIconTextGap(50);
@@ -578,7 +578,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
private class TitleLabel extends JLabel { private class TitleLabel extends JLabel {
TitleLabel(final String msg) { TitleLabel(final String msg) {
super(msg); super(msg);
this.setFont(AllZone.getSkin().font2.deriveFont(Font.ITALIC, 16)); this.setFont(AllZone.getSkin().getFont2().deriveFont(Font.ITALIC, 16));
this.setPreferredSize(new Dimension(200, 40)); this.setPreferredSize(new Dimension(200, 40));
this.setHorizontalAlignment(SwingConstants.CENTER); this.setHorizontalAlignment(SwingConstants.CENTER);
this.setForeground(Color.white); this.setForeground(Color.white);

View File

@@ -69,7 +69,7 @@ public class SplashFrame extends JFrame {
setUndecorated(true); setUndecorated(true);
// Set preferred JFrame properties. // Set preferred JFrame properties.
final ImageIcon bgIcon = skin.splash; final ImageIcon bgIcon = skin.getSplash();
final int splashWidthPx = bgIcon.getIconWidth(); final int splashWidthPx = bgIcon.getIconWidth();
final int splashHeightPx = bgIcon.getIconHeight(); final int splashHeightPx = bgIcon.getIconHeight();
@@ -127,8 +127,8 @@ public class SplashFrame extends JFrame {
contentPane.getActionMap().put("escAction", new closeAction()); contentPane.getActionMap().put("escAction", new closeAction());
// Set UI to color splash bar fill with theme colors // Set UI to color splash bar fill with theme colors
UIManager.put("ProgressBar.foreground", skin.bg1b); // Filled UIManager.put("ProgressBar.foreground", skin.getBg1b()); // Filled
UIManager.put("ProgressBar.selectionForeground", skin.txt1a); // Filled UIManager.put("ProgressBar.selectionForeground", skin.getTxt1a()); // Filled
// Instantiate model and view and tie together. // Instantiate model and view and tie together.
monitorModel = new SplashProgressModel(); monitorModel = new SplashProgressModel();

View File

@@ -88,7 +88,7 @@ public class WinLoseFrame extends JFrame {
// Place all content in FPanel // Place all content in FPanel
FPanel contentPanel = new FPanel(new MigLayout("wrap, fill, insets 20 0 10 10")); FPanel contentPanel = new FPanel(new MigLayout("wrap, fill, insets 20 0 10 10"));
contentPanel.setBGImg(AllZone.getSkin().texture1); contentPanel.setBGImg(AllZone.getSkin().getTexture1());
contentPanel.setBorder(new WinLoseBorder()); contentPanel.setBorder(new WinLoseBorder());
getContentPane().add(contentPanel); getContentPane().add(contentPanel);
@@ -107,12 +107,12 @@ public class WinLoseFrame extends JFrame {
lblTitle = new JLabel("WinLoseFrame > lblTitle is broken."); lblTitle = new JLabel("WinLoseFrame > lblTitle is broken.");
lblTitle.setForeground(Color.white); lblTitle.setForeground(Color.white);
lblTitle.setHorizontalAlignment(SwingConstants.CENTER); lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
lblTitle.setFont(AllZone.getSkin().font1.deriveFont(Font.PLAIN, 26)); lblTitle.setFont(AllZone.getSkin().getFont1().deriveFont(Font.PLAIN, 26));
lblStats = new JLabel("WinLoseFrame > lblStats is broken."); lblStats = new JLabel("WinLoseFrame > lblStats is broken.");
lblStats.setForeground(Color.white); lblStats.setForeground(Color.white);
lblStats.setHorizontalAlignment(SwingConstants.CENTER); lblStats.setHorizontalAlignment(SwingConstants.CENTER);
lblStats.setFont(AllZone.getSkin().font1.deriveFont(Font.PLAIN, 26)); lblStats.setFont(AllZone.getSkin().getFont1().deriveFont(Font.PLAIN, 26));
pnlHead.add(lblTitle, "growx"); pnlHead.add(lblTitle, "growx");
pnlHead.add(lblStats, "growx"); pnlHead.add(lblStats, "growx");
@@ -204,7 +204,7 @@ public class WinLoseFrame extends JFrame {
bounds.y = (screen.height - bounds.height) / 2; bounds.y = (screen.height - bounds.height) / 2;
} }
this.setBackground(AllZone.getSkin().bg1a); this.setBackground(AllZone.getSkin().getBg1a());
this.setBounds(bounds); this.setBounds(bounds);
this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setUndecorated(true); this.setUndecorated(true);
@@ -279,9 +279,9 @@ public class WinLoseFrame extends JFrame {
private class WinLoseBorder extends AbstractBorder { private class WinLoseBorder extends AbstractBorder {
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width,
final int height) { final int height) {
g.setColor(AllZone.getSkin().txt1a); g.setColor(AllZone.getSkin().getTxt1a());
g.drawRect(x + 1, y + 1, width - 3, height - 3); g.drawRect(x + 1, y + 1, width - 3, height - 3);
g.setColor(AllZone.getSkin().bg1a); g.setColor(AllZone.getSkin().getBg1a());
g.drawRect(x + 3, y + 3, width - 7, height - 7); g.drawRect(x + 3, y + 3, width - 7, height - 7);
} }
} }