mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
checkstyle and refactor
This commit is contained in:
@@ -22,11 +22,13 @@ import forge.AllZone;
|
||||
public class FButton extends JButton {
|
||||
|
||||
/** The img r. */
|
||||
protected Image imgL, imgM, imgR;
|
||||
private Image imgL;
|
||||
private Image imgM;
|
||||
private Image imgR;
|
||||
private int w, h = 0;
|
||||
private boolean allImagesPresent = false;
|
||||
private FSkin skin;
|
||||
private AlphaComposite disabledComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25f);
|
||||
private final FSkin skin;
|
||||
private final AlphaComposite disabledComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25f);
|
||||
|
||||
/**
|
||||
* Instantiates a new f button.
|
||||
@@ -34,45 +36,48 @@ public class FButton extends JButton {
|
||||
* @param msg
|
||||
* the msg
|
||||
*/
|
||||
public FButton(String msg) {
|
||||
public FButton(final String msg) {
|
||||
super(msg);
|
||||
this.skin = AllZone.getSkin();
|
||||
this.setOpaque(false);
|
||||
this.setForeground(skin.txt1a);
|
||||
this.setForeground(this.skin.getTxt1a());
|
||||
this.setBackground(Color.red);
|
||||
this.setContentAreaFilled(false);
|
||||
this.setMargin(new Insets(0, 25, 0, 25));
|
||||
this.setFont(skin.font1.deriveFont(Font.BOLD, 15));
|
||||
this.imgL = skin.btnLup.getImage();
|
||||
this.imgM = skin.btnMup.getImage();
|
||||
this.imgR = skin.btnRup.getImage();
|
||||
this.setFont(this.skin.getFont1().deriveFont(Font.BOLD, 15));
|
||||
this.imgL = this.skin.getBtnLup().getImage();
|
||||
this.imgM = this.skin.getBtnMup().getImage();
|
||||
this.imgR = this.skin.getBtnRup().getImage();
|
||||
|
||||
if (this.imgL != null && this.imgM != null && this.imgR != null) {
|
||||
allImagesPresent = true;
|
||||
if ((this.imgL != null) && (this.imgM != null) && (this.imgR != null)) {
|
||||
this.allImagesPresent = true;
|
||||
}
|
||||
|
||||
this.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseEntered(java.awt.event.MouseEvent evt) {
|
||||
if (isEnabled()) {
|
||||
imgL = skin.btnLover.getImage();
|
||||
imgM = skin.btnMover.getImage();
|
||||
imgR = skin.btnRover.getImage();
|
||||
@Override
|
||||
public void mouseEntered(final java.awt.event.MouseEvent evt) {
|
||||
if (FButton.this.isEnabled()) {
|
||||
FButton.this.imgL = FButton.this.skin.getBtnLover().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) {
|
||||
if (isEnabled()) {
|
||||
imgL = skin.btnLup.getImage();
|
||||
imgM = skin.btnMup.getImage();
|
||||
imgR = skin.btnRup.getImage();
|
||||
@Override
|
||||
public void mouseExited(final java.awt.event.MouseEvent evt) {
|
||||
if (FButton.this.isEnabled()) {
|
||||
FButton.this.imgL = FButton.this.skin.getBtnLup().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) {
|
||||
if (isEnabled()) {
|
||||
imgL = skin.btnLdown.getImage();
|
||||
imgM = skin.btnMdown.getImage();
|
||||
imgR = skin.btnRdown.getImage();
|
||||
@Override
|
||||
public void mousePressed(final java.awt.event.MouseEvent evt) {
|
||||
if (FButton.this.isEnabled()) {
|
||||
FButton.this.imgL = FButton.this.skin.getBtnLdown().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)
|
||||
*/
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (!allImagesPresent) {
|
||||
@Override
|
||||
protected void paintComponent(final Graphics g) {
|
||||
if (!this.allImagesPresent) {
|
||||
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_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
|
||||
if (!isEnabled()) {
|
||||
g2d.setComposite(disabledComposite);
|
||||
if (!this.isEnabled()) {
|
||||
g2d.setComposite(this.disabledComposite);
|
||||
}
|
||||
|
||||
w = this.getWidth();
|
||||
h = this.getHeight();
|
||||
this.w = this.getWidth();
|
||||
this.h = this.getHeight();
|
||||
|
||||
g2d.drawImage(imgL, 0, 0, h, h, null);
|
||||
g2d.drawImage(imgM, h, 0, w - 2 * h, h, null);
|
||||
g2d.drawImage(imgR, w - h, 0, h, h, null);
|
||||
g2d.drawImage(this.imgL, 0, 0, this.h, this.h, null);
|
||||
g2d.drawImage(this.imgM, this.h, 0, this.w - (2 * this.h), this.h, null);
|
||||
g2d.drawImage(this.imgR, this.w - this.h, 0, this.h, this.h, null);
|
||||
|
||||
super.paintComponent(g);
|
||||
}
|
||||
|
||||
@@ -29,33 +29,37 @@ public class FPanel extends JPanel {
|
||||
/**
|
||||
* Instantiates a new f panel.
|
||||
*
|
||||
* @param lm the lm
|
||||
* @param lm
|
||||
* the lm
|
||||
*/
|
||||
public FPanel(LayoutManager lm) {
|
||||
public FPanel(final LayoutManager lm) {
|
||||
this();
|
||||
this.setLayout(lm);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
|
||||
*/
|
||||
protected void paintComponent(Graphics g) {
|
||||
@Override
|
||||
protected void paintComponent(final Graphics g) {
|
||||
// System.out.print("\nRepainting. ");
|
||||
if (this.bgImg != null) {
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
iw = this.bgImg.getIconWidth();
|
||||
ih = this.bgImg.getIconHeight();
|
||||
this.w = this.getWidth();
|
||||
this.h = this.getHeight();
|
||||
this.iw = this.bgImg.getIconWidth();
|
||||
this.ih = this.bgImg.getIconHeight();
|
||||
|
||||
while (x < w) {
|
||||
while (y < h) {
|
||||
g.drawImage(bgImg.getImage(), x, y, null);
|
||||
y += ih;
|
||||
while (this.x < this.w) {
|
||||
while (this.y < this.h) {
|
||||
g.drawImage(this.bgImg.getImage(), this.x, this.y, null);
|
||||
this.y += this.ih;
|
||||
}
|
||||
x += iw;
|
||||
y = 0;
|
||||
this.x += this.iw;
|
||||
this.y = 0;
|
||||
}
|
||||
x = 0;
|
||||
this.x = 0;
|
||||
}
|
||||
|
||||
super.paintComponent(g);
|
||||
@@ -64,9 +68,10 @@ public class FPanel extends JPanel {
|
||||
/**
|
||||
* 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;
|
||||
if (this.bgImg != null) {
|
||||
this.setOpaque(false);
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.swing.JPanel;
|
||||
public class FRoundedPanel extends JPanel {
|
||||
|
||||
/** 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 borderColor = Color.black;
|
||||
@@ -52,7 +52,7 @@ public class FRoundedPanel extends JPanel {
|
||||
* @param lm
|
||||
* the lm
|
||||
*/
|
||||
public FRoundedPanel(LayoutManager lm) {
|
||||
public FRoundedPanel(final LayoutManager lm) {
|
||||
this();
|
||||
this.setLayout(lm);
|
||||
}
|
||||
@@ -67,45 +67,46 @@ public class FRoundedPanel extends JPanel {
|
||||
* @param g
|
||||
* the g
|
||||
*/
|
||||
protected void paintComponent(Graphics g) {
|
||||
@Override
|
||||
protected void paintComponent(final Graphics g) {
|
||||
super.paintComponent(g);
|
||||
int w = getWidth();
|
||||
int h = getHeight();
|
||||
int so = shadowOffset;
|
||||
int r = cornerRadius;
|
||||
final int w = this.getWidth();
|
||||
final int h = this.getHeight();
|
||||
int so = this.shadowOffset;
|
||||
final int r = this.cornerRadius;
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
final Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
if (showShadow) {
|
||||
if (this.showShadow) {
|
||||
// Mid, left, right rectangles: shadow
|
||||
g2d.setColor(shadowColor);
|
||||
g2d.fillRect(r + so, so, w - 2 * r - so, h - so);
|
||||
g2d.fillRect(so, r + so, r, h - 2 * r - so);
|
||||
g2d.fillRect(w - r, r + so, r, h - 2 * r - so);
|
||||
g2d.setColor(this.shadowColor);
|
||||
g2d.fillRect(r + so, so, w - (2 * r) - so, h - so);
|
||||
g2d.fillRect(so, r + so, r, h - (2 * r) - so);
|
||||
g2d.fillRect(w - r, r + so, r, h - (2 * r) - so);
|
||||
|
||||
// Corners: shadow
|
||||
// NW
|
||||
if (corners[0]) {
|
||||
if (this.corners[0]) {
|
||||
g2d.fillArc(so, so, 2 * r, 2 * r, 90, 90);
|
||||
} else {
|
||||
g2d.fillRect(so, so, r, r);
|
||||
}
|
||||
// SW
|
||||
if (corners[1]) {
|
||||
g2d.fillArc(so, h - 2 * r, 2 * r, 2 * r, 180, 90);
|
||||
if (this.corners[1]) {
|
||||
g2d.fillArc(so, h - (2 * r), 2 * r, 2 * r, 180, 90);
|
||||
} else {
|
||||
g2d.fillRect(so, h - r, r, r);
|
||||
}
|
||||
// SE
|
||||
if (corners[2]) {
|
||||
g2d.fillArc(w - 2 * r, h - 2 * r, 2 * r, 2 * r, 270, 90);
|
||||
if (this.corners[2]) {
|
||||
g2d.fillArc(w - (2 * r), h - (2 * r), 2 * r, 2 * r, 270, 90);
|
||||
} else {
|
||||
g2d.fillRect(w - r, h - r, r, r);
|
||||
}
|
||||
// NE
|
||||
if (corners[3]) {
|
||||
g2d.fillArc(w - 2 * r, so, 2 * r, 2 * r, 0, 90);
|
||||
if (this.corners[3]) {
|
||||
g2d.fillArc(w - (2 * r), so, 2 * r, 2 * r, 0, 90);
|
||||
} else {
|
||||
g2d.fillRect(w - r, so, r, r);
|
||||
}
|
||||
@@ -116,33 +117,33 @@ public class FRoundedPanel extends JPanel {
|
||||
}
|
||||
|
||||
// Mid, left, right rectangles: content
|
||||
g2d.setColor(getBackground());
|
||||
g2d.fillRect(r, 0, w - 2 * r - so, h - so);
|
||||
g2d.fillRect(0, r, r, h - 2 * r - so);
|
||||
g2d.fillRect(w - r - so, r, r, h - 2 * r - so);
|
||||
g2d.setColor(this.getBackground());
|
||||
g2d.fillRect(r, 0, w - (2 * r) - so, h - so);
|
||||
g2d.fillRect(0, r, r, h - (2 * r) - so);
|
||||
g2d.fillRect(w - r - so, r, r, h - (2 * r) - so);
|
||||
|
||||
// Corners: content
|
||||
// NW
|
||||
if (corners[0]) {
|
||||
if (this.corners[0]) {
|
||||
g2d.fillArc(0, 0, 2 * r, 2 * r, 90, 90);
|
||||
} else {
|
||||
g2d.fillRect(0, 0, r, r);
|
||||
}
|
||||
// SW
|
||||
if (corners[1]) {
|
||||
g2d.fillArc(0, h - 2 * r - so, 2 * r, 2 * r, 180, 90);
|
||||
if (this.corners[1]) {
|
||||
g2d.fillArc(0, h - (2 * r) - so, 2 * r, 2 * r, 180, 90);
|
||||
} else {
|
||||
g2d.fillRect(0, h - r - so, r, r);
|
||||
}
|
||||
// SE
|
||||
if (corners[2]) {
|
||||
g2d.fillArc(w - 2 * r - so, h - 2 * r - so, 2 * r, 2 * r, 270, 90);
|
||||
if (this.corners[2]) {
|
||||
g2d.fillArc(w - (2 * r) - so, h - (2 * r) - so, 2 * r, 2 * r, 270, 90);
|
||||
} else {
|
||||
g2d.fillRect(w - r - so, h - r - so, r, r);
|
||||
}
|
||||
// NE
|
||||
if (corners[3]) {
|
||||
g2d.fillArc(w - 2 * r - so, 0, 2 * r, 2 * r, 0, 90);
|
||||
if (this.corners[3]) {
|
||||
g2d.fillArc(w - (2 * r) - so, 0, 2 * r, 2 * r, 0, 90);
|
||||
} else {
|
||||
g2d.fillRect(w - r - so, 0, r, r);
|
||||
}
|
||||
@@ -156,29 +157,29 @@ public class FRoundedPanel extends JPanel {
|
||||
|
||||
// Corners: border
|
||||
// NW
|
||||
if (corners[0]) {
|
||||
if (this.corners[0]) {
|
||||
g2d.drawArc(0, 0, 2 * r, 2 * r, 90, 90);
|
||||
} else {
|
||||
g2d.drawLine(0, 0, r, 0);
|
||||
g2d.drawLine(0, 0, 0, r);
|
||||
}
|
||||
// SW
|
||||
if (corners[1]) {
|
||||
g2d.drawArc(0, h - 2 * r - so, 2 * r, 2 * r - 1, 180, 90);
|
||||
if (this.corners[1]) {
|
||||
g2d.drawArc(0, h - (2 * r) - so, 2 * r, (2 * r) - 1, 180, 90);
|
||||
} else {
|
||||
g2d.drawLine(0, h - so - 1, 0, h - r - so - 1);
|
||||
g2d.drawLine(0, h - so - 1, r, h - so - 1);
|
||||
}
|
||||
// SE
|
||||
if (corners[2]) {
|
||||
g2d.drawArc(w - 2 * r - so, h - 2 * r - so, 2 * r - 1, 2 * r - 1, 270, 90);
|
||||
if (this.corners[2]) {
|
||||
g2d.drawArc(w - (2 * r) - so, h - (2 * r) - so, (2 * r) - 1, (2 * r) - 1, 270, 90);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
// NE
|
||||
if (corners[3]) {
|
||||
g2d.drawArc(w - 2 * r - so, 0, 2 * r - 1, 2 * r - 1, 0, 90);
|
||||
if (this.corners[3]) {
|
||||
g2d.drawArc(w - (2 * r) - so, 0, (2 * r) - 1, (2 * r) - 1, 0, 90);
|
||||
} else {
|
||||
g2d.drawLine(w - so - 1, 0, w - so - r, 0);
|
||||
g2d.drawLine(w - so - 1, 0, w - so - 1, r);
|
||||
@@ -194,7 +195,7 @@ public class FRoundedPanel extends JPanel {
|
||||
* @param c
|
||||
* the new shadow color
|
||||
*/
|
||||
public void setShadowColor(Color c) {
|
||||
public void setShadowColor(final Color c) {
|
||||
this.shadowColor = c;
|
||||
}
|
||||
|
||||
@@ -207,7 +208,7 @@ public class FRoundedPanel extends JPanel {
|
||||
* @param c
|
||||
* the new border color
|
||||
*/
|
||||
public void setBorderColor(Color c) {
|
||||
public void setBorderColor(final Color c) {
|
||||
this.borderColor = c;
|
||||
}
|
||||
|
||||
@@ -254,12 +255,12 @@ public class FRoundedPanel extends JPanel {
|
||||
* @param vals
|
||||
* the new corners
|
||||
*/
|
||||
public void setCorners(boolean vals[]) {
|
||||
public void setCorners(final boolean[] vals) {
|
||||
if (vals.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
|
||||
* the new show shadow
|
||||
*/
|
||||
public void setShowShadow(boolean b) {
|
||||
showShadow = b;
|
||||
public void setShowShadow(final boolean b) {
|
||||
this.showShadow = b;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,88 +20,88 @@ import forge.gui.GuiUtils;
|
||||
public class FSkin {
|
||||
// ===== Public fields
|
||||
/** The font1. */
|
||||
public Font font1 = null;
|
||||
private Font font1 = null;
|
||||
|
||||
/** The font2. */
|
||||
public Font font2 = null;
|
||||
private Font font2 = null;
|
||||
|
||||
/** The texture1. */
|
||||
public ImageIcon texture1 = null;
|
||||
private ImageIcon texture1 = null;
|
||||
|
||||
/** The texture2. */
|
||||
public ImageIcon texture2 = null;
|
||||
private ImageIcon texture2 = null;
|
||||
|
||||
/** The texture3. */
|
||||
public ImageIcon texture3 = null;
|
||||
private ImageIcon texture3 = null;
|
||||
|
||||
/** The btn lup. */
|
||||
public ImageIcon btnLup = null;
|
||||
private ImageIcon btnLup = null;
|
||||
|
||||
/** The btn mup. */
|
||||
public ImageIcon btnMup = null;
|
||||
private ImageIcon btnMup = null;
|
||||
|
||||
/** The btn rup. */
|
||||
public ImageIcon btnRup = null;
|
||||
private ImageIcon btnRup = null;
|
||||
|
||||
/** The btn lover. */
|
||||
public ImageIcon btnLover = null;
|
||||
private ImageIcon btnLover = null;
|
||||
|
||||
/** The btn mover. */
|
||||
public ImageIcon btnMover = null;
|
||||
private ImageIcon btnMover = null;
|
||||
|
||||
/** The btn rover. */
|
||||
public ImageIcon btnRover = null;
|
||||
private ImageIcon btnRover = null;
|
||||
|
||||
/** The btn ldown. */
|
||||
public ImageIcon btnLdown = null;
|
||||
private ImageIcon btnLdown = null;
|
||||
|
||||
/** The btn mdown. */
|
||||
public ImageIcon btnMdown = null;
|
||||
private ImageIcon btnMdown = null;
|
||||
|
||||
/** The btn rdown. */
|
||||
public ImageIcon btnRdown = null;
|
||||
private ImageIcon btnRdown = null;
|
||||
|
||||
/** The splash. */
|
||||
public ImageIcon splash = null;
|
||||
private ImageIcon splash = null;
|
||||
|
||||
/** The bg1a. */
|
||||
public Color bg1a = Color.red;
|
||||
private Color bg1a = Color.red;
|
||||
|
||||
/** The bg1b. */
|
||||
public Color bg1b = Color.red;
|
||||
private Color bg1b = Color.red;
|
||||
|
||||
/** The bg2a. */
|
||||
public Color bg2a = Color.red;
|
||||
private Color bg2a = Color.red;
|
||||
|
||||
/** The bg2b. */
|
||||
public Color bg2b = Color.red;
|
||||
private Color bg2b = Color.red;
|
||||
|
||||
/** The bg3a. */
|
||||
public Color bg3a = Color.red;
|
||||
private Color bg3a = Color.red;
|
||||
|
||||
/** The bg3b. */
|
||||
public Color bg3b = Color.red;
|
||||
private Color bg3b = Color.red;
|
||||
|
||||
/** The txt1a. */
|
||||
public Color txt1a = Color.red;
|
||||
private Color txt1a = Color.red;
|
||||
|
||||
/** The txt1b. */
|
||||
public Color txt1b = Color.red;
|
||||
private Color txt1b = Color.red;
|
||||
|
||||
/** The txt2a. */
|
||||
public Color txt2a = Color.red;
|
||||
private Color txt2a = Color.red;
|
||||
|
||||
/** The txt2b. */
|
||||
public Color txt2b = Color.red;
|
||||
private Color txt2b = Color.red;
|
||||
|
||||
/** The txt3a. */
|
||||
public Color txt3a = Color.red;
|
||||
private Color txt3a = Color.red;
|
||||
|
||||
/** The txt3b. */
|
||||
public Color txt3b = Color.red;
|
||||
private Color txt3b = Color.red;
|
||||
|
||||
/** The name. */
|
||||
public String name = "default";
|
||||
private String name = "default";
|
||||
|
||||
// ===== Private fields
|
||||
private final String paletteFile = "palette.jpg";
|
||||
@@ -124,7 +124,7 @@ public class FSkin {
|
||||
private ImageIcon tempImg;
|
||||
private Font tempFont;
|
||||
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,
|
||||
@@ -146,11 +146,11 @@ public class FSkin {
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
public FSkin(String skinName) throws Exception {
|
||||
loadFontAndImages("default");
|
||||
public FSkin(final String skinName) throws Exception {
|
||||
this.loadFontAndImages("default");
|
||||
|
||||
if (!skinName.equals("default")) {
|
||||
loadFontAndImages(skinName);
|
||||
this.loadFontAndImages(skinName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,48 +159,48 @@ public class FSkin {
|
||||
*
|
||||
* @param skinName
|
||||
*/
|
||||
private void loadFontAndImages(String skinName) {
|
||||
String dirName = "res/images/skins/" + skinName + "/";
|
||||
private void loadFontAndImages(final String skinName) {
|
||||
final String dirName = "res/images/skins/" + skinName + "/";
|
||||
|
||||
// Fonts
|
||||
font1 = retrieveFont(dirName + font1file);
|
||||
font2 = retrieveFont(dirName + font2file);
|
||||
this.setFont1(this.retrieveFont(dirName + this.font1file));
|
||||
this.setFont2(this.retrieveFont(dirName + this.font2file));
|
||||
|
||||
// Images
|
||||
texture1 = retrieveImage(dirName + texture1file);
|
||||
texture2 = retrieveImage(dirName + texture2file);
|
||||
texture3 = retrieveImage(dirName + texture3file);
|
||||
btnLup = retrieveImage(dirName + btnLupfile);
|
||||
btnMup = retrieveImage(dirName + btnMupfile);
|
||||
btnRup = retrieveImage(dirName + btnRupfile);
|
||||
btnLover = retrieveImage(dirName + btnLoverfile);
|
||||
btnMover = retrieveImage(dirName + btnMoverfile);
|
||||
btnRover = retrieveImage(dirName + btnRoverfile);
|
||||
btnLdown = retrieveImage(dirName + btnLdownfile);
|
||||
btnMdown = retrieveImage(dirName + btnMdownfile);
|
||||
btnRdown = retrieveImage(dirName + btnRdownfile);
|
||||
splash = retrieveImage(dirName + splashfile);
|
||||
this.setTexture1(this.retrieveImage(dirName + this.texture1file));
|
||||
this.texture2 = this.retrieveImage(dirName + this.texture2file);
|
||||
this.texture3 = this.retrieveImage(dirName + this.texture3file);
|
||||
this.setBtnLup(this.retrieveImage(dirName + this.btnLupfile));
|
||||
this.setBtnMup(this.retrieveImage(dirName + this.btnMupfile));
|
||||
this.setBtnRup(this.retrieveImage(dirName + this.btnRupfile));
|
||||
this.setBtnLover(this.retrieveImage(dirName + this.btnLoverfile));
|
||||
this.setBtnMover(this.retrieveImage(dirName + this.btnMoverfile));
|
||||
this.setBtnRover(this.retrieveImage(dirName + this.btnRoverfile));
|
||||
this.setBtnLdown(this.retrieveImage(dirName + this.btnLdownfile));
|
||||
this.setBtnMdown(this.retrieveImage(dirName + this.btnMdownfile));
|
||||
this.setBtnRdown(this.retrieveImage(dirName + this.btnRdownfile));
|
||||
this.setSplash(this.retrieveImage(dirName + this.splashfile));
|
||||
|
||||
// Color palette
|
||||
File file = new File(dirName + paletteFile);
|
||||
final File file = new File(dirName + this.paletteFile);
|
||||
BufferedImage image;
|
||||
try {
|
||||
image = ImageIO.read(file);
|
||||
bg1a = getColorFromPixel(image.getRGB(10, 30));
|
||||
bg1b = getColorFromPixel(image.getRGB(30, 30));
|
||||
bg2a = getColorFromPixel(image.getRGB(50, 30));
|
||||
bg2b = getColorFromPixel(image.getRGB(70, 30));
|
||||
bg3a = getColorFromPixel(image.getRGB(90, 30));
|
||||
bg3b = getColorFromPixel(image.getRGB(110, 30));
|
||||
this.setBg1a(this.getColorFromPixel(image.getRGB(10, 30)));
|
||||
this.setBg1b(this.getColorFromPixel(image.getRGB(30, 30)));
|
||||
this.bg2a = this.getColorFromPixel(image.getRGB(50, 30));
|
||||
this.bg2b = this.getColorFromPixel(image.getRGB(70, 30));
|
||||
this.bg3a = this.getColorFromPixel(image.getRGB(90, 30));
|
||||
this.bg3b = this.getColorFromPixel(image.getRGB(110, 30));
|
||||
|
||||
txt1a = getColorFromPixel(image.getRGB(10, 70));
|
||||
txt1b = getColorFromPixel(image.getRGB(30, 70));
|
||||
txt2a = getColorFromPixel(image.getRGB(50, 70));
|
||||
txt2b = getColorFromPixel(image.getRGB(70, 70));
|
||||
txt3a = getColorFromPixel(image.getRGB(90, 70));
|
||||
txt3b = getColorFromPixel(image.getRGB(110, 70));
|
||||
} catch (IOException e) {
|
||||
System.err.println(notfound + paletteFile);
|
||||
this.setTxt1a(this.getColorFromPixel(image.getRGB(10, 70)));
|
||||
this.txt1b = this.getColorFromPixel(image.getRGB(30, 70));
|
||||
this.txt2a = this.getColorFromPixel(image.getRGB(50, 70));
|
||||
this.txt2b = this.getColorFromPixel(image.getRGB(70, 70));
|
||||
this.txt3a = this.getColorFromPixel(image.getRGB(90, 70));
|
||||
this.txt3b = this.getColorFromPixel(image.getRGB(110, 70));
|
||||
} catch (final IOException e) {
|
||||
System.err.println(this.notfound + this.paletteFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -215,13 +215,13 @@ public class FSkin {
|
||||
* @param {@link java.lang.String} address
|
||||
* @return a ImageIcon
|
||||
*/
|
||||
private ImageIcon retrieveImage(String address) {
|
||||
tempImg = new ImageIcon(address);
|
||||
if (tempImg.getIconWidth() == -1) {
|
||||
System.err.println(notfound + address);
|
||||
private ImageIcon retrieveImage(final String address) {
|
||||
this.tempImg = new ImageIcon(address);
|
||||
if (this.tempImg.getIconWidth() == -1) {
|
||||
System.err.println(this.notfound + address);
|
||||
}
|
||||
|
||||
return tempImg;
|
||||
return this.tempImg;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,10 +235,10 @@ public class FSkin {
|
||||
* @param {@link java.lang.String} address
|
||||
* @return a Font
|
||||
*/
|
||||
private Font retrieveFont(String address) {
|
||||
tempFont = GuiUtils.newFont(address);
|
||||
private Font retrieveFont(final String 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
|
||||
*/
|
||||
private Color getColorFromPixel(int pixel) {
|
||||
private Color getColorFromPixel(final int pixel) {
|
||||
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.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
/** Forge Card Game. */
|
||||
package forge.gui.skin;
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
|
||||
lblTemp2 = new JLabel(sb.toString());
|
||||
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.setIcon(icoTemp);
|
||||
lblTemp2.setIconTextGap(50);
|
||||
@@ -467,7 +467,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
lblTemp1 = new TitleLabel("Challenge Rewards for \"" + ((QuestChallenge) model.qEvent).getTitle() + "\"");
|
||||
|
||||
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.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblTemp2.setIconTextGap(50);
|
||||
@@ -489,7 +489,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
lblTemp1 = new TitleLabel("Gameplay Results");
|
||||
|
||||
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.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblTemp2.setIconTextGap(50);
|
||||
@@ -578,7 +578,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
private class TitleLabel extends JLabel {
|
||||
TitleLabel(final String 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.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
this.setForeground(Color.white);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class SplashFrame extends JFrame {
|
||||
setUndecorated(true);
|
||||
|
||||
// Set preferred JFrame properties.
|
||||
final ImageIcon bgIcon = skin.splash;
|
||||
final ImageIcon bgIcon = skin.getSplash();
|
||||
final int splashWidthPx = bgIcon.getIconWidth();
|
||||
final int splashHeightPx = bgIcon.getIconHeight();
|
||||
|
||||
@@ -127,8 +127,8 @@ public class SplashFrame extends JFrame {
|
||||
contentPane.getActionMap().put("escAction", new closeAction());
|
||||
|
||||
// Set UI to color splash bar fill with theme colors
|
||||
UIManager.put("ProgressBar.foreground", skin.bg1b); // Filled
|
||||
UIManager.put("ProgressBar.selectionForeground", skin.txt1a); // Filled
|
||||
UIManager.put("ProgressBar.foreground", skin.getBg1b()); // Filled
|
||||
UIManager.put("ProgressBar.selectionForeground", skin.getTxt1a()); // Filled
|
||||
|
||||
// Instantiate model and view and tie together.
|
||||
monitorModel = new SplashProgressModel();
|
||||
|
||||
@@ -88,7 +88,7 @@ public class WinLoseFrame extends JFrame {
|
||||
|
||||
// Place all content in FPanel
|
||||
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());
|
||||
getContentPane().add(contentPanel);
|
||||
|
||||
@@ -107,12 +107,12 @@ public class WinLoseFrame extends JFrame {
|
||||
lblTitle = new JLabel("WinLoseFrame > lblTitle is broken.");
|
||||
lblTitle.setForeground(Color.white);
|
||||
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.setForeground(Color.white);
|
||||
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(lblStats, "growx");
|
||||
@@ -204,7 +204,7 @@ public class WinLoseFrame extends JFrame {
|
||||
bounds.y = (screen.height - bounds.height) / 2;
|
||||
}
|
||||
|
||||
this.setBackground(AllZone.getSkin().bg1a);
|
||||
this.setBackground(AllZone.getSkin().getBg1a());
|
||||
this.setBounds(bounds);
|
||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
this.setUndecorated(true);
|
||||
@@ -279,9 +279,9 @@ public class WinLoseFrame extends JFrame {
|
||||
private class WinLoseBorder extends AbstractBorder {
|
||||
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width,
|
||||
final int height) {
|
||||
g.setColor(AllZone.getSkin().txt1a);
|
||||
g.setColor(AllZone.getSkin().getTxt1a());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user