Refactoring.
This commit is contained in:
@@ -16,11 +16,11 @@ public class BasicNavPanel extends JPanel implements AppTheme {
|
||||
public BasicNavPanel(DefaultButton backButton, DefaultButton continueButton, int continueRequirement) {
|
||||
|
||||
super(new GridLayout(1, 2, 30, 0));
|
||||
this.backButton = backButton;
|
||||
this.continueButton = continueButton;
|
||||
this.backButton = backButton;
|
||||
this.continueButton = continueButton;
|
||||
|
||||
this.continueRequirement = continueRequirement;
|
||||
createNavPanel();
|
||||
this.continueRequirement = continueRequirement;
|
||||
createNavPanel();
|
||||
|
||||
}
|
||||
|
||||
@@ -58,17 +58,17 @@ public class BasicNavPanel extends JPanel implements AppTheme {
|
||||
setBorder(new EmptyBorder(15, 150, 15, 150));
|
||||
add(backButton);
|
||||
|
||||
if(continueRequirement == 0) {
|
||||
if (continueRequirement == 0) {
|
||||
|
||||
add(continueButton);
|
||||
|
||||
} else {
|
||||
|
||||
DefaultButton requiredStepsNeeds = new DefaultButton(Integer.toString(continueRequirement) + " Points Left");
|
||||
requiredStepsNeeds.select();
|
||||
requiredStepsNeeds.setBorder(new LineBorder(lightAccent, 1));
|
||||
requiredStepsNeeds.setBorderPainted(true);
|
||||
requiredStepsNeeds.setEnabled(false);
|
||||
requiredStepsNeeds.select();
|
||||
requiredStepsNeeds.setBorder(new LineBorder(lightAccent, 1));
|
||||
requiredStepsNeeds.setBorderPainted(true);
|
||||
requiredStepsNeeds.setEnabled(false);
|
||||
add(requiredStepsNeeds);
|
||||
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public class DefaultButton extends JButton implements AppTheme {
|
||||
public DefaultButton(String buttonLabel) {
|
||||
|
||||
super(buttonLabel);
|
||||
applyDefaultButtonStyle();
|
||||
applyCommon();
|
||||
applyDefaultButtonStyle();
|
||||
applyCommon();
|
||||
|
||||
}
|
||||
|
||||
@@ -42,23 +42,32 @@ public class DefaultButton extends JButton implements AppTheme {
|
||||
|
||||
private void applyFocusedButtonStyle() {
|
||||
|
||||
setBackground(darkestBrown);
|
||||
setForeground(lightAccent);
|
||||
setBackground(darkestBrown);
|
||||
setForeground(lightAccent);
|
||||
|
||||
}
|
||||
|
||||
private void applyCommon() {
|
||||
|
||||
addMouseListener(
|
||||
new MouseListener() {
|
||||
new MouseListener() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {}
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) { applyFocusedButtonStyle(); }
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
applyFocusedButtonStyle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
|
||||
@@ -83,5 +92,4 @@ public class DefaultButton extends JButton implements AppTheme {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ImageInfoPanel extends InfoPanel implements AppTheme {
|
||||
|
||||
}*/
|
||||
|
||||
lastIndex = newIndex;
|
||||
lastIndex = newIndex;
|
||||
|
||||
return newIndex;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ImageInfoPanel extends InfoPanel implements AppTheme {
|
||||
|
||||
String category = "";
|
||||
|
||||
if(panelIndex == 1) {
|
||||
if (panelIndex == 1) {
|
||||
|
||||
category = "Races";
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ImageInfoPanel extends InfoPanel implements AppTheme {
|
||||
|
||||
File imagesDir;
|
||||
|
||||
if(OS.startsWith("Windows")) {
|
||||
if (OS.startsWith("Windows")) {
|
||||
|
||||
imagesDir = new File("dndBuilder\\src\\Resources\\Img\\" + category + "\\" + categoryHolder[i].toLowerCase() + "\\");
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ImageInfoPanel extends InfoPanel implements AppTheme {
|
||||
|
||||
} else if (OS.startsWith("Linux")) {
|
||||
|
||||
imagesDir = new File("dndBuilder/src/Resources/Img/" + category + "/" + categoryHolder[i].toLowerCase() + "/");
|
||||
imagesDir = new File("dndBuilder/src/Resources/Img/" + category + "/" + categoryHolder[i].toLowerCase() + "/");
|
||||
|
||||
} else {
|
||||
|
||||
@@ -125,7 +125,7 @@ public class ImageInfoPanel extends InfoPanel implements AppTheme {
|
||||
|
||||
}
|
||||
|
||||
if(Objects.isNull(finalImg)) {
|
||||
if (Objects.isNull(finalImg)) {
|
||||
|
||||
picture = new JLabel("ERROR: Image not found.");
|
||||
|
||||
|
||||
@@ -2,14 +2,9 @@ package Resources.CustomAssets;
|
||||
|
||||
import GUI.AppTheme;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
public class InfoPanel extends JPanel implements AppTheme {
|
||||
|
||||
@@ -22,14 +17,14 @@ public class InfoPanel extends JPanel implements AppTheme {
|
||||
public InfoPanel(String[] categoryHolder, String[] holderDescriptions, Rectangle[] bounds, int panelIndex) {
|
||||
|
||||
super();
|
||||
this.categoryHolder = categoryHolder;
|
||||
this.holderDescriptions = holderDescriptions;
|
||||
this.bounds = bounds;
|
||||
this.panelIndex = panelIndex;
|
||||
this.categoryHolder = categoryHolder;
|
||||
this.holderDescriptions = holderDescriptions;
|
||||
this.bounds = bounds;
|
||||
this.panelIndex = panelIndex;
|
||||
|
||||
panelSetup();
|
||||
panelSetup();
|
||||
|
||||
createDescriptions();
|
||||
createDescriptions();
|
||||
|
||||
}
|
||||
|
||||
@@ -63,13 +58,13 @@ public class InfoPanel extends JPanel implements AppTheme {
|
||||
setLayout(null);
|
||||
|
||||
JLabel subHeader = new JLabel("Description");
|
||||
subHeader.setFont(subHeaderFont);
|
||||
subHeader.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
subHeader.setBounds(bounds[1]);
|
||||
subHeader.setForeground(darkestBrown);
|
||||
subHeader.setFont(subHeaderFont);
|
||||
subHeader.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
subHeader.setBounds(bounds[1]);
|
||||
subHeader.setForeground(darkestBrown);
|
||||
|
||||
add(subHeader);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void createDescriptions() {
|
||||
@@ -79,17 +74,17 @@ public class InfoPanel extends JPanel implements AppTheme {
|
||||
for (int i = 0; i < holderDescriptions.length; i++) {
|
||||
|
||||
JTextArea tmpDesc = new JTextArea();
|
||||
tmpDesc.setText(holderDescriptions[i]);
|
||||
tmpDesc.setWrapStyleWord(true);
|
||||
tmpDesc.setLineWrap(true);
|
||||
tmpDesc.setOpaque(true);
|
||||
tmpDesc.setEditable(false);
|
||||
tmpDesc.setFocusable(false);
|
||||
tmpDesc.setFont(paragraphFont);
|
||||
tmpDesc.setBounds(bounds[2]);
|
||||
tmpDesc.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
tmpDesc.setBackground(medBrown);
|
||||
tmpDesc.setForeground(darkestBrown);
|
||||
tmpDesc.setText(holderDescriptions[i]);
|
||||
tmpDesc.setWrapStyleWord(true);
|
||||
tmpDesc.setLineWrap(true);
|
||||
tmpDesc.setOpaque(true);
|
||||
tmpDesc.setEditable(false);
|
||||
tmpDesc.setFocusable(false);
|
||||
tmpDesc.setFont(paragraphFont);
|
||||
tmpDesc.setBounds(bounds[2]);
|
||||
tmpDesc.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
tmpDesc.setBackground(medBrown);
|
||||
tmpDesc.setForeground(darkestBrown);
|
||||
|
||||
descriptions[i] = tmpDesc;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Resources.CustomAssets;
|
||||
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.border.Border;
|
||||
import java.awt.*;
|
||||
|
||||
public class RoundedBorder implements Border {
|
||||
@@ -15,7 +15,7 @@ public class RoundedBorder implements Border {
|
||||
|
||||
public Insets getBorderInsets(Component c) {
|
||||
|
||||
return new Insets(this.radius+1, this.radius+1, this.radius+2, this.radius);
|
||||
return new Insets(this.radius + 1, this.radius + 1, this.radius + 2, this.radius);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class RoundedBorder implements Border {
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
|
||||
g.drawRoundRect(x, y, width-1, height-1, radius, radius);
|
||||
g.drawRoundRect(x, y, width - 1, height - 1, radius, radius);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user