Skip to content
Snippets Groups Projects
Commit 55595ba9 authored by Lucas Stratmann's avatar Lucas Stratmann
Browse files

Changed Iconpaths

parent 0a382c95
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment