created setTheme at mainframe class and finished table with register details

This commit is contained in:
Meruemon
2022-03-20 16:53:10 +01:00
parent 23717cdfc1
commit ab81461034
16 changed files with 643 additions and 453 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -214,7 +214,7 @@ public class RAM {
//Check for overflow and set bit and timer
if ((iValTMR0 + iValIncr) > 255) {
set_T0IF(true);
set_TMR0((iValTMR0 + iValIncr) & 255); //TODO 0 or &255
set_TMR0((iValTMR0 + iValIncr) & 255); //TODO 0 or &255 (Question to Prof)
} else {
set_T0IF(false);
set_TMR0(iValTMR0 + iValIncr);
@@ -281,34 +281,12 @@ public class RAM {
* @param value
*/
public synchronized void set_PORTA(int value) {
//Check if PORT A RA4 was set/cleared
boolean bActualRA4 = get_RA4_T0CKI();
boolean bNewRA4 = ((value & 0b00010000) == 0b00010000);
//Increment TMR0 if RA4 was set/cleared
if (bActualRA4 != bNewRA4) {
if (bNewRA4) { //rising edge
if (!get_T0SE()) { //rising edge increments TMR0
increment_TMR0();
}
} else { //falling edge
if (get_T0SE()) { //falling edge increments TMR0
increment_TMR0();
}
}
}
//Set PORT A
bank0[5] = value;
}
public synchronized void set_PORTA_Bit_X_To_Y(int x, int y) { //TODO
//Increment TMR0 if RA4 was set/cleared
if ((x == 4)) {
if (get_T0CS()) {
//Check if PORT A RA4 was set/cleared
boolean bActualRA4 = get_RA4_T0CKI();
boolean bNewRA4 = false;
if (y == 1)
bNewRA4 = true;
boolean bNewRA4 = ((value & 0b00010000) == 0b00010000);
//Increment TMR0 if RA4 was set/cleared
if (bActualRA4 != bNewRA4) {
if (bNewRA4) { //rising edge
if (!get_T0SE()) { //rising edge increments TMR0
@@ -321,6 +299,35 @@ public class RAM {
}
}
}
//Set PORT A
bank0[5] = value;
}
public synchronized void set_PORTA_Bit_X_To_Y(int x, int y) {
//Increment TMR0 if RA4 was set/cleared
if ((x == 4)) {
//Check T0CS
if (get_T0CS()) {
boolean bActualRA4 = get_RA4_T0CKI();
boolean bNewRA4 = false;
if (y == 1)
bNewRA4 = true;
if (bActualRA4 != bNewRA4) {
if (bNewRA4) { //rising edge
if (!get_T0SE()) { //rising edge increments TMR0
increment_TMR0();
}
} else { //falling edge
if (get_T0SE()) { //falling edge increments TMR0
increment_TMR0();
}
}
}
}
}
//Clear bit x
if (y == 0) {
@@ -595,71 +602,65 @@ public class RAM {
set_STATUS(status);
}
public synchronized boolean get_Interruptflag()
{
public synchronized boolean get_Interruptflag() {
return (get_STATUS() & 0b10000000) == 128;
}
//Bank0 PCL
public synchronized int get_Programcounter()
{
public synchronized int get_Programcounter() {
return (bank0[2]);
}
public synchronized int get_LastProgramcounter()
{
public synchronized int get_LastProgramcounter() {
return lastProgramcounter;
}
public synchronized void inkrement_Programcounter(int value, int kindOfCall) //0 at Fetchzycle, 1 at Jumpcommand, 2 at ...
{
if (bank0[2] >= 0 && bank0[2] <= 255)
{
/**
*
* @param value
* @param kindOfCall 0 at normal instruction, 1 at Fetchzycle,... 2 at Jumpcommand, 3 at ...
*/
public synchronized void inkrement_Programcounter(int value, int kindOfCall) {
if (bank0[2] >= 0 && bank0[2] <= 255) {
lastProgramcounter = bank0[2];
bank0[2] += value;
}
else
{
if (kindOfCall == 0)
{
} else {
if (kindOfCall == 0) {
//Nothing happens
}
if (kindOfCall == 1)
{
if (kindOfCall == 1) {
bank0[2] = 0; //Wrap-Around at fetchcycle
}
}
}
public synchronized void dekrement_Programcounter(int value)
{
if (bank0[2] > 0 && bank0[2] <= 255)
{
/**
* Decrements PC by value.
* @param value to decrement PC by.
*/
public synchronized void dekrement_Programcounter(int value) {
if (bank0[2] > 0 && bank0[2] <= 255) {
lastProgramcounter = bank0[2];
bank0[2] -= value;
}
else
{
} else {
throw new IndexOutOfBoundsException();
}
}
public synchronized boolean set_Programcounter(int value)
{
/**
* Sets PC to value.
* @param value to set PC to.
* @returns true if set worked, else false if set didn't work.
*/
public synchronized boolean set_Programcounter(int value) {
boolean setWorked = false;
if (value >= 0 && value <= 255)
{
if (value >= 0 && value <= 255) {
lastProgramcounter = bank0[2];
bank0[2] = value;
setWorked = true;
}
else
{
} else {
throw new IndexOutOfBoundsException();
}
@@ -667,85 +668,84 @@ public class RAM {
}
//Bank0 PORTA
public synchronized void set_RA0(boolean value)
{
/**
*
* @param value
*/
public synchronized void set_RA0(boolean value) {
int portA = get_PORTA();
if (value)
{
if (value) {
portA |= 0b00000001;
}
else
{
} else {
portA &= 0b11111110;
}
set_PORTA(portA);
}
public synchronized boolean get_RA0()
{
{
return (get_PORTA() & 0b00000001) == 1;
}
/**
*
* @return
*/
public synchronized boolean get_RA0() {
return (get_PORTA() & 0b00000001) == 1;
}
public synchronized void set_RA1(boolean value)
{
/**
*
* @param value
*/
public synchronized void set_RA1(boolean value) {
int portA = get_PORTA();
if (value)
{
if (value) {
portA |= 0b00000010;
}
else
{
} else {
portA &= 0b11111101;
}
set_PORTA(portA);
}
public synchronized boolean get_RA1()
{
{
return (get_PORTA() & 0b00000010) == 2;
}
/**
*
* @return
*/
public synchronized boolean get_RA1() {
return (get_PORTA() & 0b00000010) == 2;
}
public synchronized void set_RA2(boolean value)
{
/**
*
* @param value
*/
public synchronized void set_RA2(boolean value) {
int portA = get_PORTA();
if (value)
{
if (value) {
portA |= 0b00000100;
}
else
{
} else {
portA &= 0b11111011;
}
set_PORTA(portA);
}
public synchronized boolean get_RA2()
{
{
return (get_PORTA() & 0b00000100) == 4;
}
/**
*
* @return
*/
public synchronized boolean get_RA2() {
return (get_PORTA() & 0b00000100) == 4;
}
public synchronized void set_RA3(boolean value)
{
/**
*
* @param value
*/
public synchronized void set_RA3(boolean value) {
int portA = get_PORTA();
if (value)
{
if (value) {
portA |= 0b00001000;
}
else
{
} else {
portA &= 0b11110111;
}

View File

@@ -31,13 +31,15 @@ public class Environment {
public Environment() {
oPIC = new PIC();
oPIC.setWRegister(4);
GUIMainFrame oMainFrame = new GUIMainFrame(this);
watchdog = new WATCHDOG();
oPIC = new PIC();
sEepromDataFile = "";
sActualCommand = "";

View File

@@ -3,6 +3,7 @@ package Frontend.PIC_SIMULATOR_GUI_JAVA;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Insets;
import java.util.ArrayList;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
@@ -10,6 +11,7 @@ import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.Border;
import Backend.EepromLoader.ReadEepromFile;
@@ -17,27 +19,72 @@ import Backend.Runtime.Environment;
public class GUIMainFrame extends JFrame {
/**
* 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)};
GUITestFileTable oGUITestFileTable;
GUIMenuBar oGUIMenuBar;
JPanel oMainPanel;
JPanel oPanelRegisterInformation;
ArrayList<JPanel> oPanels = new ArrayList<JPanel>();
/**
* Constructor
*/
public GUIMainFrame(Environment env) {
oMainPanel = new JPanel();
this.setTitle("PIC-Simulator GUI"); // sets title of frame
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // if x is pressed, exit application (HIDE_ON_CLOSE-hides application, DO_NOTHING_ON_CLOSE-prevents user from closing application)
//this.setResizable(false); // prevent frame from beeing resized
this.setSize(1400, 800); //sets x and y dimension of frame
//this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
this.setLayout(new GridBagLayout());
oMainPanel.setLayout(new GridBagLayout());
oGUITestFileTable = new GUITestFileTable();
int[] aiTestRegisters = {1, 2, 3, 4, 5, 6, 7, 8 ,9};
oPanelRegisterInformation = new JPanel();
oPanelRegisterInformation.setLayout(new GridBagLayout());
GridBagConstraints oConstraintsRegisterInformation = new GridBagConstraints();
int iPrescaler;
if (env.getPIC().getRam().get_PSA())
iPrescaler = env.getPIC().getRam().get_WDT_PrescalerRate();
else
iPrescaler = env.getPIC().getRam().get_TMR0_PrescalerRate();
int[] aiRegisters = {env.getPIC().getRam().get_PCL(), env.getPIC().getRam().get_PCLATH(),
env.getPIC().getRam().get_Programcounter(), env.getPIC().getRam().get_STATUS(),
env.getPIC().getRam().get_FSR(), env.getPIC().getRam().get_OPTION(),
iPrescaler, env.getPIC().getRam().get_TMR0(),
env.getPIC().get_WRegister()};
GUIRegisters oGUIRegisters = new GUIRegisters();
oGUIRegisters.setRegisters(aiRegisters);
GUIRegistersDetailed oGuiRegistersDetailed = new GUIRegistersDetailed();
oConstraintsRegisterInformation.anchor = GridBagConstraints.WEST;
oConstraintsRegisterInformation.gridx = 0;
oConstraintsRegisterInformation.gridy = 0;
oPanelRegisterInformation.add(oGUIRegisters, oConstraintsRegisterInformation);
oConstraintsRegisterInformation.gridy = 1;
oConstraintsRegisterInformation.anchor = GridBagConstraints.WEST;
oPanelRegisterInformation.add(oGuiRegistersDetailed, oConstraintsRegisterInformation);
this.setJMenuBar(new GUIMenuBar(env, this, oGUITestFileTable, oGUIRegisters));
this.setVisible(true); //make frame visible
this.setBackground(new Color(76, 78, 82));
ImageIcon guiLogo = new ImageIcon("./images/gui_logo.png"); // create an ImageIcon
ImageIcon guiLogo = new ImageIcon("./pictures/gui_logo.png"); // create an ImageIcon
this.setIconImage(guiLogo.getImage()); // change icon of frame
//this.getContentPane().setBackground(Color.green); //change color of background
@@ -64,14 +111,16 @@ public class GUIMainFrame extends JFrame {
//getContentPane().setLayout(new BorderLayout());
//this.add(new GUITestFileTable("./testfiles/TPicSim1.LST"));
GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.WEST;
c.insets = new Insets(2,5,2,5);
c.gridx = 0; //next added element will be in column 1
c.gridy = 0; //next added element will be in row 1
c.insets = new Insets(10,10,10,10);
this.add(oGUITestFileTable, c);
oMainPanel.add(oGUITestFileTable, c);
c.gridx = 1;
this.add(oGUIRegisters);
oMainPanel.add(oPanelRegisterInformation, c);
oPanels.add(oPanelRegisterInformation);
oPanels.add(oMainPanel);
this.add(oMainPanel);
updateWindow();
}
@@ -79,4 +128,21 @@ public class GUIMainFrame extends JFrame {
this.revalidate();
this.repaint();
}
public void setTheme(int iThemeNr) {
switch (iThemeNr) {
case 0: {
for (JPanel oPanel : oPanels) {
oPanel.setForeground(aoLightTheme[0]);
oPanel.setBackground(aoLightTheme[1]);
}
}break;
case 1: {
for (JPanel oPanel : oPanels) {
oPanel.setForeground(aoDarkTheme[0]);
oPanel.setBackground(aoDarkTheme[1]);
}
}break;
}
}
}

View File

@@ -14,6 +14,8 @@ import javax.swing.JFileChooser;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import Backend.EepromLoader.ReadEepromFile;
import Backend.Runtime.Environment;
@@ -367,7 +369,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
setTheme(aoDarkTheme[0], aoDarkTheme[1]);
oGUITestFileTable.setTheme(1);
oGUIRegisters.setTheme(1);
oGUIMainFrame.setBackground(aoDarkTheme[1]);
oGUIMainFrame.setTheme(1);
}
//Change to light theme
if (e.getSource() == oLightTheme) {
@@ -375,7 +377,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
setTheme(aoLightTheme[0], aoLightTheme[1]);
oGUITestFileTable.setTheme(0);
oGUIRegisters.setTheme(0);
oGUIMainFrame.setBackground(aoLightTheme[1]);
oGUIMainFrame.setTheme(0);
}
//Microcontroller

View File

@@ -14,11 +14,20 @@ public class GUIRegisters 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)};
Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250)};
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)};
ArrayList<JTextField> oTextfields = new ArrayList<JTextField>();
ArrayList<JPanel> oPanels = new ArrayList<JPanel>();
@@ -26,61 +35,55 @@ public class GUIRegisters extends JPanel {
JPanel oLeftComponentPanel = new JPanel();
JPanel oRightComponentPanel = new JPanel();
JTextField oTextSFR = new JTextField("SFR", 22);
int iTextFieldSize = 15;
JTextField oTextPCL = new JTextField("PCL", 22);
JTextField oTextPCLATH = new JTextField("PCLATH", 22);
JTextField oTextPCIntern = new JTextField("PC intern", 22);
JTextField oTextStatus = new JTextField("STATUS", 22);
JTextField oTextFileSelectionRegister = new JTextField("FileSelectionRegister", 22);
JTextField oTextOption = new JTextField("OPTION", 22);
JTextField oTextPrescaler = new JTextField("Prescaler", 22);
JTextField oTextTMR0 = new JTextField("TMR0", 22);
JTextField oTextSFR = new JTextField("SFR", iTextFieldSize);
JTextField oTextPCL = new JTextField("PCL", iTextFieldSize);
JTextField oTextPCLATH = new JTextField("PCLATH", iTextFieldSize);
JTextField oTextPCIntern = new JTextField("PC intern", iTextFieldSize);
JTextField oTextStatus = new JTextField("STATUS", iTextFieldSize);
JTextField oTextFileSelectionRegister = new JTextField("FileSelectionRegister", iTextFieldSize);
JTextField oTextOption = new JTextField("OPTION", iTextFieldSize);
JTextField oTextPrescaler = new JTextField("Prescaler", iTextFieldSize);
JTextField oTextTMR0 = new JTextField("TMR0", iTextFieldSize);
JTextField oValuePCL = new JTextField("00", 2);
JTextField oValuePCLATH = new JTextField("00", 2);
JTextField oValuePCIntern = new JTextField("00", 2);
JTextField oValueStatus = new JTextField("00", 2);
JTextField oValueFileSearchRegister = new JTextField("00", 2);
JTextField oValueFileSelectionRegister = new JTextField("00", 2);
JTextField oValueOption = new JTextField("00", 2);
JTextField oValuePrescaler = new JTextField("00", 2);
JTextField oValueTMR0 = new JTextField("00", 2);
JTextField oFillTextField1 = new JTextField("", 22);
JTextField oFillTextField1 = new JTextField("", iTextFieldSize);
JTextField oFillValueField1 = new JTextField("", 2);
JTextField oFillTextField2 = new JTextField("", 22);
JTextField oFillTextField2 = new JTextField("", iTextFieldSize);
JTextField oFillValueField2 = new JTextField("", 2);
JTextField oFillTextField3 = new JTextField("", 22);
JTextField oFillTextField3 = new JTextField("", iTextFieldSize);
JTextField oFillValueField3 = new JTextField("", 2);
JTextField oFillValueField4 = new JTextField("", 2);
JTextField oFillValueField5 = new JTextField("", 2);
JTextField oTextW = new JTextField("W", 22);
JTextField oTextWRegister = new JTextField("W-Register", 22);
JTextField oTextW = new JTextField("W", iTextFieldSize);
JTextField oTextWRegister = new JTextField("W-Register", iTextFieldSize);
JTextField oValueWRegister = new JTextField("00", 2);
/**
* Constructor of register-table-class, adds components to list, sets components uneditable,
* builds register-table and colors according to theme.
*/
public GUIRegisters() {
//9
/**
* [0] W-Register
* [1] PCL
* [2] PCLATH
* [3] PC intern
* [4] Status
* [5] FSR FileSelectionRegister
* [6] Option
* [7] Vorteiler
* [8] TMR0
*/
addComponentsToLists();
setEditFalse();
buildGUIRegisters();
setTheme(0);
this.setBorder(BorderFactory.createLineBorder(new Color(173, 216, 230)));
}
/**
* Builds register-panel by actually setting the positions of the fields and adding them to the panels.
*/
private void buildGUIRegisters() {
GridBagConstraints oConstraints = new GridBagConstraints();
@@ -95,7 +98,7 @@ public class GUIRegisters extends JPanel {
oConstraints.anchor = GridBagConstraints.WEST;
oLeftComponentPanel.add(oTextSFR, oConstraints);
oConstraints.gridx = 1;
oLeftComponentPanel.add(oFillValueField1);
oLeftComponentPanel.add(oFillValueField1, oConstraints);
//Fill left side of left component panel
oConstraints.gridx = 0;
@@ -135,14 +138,16 @@ public class GUIRegisters extends JPanel {
oRightComponentPanel.add(oTextTMR0, oConstraints);
oConstraints.gridy = 5;
oRightComponentPanel.add(oFillTextField2, oConstraints);
oConstraints.gridy = 6;
oRightComponentPanel.add(oFillTextField3, oConstraints);
//Fill right side of right component panel
oConstraints.gridx = 1;
oConstraints.gridy = 0;
oConstraints.anchor = GridBagConstraints.EAST;
oRightComponentPanel.add(oFillValueField1, oConstraints);
oRightComponentPanel.add(oFillValueField2, oConstraints);
oConstraints.gridy = 1;
oRightComponentPanel.add(oValueFileSearchRegister, oConstraints);
oRightComponentPanel.add(oValueFileSelectionRegister, oConstraints);
oConstraints.gridy = 2;
oRightComponentPanel.add(oValueOption, oConstraints);
oConstraints.gridy = 3;
@@ -150,7 +155,9 @@ public class GUIRegisters extends JPanel {
oConstraints.gridy = 4;
oRightComponentPanel.add(oValueTMR0, oConstraints);
oConstraints.gridy = 5;
oRightComponentPanel.add(oFillValueField2);
oRightComponentPanel.add(oFillValueField3, oConstraints);
oConstraints.gridy = 6;
oRightComponentPanel.add(oFillValueField4, oConstraints);
//Fill footer of left component panel
oConstraints.anchor = GridBagConstraints.WEST;
@@ -159,8 +166,9 @@ public class GUIRegisters extends JPanel {
oLeftComponentPanel.add(oTextW, oConstraints);
oConstraints.anchor = GridBagConstraints.EAST;
oConstraints.gridx = 1;
oLeftComponentPanel.add(oFillValueField2, oConstraints);
oLeftComponentPanel.add(oFillValueField5, oConstraints);
oConstraints.gridx = 0;
oConstraints.gridy = 6;
oLeftComponentPanel.add(oTextWRegister, oConstraints);
oConstraints.anchor = GridBagConstraints.EAST;
oConstraints.gridx = 1;
@@ -171,6 +179,7 @@ public class GUIRegisters extends JPanel {
oConstraints.gridx = 0;
oConstraints.gridy = 0;
this.add(oLeftComponentPanel, oConstraints);
oConstraints.gridx = 1;
this.add(oRightComponentPanel, oConstraints);
}
@@ -189,24 +198,31 @@ public class GUIRegisters extends JPanel {
oTextfields.add(oTextTMR0);
oTextfields.add(oTextW);
oTextfields.add(oTextWRegister);
oTextfields.add(oFillTextField1);
oTextfields.add(oFillTextField2);
oTextfields.add(oFillTextField3);
oTextfields.add(oValuePCL);
oTextfields.add(oValuePCLATH);
oTextfields.add(oValuePCIntern);
oTextfields.add(oValueStatus);
oTextfields.add(oValueFileSearchRegister);
oTextfields.add(oValueFileSelectionRegister);
oTextfields.add(oValueOption);
oTextfields.add(oValuePrescaler);
oTextfields.add(oValueTMR0);
oTextfields.add(oValueWRegister);
oTextfields.add(oFillValueField1);
oTextfields.add(oFillValueField2);
oTextfields.add(oFillValueField3);
oTextfields.add(oFillValueField4);
oTextfields.add(oFillValueField5);
oPanels.add(this);
oPanels.add(oLeftComponentPanel);
oPanels.add(oRightComponentPanel);
}
/**
*
* Set edit all textfields to false.
*/
private void setEditFalse() {
for (JTextField oTextfield : oTextfields) {
@@ -215,16 +231,28 @@ public class GUIRegisters extends JPanel {
}
/**
*
* Sets textfields of registervalues.
* @param aiRegisters
*/
public void setRegisters(int[] aiRegisters) {
//TODO
oValuePCL.setText(aiRegisters[0] + "");
oValuePCLATH.setText(aiRegisters[1] + "");
oValuePCIntern.setText(aiRegisters[2] + "");
oValueStatus.setText(aiRegisters[3] + "");
oValueFileSelectionRegister.setText(aiRegisters[4] + "");
oValueOption.setText(aiRegisters[5] + "");
oValuePrescaler.setText(aiRegisters[6] + "");
oValueTMR0.setText(aiRegisters[7] + "");
oValueWRegister.setText(aiRegisters[8] + "");
}
/**
* Set theme of RegisterTable
* @param iThemeNr 0 == light theme, 1 == dark theme
*/
public void setTheme(int iThemeNr) {
switch (iThemeNr) {
case 0: {
case 0: { //light theme
for (JPanel oPanel : oPanels) {
oPanel.setForeground(aoLightTheme[0]);
oPanel.setBackground(aoLightTheme[1]);
@@ -233,12 +261,12 @@ public class GUIRegisters extends JPanel {
for (JTextField oTextfield : oTextfields) {
oTextfield.setForeground(aoLightTheme[0]);
oTextfield.setBackground(aoLightTheme[1]);
oTextfield.setBorder(BorderFactory.createLineBorder(aoLightTheme[1]));
oTextfield.setBorder(BorderFactory.createLineBorder(aoLightTheme[2]));
}
this.setBorder(BorderFactory.createLineBorder(aoLightTheme[2], 3));
}break;
case 1: {
System.out.println("Test");
case 1: { //dark theme
for (JPanel oPanel : oPanels) {
oPanel.setForeground(aoDarkTheme[0]);
oPanel.setBackground(aoDarkTheme[1]);
@@ -247,8 +275,9 @@ public class GUIRegisters extends JPanel {
for (JTextField oTextfield : oTextfields) {
oTextfield.setForeground(aoDarkTheme[0]);
oTextfield.setBackground(aoDarkTheme[1]);
oTextfield.setBorder(BorderFactory.createLineBorder(aoDarkTheme[1]));
oTextfield.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2]));
}
this.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2], 3));
}break;
}
}

View File

@@ -0,0 +1,103 @@
package Frontend.PIC_SIMULATOR_GUI_JAVA;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Color;
public class GUIRegistersDetailed extends JPanel {
JTable oStatusTable;
JTable oOptionTable = new JTable();
JTable oIntconTable = new JTable();
JPanel oStatusPanel = new JPanel();
JPanel oOptionPanel = new JPanel();
JPanel oIntconPanel = new JPanel();
JLabel oStatusLabel = new JLabel("STATUS");
JLabel oOptionLabel = new JLabel("OPTION");
JLabel oIntconLabel = new JLabel("INTCON");
public GUIRegistersDetailed() {
buildGUIRegistersDetailed();
}
private void buildGUIRegistersDetailed() {
this.setLayout(new GridBagLayout());
oStatusPanel.setLayout(new GridBagLayout());
oOptionPanel.setLayout(new GridBagLayout());
oIntconPanel.setLayout(new GridBagLayout());
String[][] asDataStatus = {{"IRP", "RP1", "RP0", "TO", "PD", "Z", "DC", "C"}, {"0", "0", "0", "0", "0", "0", "0", "0"}};
String[] asHeadersStatus = {"0", "1", "2", "3", "4", "5", "6", "7"};
oStatusTable = new JTable(asDataStatus, asHeadersStatus);
oStatusTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
GridBagConstraints oConstraintsStatus = new GridBagConstraints();
oConstraintsStatus.anchor = GridBagConstraints.WEST;
oConstraintsStatus.gridx = 0;
oConstraintsStatus.gridy = 0;
oStatusPanel.add(oStatusLabel, oConstraintsStatus);
oConstraintsStatus.gridy = 1;
oStatusPanel.add(oStatusTable, oConstraintsStatus);
for (int i = 0; i < 8; i++) {
oStatusTable.getColumn(i + "").setMaxWidth(50);
}
oStatusTable.setEnabled(false);
String[][] asDataOption = {{"RBPU", "INTEDG", "T0CS", "T0SE", "PSA", "PS2", "PS1", "PS0"}, {"0", "0", "0", "0", "0", "0", "0", "0"}};
String[] asHeadersOption = {"0", "1", "2", "3", "4", "5", "6", "7"};
oOptionTable = new JTable(asDataOption, asHeadersOption);
oOptionTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
GridBagConstraints oConstraintsOption = new GridBagConstraints();
oConstraintsOption.anchor = GridBagConstraints.WEST;
oConstraintsOption.gridx = 0;
oConstraintsOption.gridy = 0;
oOptionPanel.add(oOptionLabel, oConstraintsOption);
oConstraintsOption.gridy = 1;
oOptionPanel.add(oOptionTable, oConstraintsOption);
for (int i = 0; i < 8; i++) {
oOptionTable.getColumn(i + "").setMaxWidth(50);
}
oOptionTable.setEnabled(false);
String[][] asDataIntcon = {{"GIE", "EEIE", "T0IE", "INTE", "RBIE", "T0IF", "INTF", "RBIF"}, {"0", "0", "0", "0", "0", "0", "0", "0"}};
String[] asHeadersIntcon = {"0", "1", "2", "3", "4", "5", "6", "7"};
oIntconTable = new JTable(asDataIntcon, asHeadersIntcon);
oIntconTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
GridBagConstraints oConstraintsIntcon = new GridBagConstraints();
oConstraintsIntcon.anchor = GridBagConstraints.WEST;
oConstraintsIntcon.gridx = 0;
oConstraintsIntcon.gridy = 0;
oIntconPanel.add(oIntconLabel, oConstraintsIntcon);
oConstraintsIntcon.gridy = 1;
oIntconPanel.add(oIntconTable, oConstraintsIntcon);
for (int i = 0; i < 8; i++) {
oIntconTable.getColumn(i + "").setMaxWidth(50);
}
oIntconTable.setEnabled(false);
GridBagConstraints oConstraints = new GridBagConstraints();
oConstraints.anchor = GridBagConstraints.WEST;
oConstraints.gridx = 0;
oConstraints.gridy = 0;
this.add(oStatusPanel, oConstraints);
oConstraints.gridy = 1;
this.add(oOptionPanel, oConstraints);
oConstraints.gridy = 2;
this.add(oIntconPanel, oConstraints);
this.setBorder(BorderFactory.createLineBorder(Color.BLACK));
}
}

View File

@@ -46,13 +46,13 @@ public class GUITestFileTable extends JScrollPane {
*/
public GUITestFileTable() {
oTable = new JPanel();
oPanels.add(oTable);
JPanel oTestPanel = new JPanel();
JTextField oFill = new JTextField("0");
oLineInformation.add(oFill);
oFill.setEditable(false);
JPanel oTestPanel = new JPanel();
oPanels.add(oTestPanel);
oTestPanel.setLayout(new GridLayout(1, 3));
oTestPanel.add(oFill);
@@ -170,19 +170,19 @@ public class GUITestFileTable extends JScrollPane {
public void setTheme(int iThemeNr) {
iTheme = iThemeNr;
for (int i = 0; i < oLineInformation.size(); i++) {
oLineInformation.get(i).setForeground(getThemeColor()[0]);
oLineInformation.get(i).setBackground(getThemeColor()[1]);
oLineInformation.get(i).setBorder(BorderFactory.createLineBorder(getThemeColor()[2]));
for (JTextField oTextfield : oLineInformation) {
oTextfield.setForeground(getThemeColor()[0]);
oTextfield.setBackground(getThemeColor()[1]);
oTextfield.setBorder(BorderFactory.createLineBorder(getThemeColor()[2]));
}
for (int i = 0; i < oCheckboxes.size(); i++) {
oCheckboxes.get(i).setForeground(getThemeColor()[0]);
oCheckboxes.get(i).setBackground(getThemeColor()[1]);
oCheckboxes.get(i).setBorder(BorderFactory.createLineBorder(getThemeColor()[2]));
for (JCheckBox oCheckbox : oCheckboxes) {
oCheckbox.setForeground(getThemeColor()[0]);
oCheckbox.setBackground(getThemeColor()[1]);
oCheckbox.setBorder(BorderFactory.createLineBorder(getThemeColor()[2]));
}
for (int i = 0; i < oPanels.size(); i++) {
oPanels.get(i).setForeground(getThemeColor()[0]);
oPanels.get(i).setBackground(getThemeColor()[1]);
for (JPanel oPanel : oPanels) {
oPanel.setForeground(getThemeColor()[0]);
oPanel.setBackground(getThemeColor()[1]);
}
oTable.setForeground(getThemeColor()[0]);