Created time field, created setTheme for all classes, overworked layout of components

This commit is contained in:
Meruemon
2022-03-23 18:34:38 +01:00
parent 39f06011b3
commit 73c3255d09
10 changed files with 210 additions and 19 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -3,6 +3,7 @@ package View;
import java.util.ArrayList;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
@@ -30,16 +31,20 @@ public class GUIMCMenu extends JPanel {
Color[] aoDarkTheme = {new Color(255, 253, 250), new Color(76, 78, 82), new Color(47, 47, 47), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)};
Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250), new Color(173, 216, 230), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)};
JButton oButtonStart = new JButton();
JButton oButtonStep = new JButton();
JButton oButtonPause = new JButton();
JButton oButtonReset = new JButton();
String[] asLangGerman = {"Start", "Schritt", "Pausieren", "Zurücksetzen"};
String[] asLangEnglish = {"Start", "Step", "Pause", "Reset"};
JButton oButtonStart = new JButton("Start");
JButton oButtonStep = new JButton("Step");
JButton oButtonPause = new JButton("Pause");
JButton oButtonReset = new JButton("Reset");
ArrayList<JButton> oButtons = new ArrayList<JButton>();
public GUIMCMenu() {
buildGUIMCMenu();
fillList();
setLanguage(0);
}
private void buildGUIMCMenu() {
@@ -54,6 +59,28 @@ public class GUIMCMenu extends JPanel {
this.add(oButtonStep, oConstraints);
oConstraints.gridy = 2;
this.add(oButtonPause, oConstraints);
oConstraints.gridy = 3;
this.add(oButtonReset, oConstraints);
}
public void setLanguage(int iLangNr) {
switch (iLangNr) {
case 0: {
int i = 0;
for (JButton oButton : oButtons) {
oButton.setText(asLangGerman[i]);
oButton.setPreferredSize(new Dimension(150,20));
i++;
}
}break;
case 1: {
int i = 0;
for (JButton oButton : oButtons) {
oButton.setText(asLangEnglish[i]);
i++;
}
}break;
}
}
private void fillList() {
@@ -73,21 +100,19 @@ public class GUIMCMenu extends JPanel {
for (JButton oButton : oButtons) {
oButton.setForeground(aoLightTheme[0]);
oButton.setBackground(aoLightTheme[1]);
oButton.setBorder(BorderFactory.createLineBorder(aoLightTheme[2]));
oButton.setBorder(BorderFactory.createLineBorder(aoLightTheme[2], 2));
}
this.setForeground(aoLightTheme[0]);
this.setBackground(aoLightTheme[1]);
this.setBorder(BorderFactory.createLineBorder(aoLightTheme[2]));
}break;
case 1: {
for (JButton oButton : oButtons) {
oButton.setForeground(aoDarkTheme[0]);
oButton.setBackground(aoDarkTheme[1]);
oButton.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2]));
oButton.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2], 2));
}
this.setForeground(aoDarkTheme[0]);
this.setBackground(aoDarkTheme[1]);
this.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2]));
}break;
}
}

View File

@@ -41,10 +41,13 @@ public class GUIMainFrame extends JFrame {
GUIPorts oGUIPorts = new GUIPorts();
GUIStack oGUIStack = new GUIStack();
GUIMCMenu oGUIMCMenu = new GUIMCMenu();
GUITime oGUITime = new GUITime();
JPanel oMainPanel = new JPanel();
JPanel oPanel0 = new JPanel();
JPanel oPanel1 = new JPanel();
JPanel oPanel2 = new JPanel();
JPanel oPanel3 = new JPanel();
ArrayList<JPanel> oPanels = new ArrayList<JPanel>();
/**
@@ -57,43 +60,89 @@ public class GUIMainFrame extends JFrame {
this.setResizable(false); // prevent frame from beeing resized
this.setSize(1400, 800); //sets x and y dimension of frame
//Set layouts of panels
oMainPanel.setLayout(new GridBagLayout());
oPanel0.setLayout(new GridBagLayout());
oPanel1.setLayout(new GridBagLayout());
oPanel2.setLayout(new GridBagLayout());
oPanel3.setLayout(new GridBagLayout());
//Create constraints for positioning
GridBagConstraints oConstraints = new GridBagConstraints();
oConstraints.anchor = GridBagConstraints.NORTHWEST;
oConstraints.weightx = 1;
oConstraints.weighty = 1;
//Build first Panel from left
oConstraints.gridx = 0;
oConstraints.gridy = 0;
oConstraints.insets = new Insets(0,0,0,0);
oConstraints.insets = new Insets(10,10,0,0);
oPanel0.add(oGUITestFileTable, oConstraints);
//Build 2nd Panel from left
oConstraints.gridx = 0;
oConstraints.gridy = 0;
oConstraints.insets = new Insets(10,10,0,0);
oPanel1.add(oGUIRegister, oConstraints);
oConstraints.gridy = 1;
oConstraints.insets = new Insets(36,10,0,0);
oPanel1.add(oGUIRegistersDetailed, oConstraints);
oConstraints.gridy = 2;
oConstraints.insets = new Insets(47,10,0,0);
oPanel1.add(oGUIRamTable, oConstraints);
//Build 3rd Panel from left
oConstraints.gridx = 0;
oConstraints.gridy = 0;
oConstraints.insets = new Insets(10,10,0,0);
oPanel2.add(oGUIPorts, oConstraints);
oConstraints.gridy = 1;
oPanel2.add(oPanel3, oConstraints);
oConstraints.gridy = 2;
oConstraints.insets = new Insets(45,90,0,0);
oPanel2.add(oGUIMCMenu, oConstraints);
//Build lower panel of 3rd panel
oConstraints.gridx = 0;
oConstraints.gridy = 0;
oConstraints.insets = new Insets(0,0,0,0);
oPanel1.add(oGUIRegister, oConstraints);
oConstraints.gridy = 1;
oPanel1.add(oGUIRegistersDetailed, oConstraints);
oConstraints.gridy = 2;
oPanel1.add(oGUIRamTable, oConstraints);
oConstraints.weightx = 1;
oConstraints.weighty = 1;
oPanel3.add(oGUIStack, oConstraints);
oConstraints.insets = new Insets(0,40,0,0);
oConstraints.gridx = 1;
oPanel3.add(oGUITime, oConstraints);
//Build MainPanel
oConstraints.gridx = 0;
oConstraints.gridy = 0;
oConstraints.weightx = 1;
oConstraints.weighty = 1;
oConstraints.insets = new Insets(0,0,0,0);
oMainPanel.add(oPanel0, oConstraints);
oConstraints.gridx = 1;
oMainPanel.add(oPanel1, oConstraints);
oConstraints.gridx = 2;
oMainPanel.add(oPanel2, oConstraints);
//Add panels to list
oPanels.add(oPanel0);
oPanels.add(oPanel1);
oPanels.add(oPanel2);
oPanels.add(oPanel3);
oPanels.add(oMainPanel);
//Set Icon
ImageIcon guiLogo = new ImageIcon("./pictures/gui_logo.png"); // create an ImageIcon
this.setIconImage(guiLogo.getImage()); // change icon of frame
//Set menubar
oGUIMenuBar = new GUIMenuBar(env, this, oGUITestFileTable, oGUIRegister, oGUIRegistersDetailed);
this.setJMenuBar(oGUIMenuBar);
//Build this frame
this.add(oMainPanel);
setTheme(0);
updateWindow();
this.setVisible(true); //make frame visible
}
@@ -110,12 +159,26 @@ public class GUIMainFrame extends JFrame {
oPanel.setForeground(aoLightTheme[0]);
oPanel.setBackground(aoLightTheme[1]);
}
this.setForeground(aoLightTheme[0]);
this.setBackground(aoLightTheme[1]);
oGUIMCMenu.setTheme(0);
oGUIStack.setTheme(0);
oGUIPorts.setTheme(0);
oGUIRamTable.setTheme(0);
oGUITime.setTheme(0);
}break;
case 1: {
for (JPanel oPanel : oPanels) {
oPanel.setForeground(aoDarkTheme[0]);
oPanel.setBackground(aoDarkTheme[1]);
}
this.setForeground(aoDarkTheme[0]);
this.setBackground(aoDarkTheme[1]);
oGUIMCMenu.setTheme(1);
oGUIStack.setTheme(1);
oGUIPorts.setTheme(1);
oGUIRamTable.setTheme(1);
oGUITime.setTheme(1);
}break;
}
}

View File

@@ -98,22 +98,26 @@ public class GUIRamTable extends JScrollPane {
case 0: {
oRam.setForeground(aoLightTheme[0]);
oRam.setBackground(aoLightTheme[1]);
oRamPanel.setForeground(aoLightTheme[0]);
oRamPanel.setBackground(aoLightTheme[1]);
oRamTable.setForeground(aoLightTheme[0]);
oRamTable.setBackground(aoLightTheme[1]);
oRamTable.setGridColor(aoLightTheme[2]);
this.setForeground(aoLightTheme[0]);
this.setBackground(aoLightTheme[1]);
this.setBorder(BorderFactory.createLineBorder(aoLightTheme[2]));
this.setBorder(BorderFactory.createLineBorder(aoLightTheme[2], 2));
}break;
case 1: {
oRam.setForeground(aoDarkTheme[0]);
oRam.setBackground(aoDarkTheme[1]);
oRamPanel.setForeground(aoDarkTheme[0]);
oRamPanel.setBackground(aoDarkTheme[1]);
oRamTable.setForeground(aoDarkTheme[0]);
oRamTable.setBackground(aoDarkTheme[1]);
oRamTable.setGridColor(aoDarkTheme[2]);
this.setForeground(aoDarkTheme[0]);
this.setBackground(aoDarkTheme[1]);
this.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2]));
this.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2], 2));
}break;
}
}

View File

@@ -43,7 +43,7 @@ public class GUIStack extends JPanel {
GridBagConstraints oConstraints = new GridBagConstraints();
this.setLayout(new GridBagLayout());
oStackTable.setEnabled(false);
oConstraints.gridx = 0;
oConstraints.gridy = 0;
oConstraints.anchor = GridBagConstraints.WEST;
@@ -60,6 +60,7 @@ public class GUIStack extends JPanel {
oStackTable.setForeground(aoLightTheme[0]);
oStackTable.setBackground(aoLightTheme[1]);
oStackTable.setGridColor(aoLightTheme[2]);
oStackTable.setBorder(BorderFactory.createLineBorder(aoLightTheme[2]));
this.setForeground(aoLightTheme[0]);
this.setBackground(aoLightTheme[1]);
this.setBorder(BorderFactory.createLineBorder(aoLightTheme[2], 2));
@@ -70,6 +71,7 @@ public class GUIStack extends JPanel {
oStackTable.setForeground(aoDarkTheme[0]);
oStackTable.setBackground(aoDarkTheme[1]);
oStackTable.setGridColor(aoDarkTheme[2]);
oStackTable.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2]));
this.setForeground(aoDarkTheme[0]);
this.setBackground(aoDarkTheme[1]);
this.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2], 2));

View File

@@ -1,7 +1,104 @@
package View;
import java.awt.Color;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.GridBagConstraints;
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class GUITime extends JPanel {
/**
* Color oWhite = new Color(255, 253, 250);
* Color oDarkGray = new Color(76, 78, 82);
* Color oDarkGrayB = new Color(47, 47, 47);
* Color oLightBlue = new Color(173, 216, 230);
* Color oOrangeDM = new Color(255, 170, 0);
* Color oLightBlueDM = new Color(0, 213, 255);
* Color oOrangeDMB = new Color(255, 85, 0);
* First Color == TextColor
* Second Color == BackgroundColor
* Third Color == BorderColor
* Fourth Color == TextColor Marked
* Fifth Color == BackgroundColor Marked
* Sixth Color == BorderColor Marked
*/
Color[] aoDarkTheme = {new Color(255, 253, 250), new Color(76, 78, 82), new Color(47, 47, 47), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)};
Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250), new Color(173, 216, 230), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)};
JLabel oLabelWDT = new JLabel("Watchdog Timer");
JCheckBox oEnableWDT = new JCheckBox("WDT");
JLabel oLabelRuntime = new JLabel("Runtime: 0");
JLabel oLabelQuarz = new JLabel("Quarzfrequency");
String[] asIntervals = {"32 kHz", "100 kHz", "500 kHz", "1 MHz", "2 MHz", "4 MHz", "8 MHz", "12 MHz", "16 MHz", "20 MHz"};
JComboBox<String> oIntervals = new JComboBox<>(asIntervals);
public GUITime() {
buildGUITime();
}
private void buildGUITime() {
this.setLayout(new GridBagLayout());
GridBagConstraints oConstraints = new GridBagConstraints();
oConstraints.gridx = 0;
oConstraints.gridy = 0;
oConstraints.weightx = 1;
oConstraints.weighty = 1;
oConstraints.anchor = GridBagConstraints.NORTHWEST;
oConstraints.insets = new Insets(5,35,0,36);
this.add(oLabelWDT, oConstraints);
oConstraints.gridy = 1;
oConstraints.insets = new Insets(0,35,0,36);
this.add(oEnableWDT, oConstraints);
oConstraints.gridy = 2;
oConstraints.insets = new Insets(20,35,0,36);
this.add(oLabelRuntime, oConstraints);
oConstraints.gridy = 3;
oConstraints.insets = new Insets(20,35,0,36);
this.add(oLabelQuarz, oConstraints);
oConstraints.gridy = 4;
oConstraints.insets = new Insets(0,35,5,36);
this.add(oIntervals, oConstraints);
}
public void setTheme(int iThemeNr) {
switch (iThemeNr) {
case 0: {
oLabelWDT.setForeground(aoLightTheme[0]);
oLabelWDT.setBackground(aoLightTheme[1]);
oEnableWDT.setForeground(aoLightTheme[0]);
oEnableWDT.setBackground(aoLightTheme[1]);
oLabelRuntime.setForeground(aoLightTheme[0]);
oLabelRuntime.setBackground(aoLightTheme[1]);
oLabelQuarz.setForeground(aoLightTheme[0]);
oLabelQuarz.setBackground(aoLightTheme[1]);
oIntervals.setForeground(aoLightTheme[0]);
oIntervals.setBackground(aoLightTheme[1]);
this.setForeground(aoLightTheme[0]);
this.setBackground(aoLightTheme[1]);
this.setBorder(BorderFactory.createLineBorder(aoLightTheme[2], 2));
}break;
case 1: {
oLabelWDT.setForeground(aoDarkTheme[0]);
oLabelWDT.setBackground(aoDarkTheme[1]);
oEnableWDT.setForeground(aoDarkTheme[0]);
oEnableWDT.setBackground(aoDarkTheme[1]);
oLabelRuntime.setForeground(aoDarkTheme[0]);
oLabelRuntime.setBackground(aoDarkTheme[1]);
oLabelQuarz.setForeground(aoDarkTheme[0]);
oLabelQuarz.setBackground(aoDarkTheme[1]);
oIntervals.setForeground(aoDarkTheme[0]);
oIntervals.setBackground(aoDarkTheme[1]);
this.setForeground(aoDarkTheme[0]);
this.setBackground(aoDarkTheme[1]);
this.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2], 2));
}break;
}
}
}