diff --git a/src/tec/letsgoing/ardublock/simulator/Simulator.java b/src/tec/letsgoing/ardublock/simulator/Simulator.java index c6105d4266bf13dfaeb24dba1cd658f6e5479a24..bd49df03f03292bae7bba16791179601d09f1d13 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 82d56eb0c33456efbe56bbab299f2c29d409ba2f..1a34d16f7632fdff6bbb6ae8290fb92a1208034c 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 369a97715431fb3f185a0b3b8423ea7660dd3f26..cc8d31acd592768cd79d7e57065cf55d5598be4c 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 009c2ff94f714cf84c7bb7a7295e56f7f0a94ebf..5a81295d431a27d10d38e71c26bfcbddd4bf2194 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 2b46547d24d705e3528e9e7b965bc567a1a1a012..d94708ca3574ee00db2a09f47fe694e1e3d59171 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 5df162a5502c55918583795cce3fdfab2f8e2671..2ab4e96b0862899383b0ddd10c2b3bde6edd42ad 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 0154903de96968d0670a74efbaaf5c8fc254cf75..8ee84cd336eb52d59220edbd7b0580b37aae69df 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);