diff --git a/src/tec/letsgoing/ardublock/simulator/view/GUI.java b/src/tec/letsgoing/ardublock/simulator/view/GUI.java index afd1f9a91f03947add0b56be8f6ef2d8306547a9..30a83ad0fc82c6959dbce82a6bb788e8acf06965 100644 --- a/src/tec/letsgoing/ardublock/simulator/view/GUI.java +++ b/src/tec/letsgoing/ardublock/simulator/view/GUI.java @@ -135,16 +135,16 @@ public class GUI extends JFrame implements Runnable, ActionListener { @Override public void componentResized(ComponentEvent e) { + if(Math.abs(WindowHeight - getHeight()) > 30 || Math.abs(WindowWidth - getWidth()) > 30) { - - - - + System.out.println("boom.."); WindowHeight = getHeight(); WindowWidth = getWidth(); topPanelWidth = topPanel.getWidth(); topPanelHeight = topPanel.getHeight(); + + if(topPanelWidth <= ((topPanelHeight + WindowHeight) / 2)) { xscale = topPanelWidth; @@ -158,7 +158,7 @@ public class GUI extends JFrame implements Runnable, ActionListener { updateGUI(xscale, yscale); //} - + } } diff --git a/src/tec/letsgoing/ardublock/simulator/view/modules/Button.java b/src/tec/letsgoing/ardublock/simulator/view/modules/Button.java index 1da3b5c5bcf0cfa5f77734d1b593b9595ffed749..bfd6ea43b329dcec6c3572819608ef5b514b2b23 100644 --- a/src/tec/letsgoing/ardublock/simulator/view/modules/Button.java +++ b/src/tec/letsgoing/ardublock/simulator/view/modules/Button.java @@ -26,7 +26,7 @@ import tec.letsgoing.ardublock.simulator.view.GUI; */ public class Button extends Modul implements ActionListener { private int[] lastState = { 0, 0, 0 }; - private ImageIcon iconOff, iconOn, chipIcon, chipIcon_temp; + private ImageIcon iconOff, iconOn, chipIcon, chipIcon_temp, iconOff_temp, iconOn_temp; private JToggleButton but1, but2, but3; private JLabel chiplabel, label1, label2, label3; private int xscale = GUI.getxscale(); @@ -36,21 +36,23 @@ public class Button extends Modul implements ActionListener { chipIcon = _icon; iconOff = _icon1; iconOn = _icon2; + iconOff_temp = iconOff; + iconOn_temp = iconOn; chiplabel = new JLabel(); but1 = new JToggleButton(); - but1.setIcon(iconOff); + but1.setIcon(iconOff_temp); but1.setActionCommand("0"); but1.addActionListener(this); but2 = new JToggleButton(); - but2.setIcon(iconOff); + but2.setIcon(iconOff_temp); but2.setActionCommand("1"); but2.addActionListener(this); but3 = new JToggleButton(); - but3.setIcon(iconOff); + but3.setIcon(iconOff_temp); but3.setActionCommand("2"); but3.addActionListener(this); @@ -79,13 +81,40 @@ public class Button extends Modul implements ActionListener { chipIcon_temp = new ImageIcon(chipIcon.getImage().getScaledInstance(((int)(0.3037*xscale)), ((int)(0.304*yscale)), Image.SCALE_SMOOTH)); chiplabel.setIcon(chipIcon_temp); chiplabel.setSize(((int)(0.3037*xscale)), ((int)(0.304*yscale))); - layerpane.add(chiplabel, 0); + but1.setSize(((int)(0.0723*xscale)), ((int)(0.0724*yscale))); + label1.setSize(((int)(0.0723*xscale)), ((int)(0.0724*yscale))); label1.setLocation(((int)(0.02996*xscale)), ((int)(0.06618*yscale))); + + + iconOff_temp = new ImageIcon(iconOff.getImage().getScaledInstance(((int)(0.0723*xscale)), ((int)(0.0724*yscale)), Image.SCALE_SMOOTH)); + iconOn_temp = new ImageIcon(iconOn.getImage().getScaledInstance(((int)(0.0723*xscale)), ((int)(0.0724*yscale)), Image.SCALE_SMOOTH)); + //Abfrage ob der jeweilige Button im moment gedrückt wurde oder nicht und dementsprechend wird das gas gezoomte icon gesetzt + if(!but1.isSelected()) + but1.setIcon(iconOff_temp); + else + but1.setIcon(iconOn_temp); + + + + + if(!but2.isSelected()) + but2.setIcon(iconOff_temp); + else + but2.setIcon(iconOn_temp); + + + + if(!but3.isSelected()) + but3.setIcon(iconOff_temp); + else + but3.setIcon(iconOn_temp); + + but2.setSize(((int)(0.0723*xscale)), ((int)(0.0724*yscale))); @@ -100,6 +129,7 @@ public class Button extends Modul implements ActionListener { label1.add(but1); label2.add(but2); label3.add(but3); + layerpane.add(chiplabel, 0); layerpane.add(label1, 0); layerpane.add(label2, 0); layerpane.add(label3, 0); @@ -141,9 +171,9 @@ public class Button extends Modul implements ActionListener { Integer pin = Integer.parseInt(arg0.getActionCommand()); boolean bool = ((JToggleButton) arg0.getSource()).isSelected(); if (bool) { - ((JToggleButton) arg0.getSource()).setIcon(iconOn); + ((JToggleButton) arg0.getSource()).setIcon(iconOn_temp); } else { - ((JToggleButton) arg0.getSource()).setIcon(iconOff); + ((JToggleButton) arg0.getSource()).setIcon(iconOff_temp); } int value = 0;