From 55595ba928ea6434939f69bceebe03616176d4ee Mon Sep 17 00:00:00 2001
From: Lucas Stratmann <lucas.stratmann@student.reutlingen-university.de>
Date: Mon, 31 Aug 2020 13:50:45 +0200
Subject: [PATCH] Changed Iconpaths

---
 .../ardublock/simulator/Simulator.java        |  4 ++--
 .../ardublock/simulator/view/GUI.java         | 16 +++++++--------
 .../simulator/view/modules/ArduinoUno.java    |  6 ++++--
 .../simulator/view/modules/Button.java        | 20 ++++++++++---------
 .../simulator/view/modules/Modul.java         |  4 +++-
 .../simulator/view/modules/Poti.java          |  4 ++--
 .../ardublock/simulator/view/modules/RGB.java |  4 ++--
 7 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/src/tec/letsgoing/ardublock/simulator/Simulator.java b/src/tec/letsgoing/ardublock/simulator/Simulator.java
index c6105d4..bd49df0 100644
--- a/src/tec/letsgoing/ardublock/simulator/Simulator.java
+++ b/src/tec/letsgoing/ardublock/simulator/Simulator.java
@@ -80,7 +80,7 @@ public class Simulator implements Runnable, ActionListener {
 
 	@Override
 	public void run() {
-		arduino.digitalWrite(20, true); // Power ON LED
+		arduino.getPin(20).setValue(1023); // Power ON LED
 		arduino.setStop(false);
 
 		arduino.getFunction("main").run(arduino, null);
@@ -95,7 +95,7 @@ public class Simulator implements Runnable, ActionListener {
 			simuThread.interrupt();
 
 		}
-		arduino.digitalWrite(20, false);
+		arduino.getPin(20).setValue(0);
 
 	}
 
diff --git a/src/tec/letsgoing/ardublock/simulator/view/GUI.java b/src/tec/letsgoing/ardublock/simulator/view/GUI.java
index 82d56eb..1a34d16 100644
--- a/src/tec/letsgoing/ardublock/simulator/view/GUI.java
+++ b/src/tec/letsgoing/ardublock/simulator/view/GUI.java
@@ -46,10 +46,10 @@ public class GUI extends JFrame implements Runnable, ActionListener {
 	public GUI(Simulator simu) {
 		super("ArdubBlock Simulator");
 		// TODO Module geben Pin Positionen
-		modules[0] = new RGB();
-		modules[1] = new Button();
-		modules[2] = new Poti();
-		modules[3] = new ArduinoUno();
+		modules[0] = new RGB(new ImageIcon(getToolkit().getImage(GUI.class.getResource("/img/PM31_RGB_LED.png"))));
+		modules[1] = new Button(new ImageIcon(getToolkit().getImage(GUI.class.getResource("/img/PM26_Taster.png"))),new ImageIcon(getToolkit().getImage(GUI.class.getResource("/img/Taster_Off.png"))),new ImageIcon(getToolkit().getImage(GUI.class.getResource("/img/Taster_On.png"))));
+		modules[2] = new Poti(new ImageIcon(getToolkit().getImage(GUI.class.getResource("/img/PM24_Potentiometer.png"))));
+		modules[3] = new ArduinoUno(new ImageIcon(getToolkit().getImage(GUI.class.getResource("/img/ArduinoUno.png"))));
 
 		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 		this.setResizable(false);
@@ -88,10 +88,10 @@ public class GUI extends JFrame implements Runnable, ActionListener {
 		reloadButton.setIcon(new ImageIcon(getToolkit().getImage(GUI.class.getResource("/img/Reload.png"))));
 		measButton.setIcon(new ImageIcon(getToolkit().getImage(GUI.class.getResource("/img/Measure.png"))));
 		
-		//goButton.setIcon(new ImageIcon("res/Play.png"));
-		//stopButton.setIcon(new ImageIcon("res/Stop.png"));
-		//reloadButton.setIcon(new ImageIcon("res/Reload.png"));
-		//measButton.setIcon(new ImageIcon("res/Measure.png"));
+//		goButton.setIcon(new ImageIcon("res/img/Play.png"));
+//		stopButton.setIcon(new ImageIcon("res/img/Stop.png"));
+//		reloadButton.setIcon(new ImageIcon("res/img/Reload.png"));
+//		measButton.setIcon(new ImageIcon("res/img/Measure.png"));
 
 		goButton.addActionListener(simu);
 		stopButton.addActionListener(simu);
diff --git a/src/tec/letsgoing/ardublock/simulator/view/modules/ArduinoUno.java b/src/tec/letsgoing/ardublock/simulator/view/modules/ArduinoUno.java
index 369a977..cc8d31a 100644
--- a/src/tec/letsgoing/ardublock/simulator/view/modules/ArduinoUno.java
+++ b/src/tec/letsgoing/ardublock/simulator/view/modules/ArduinoUno.java
@@ -15,6 +15,7 @@ import javax.swing.JLabel;
 
 import tec.letsgoing.ardublock.simulator.arduino.Arduino;
 import tec.letsgoing.ardublock.simulator.arduino.Pin;
+import tec.letsgoing.ardublock.simulator.view.GUI;
 
 /**
  * @author Lucas
@@ -25,11 +26,12 @@ public class ArduinoUno extends Modul {
 	private boolean ledOn;
 	private int led13 = 0;
 
-	public ArduinoUno() {
+	public ArduinoUno(ImageIcon _icon) {
+		
 		// TODO Arduino mittig anordnen
 		layerpane.setPreferredSize(new Dimension(587, 418));
 		JLabel chiplabel = new JLabel();
-		ImageIcon chipIcon = new ImageIcon("res/ArduinoUno.png");
+		ImageIcon chipIcon = _icon;
 		chipIcon = new ImageIcon(chipIcon.getImage().getScaledInstance(587, 418, Image.SCALE_SMOOTH));
 		chiplabel.setIcon(chipIcon);
 		chiplabel.setSize(587, 418);
diff --git a/src/tec/letsgoing/ardublock/simulator/view/modules/Button.java b/src/tec/letsgoing/ardublock/simulator/view/modules/Button.java
index 009c2ff..5a81295 100644
--- a/src/tec/letsgoing/ardublock/simulator/view/modules/Button.java
+++ b/src/tec/letsgoing/ardublock/simulator/view/modules/Button.java
@@ -19,18 +19,21 @@ import tec.letsgoing.ardublock.simulator.arduino.Pin;
  */
 public class Button extends Modul implements ActionListener {
 	private int[] lastState = { 0, 0, 0 };
+	private ImageIcon iconOff,iconOn;
 
-	public Button() {
+	public Button(ImageIcon _icon, ImageIcon _icon1, ImageIcon _icon2) {
+		iconOff=_icon1;
+		iconOn=_icon2;
 		layerpane.setPreferredSize(new Dimension(294, 294));
 		JLabel chiplabel = new JLabel();
-		ImageIcon chipIcon = new ImageIcon("res/PM26_Taster.png");
+		ImageIcon chipIcon =_icon;
 		chiplabel.setIcon(chipIcon);
 		chiplabel.setSize(294, 294);
 		layerpane.add(chiplabel, 0);
 
 		JToggleButton but1 = new JToggleButton();
 		but1.setSize(70, 70);
-		but1.setIcon(new ImageIcon("res/Taster_Off.png"));
+		but1.setIcon(iconOff);
 		but1.setActionCommand("0");
 		but1.addActionListener(this);
 		JLabel label1 = new JLabel();
@@ -40,7 +43,7 @@ public class Button extends Modul implements ActionListener {
 
 		JToggleButton but2 = new JToggleButton();
 		but2.setSize(70, 70);
-		but2.setIcon(new ImageIcon("res/Taster_Off.png"));
+		but2.setIcon(iconOff);
 		but2.setActionCommand("1");
 		but2.addActionListener(this);
 		JLabel label2 = new JLabel();
@@ -50,7 +53,7 @@ public class Button extends Modul implements ActionListener {
 
 		JToggleButton but3 = new JToggleButton();
 		but3.setSize(70, 70);
-		but3.setIcon(new ImageIcon("res/Taster_Off.png"));
+		but3.setIcon(iconOff);
 		but3.setActionCommand("2");
 		but3.addActionListener(this);
 		JLabel label3 = new JLabel();
@@ -96,13 +99,12 @@ public class Button extends Modul implements ActionListener {
 	public void actionPerformed(ActionEvent arg0) {
 		Integer pin = Integer.parseInt(arg0.getActionCommand());
 		boolean bool = ((JToggleButton) arg0.getSource()).isSelected();
-		String path;
 		if (bool) {
-			path = "res/Taster_On.png";
+			((JToggleButton) arg0.getSource()).setIcon(iconOn);
 		} else {
-			path = "res/Taster_Off.png";
+			((JToggleButton) arg0.getSource()).setIcon(iconOff);
 		}
-		((JToggleButton) arg0.getSource()).setIcon(new ImageIcon(path));
+		
 		int value = 0;
 		if (bool)
 			value = 1023;
diff --git a/src/tec/letsgoing/ardublock/simulator/view/modules/Modul.java b/src/tec/letsgoing/ardublock/simulator/view/modules/Modul.java
index 2b46547..d94708c 100644
--- a/src/tec/letsgoing/ardublock/simulator/view/modules/Modul.java
+++ b/src/tec/letsgoing/ardublock/simulator/view/modules/Modul.java
@@ -9,6 +9,7 @@ import java.util.Observer;
 import java.util.Vector;
 
 import javax.swing.JLayeredPane;
+import javax.swing.JPanel;
 
 import tec.letsgoing.ardublock.simulator.arduino.Arduino;
 import tec.letsgoing.ardublock.simulator.arduino.Pin;
@@ -17,7 +18,7 @@ import tec.letsgoing.ardublock.simulator.arduino.Pin;
  * @author Lucas
  *
  */
-public abstract class Modul implements Observer {
+public abstract class Modul extends JPanel implements Observer  {
 	private boolean active = true;
 	private Point position;
 	protected Vector<Pin> pins = new Vector<Pin>();
@@ -46,6 +47,7 @@ public abstract class Modul implements Observer {
 					updateModul((Pin) Observable);
 			}
 		}
+		
 	}
 
 	public abstract void updateModul(Pin pin);
diff --git a/src/tec/letsgoing/ardublock/simulator/view/modules/Poti.java b/src/tec/letsgoing/ardublock/simulator/view/modules/Poti.java
index 5df162a..2ab4e96 100644
--- a/src/tec/letsgoing/ardublock/simulator/view/modules/Poti.java
+++ b/src/tec/letsgoing/ardublock/simulator/view/modules/Poti.java
@@ -17,10 +17,10 @@ import tec.letsgoing.ardublock.simulator.arduino.Pin;
 public class Poti extends Modul {
 	int value = 0;
 
-	public Poti() {
+	public Poti(ImageIcon _icon) {
 		layerpane.setPreferredSize(new Dimension(294, 294));
 		JLabel chiplabel = new JLabel();
-		ImageIcon chipIcon = new ImageIcon("res/PM24_Potentiometer.png");
+		ImageIcon chipIcon = _icon;
 		chiplabel.setIcon(chipIcon);
 		chiplabel.setSize(294, 294);
 		layerpane.add(chiplabel, 1);
diff --git a/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java b/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java
index 0154903..8ee84cd 100644
--- a/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java
+++ b/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java
@@ -22,10 +22,10 @@ public class RGB extends Modul {
 	private int greenValue = 0;
 	private int blueValue = 0;
 
-	public RGB() {
+	public RGB(ImageIcon _icon) {
 		layerpane.setPreferredSize(new Dimension(294, 294));
 		JLabel chiplabel = new JLabel();
-		ImageIcon chipIcon = new ImageIcon("res/PM31_RGB_LED.png");
+		ImageIcon chipIcon = _icon;
 		chiplabel.setIcon(chipIcon);
 		chiplabel.setSize(294, 294);
 		layerpane.add(chiplabel, 1);
-- 
GitLab