-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.java
More file actions
51 lines (40 loc) · 1.09 KB
/
Input.java
File metadata and controls
51 lines (40 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.awt.Graphics2D;
public class Input extends Part {
public Input(String name, int x, int y, int width, int height, boolean state) {
super(name, x, y, width, height, 0, -1);
}
public Input(Input s) {
super(s);
}
public Input clone() {
return new Input(this);
}
@Override
public void onDoubleClick() {
changeName();
}
@Override
public void draw(Graphics2D g) {
g.setColor(state ? Main.switch_On : Main.switch_Off);
g.fillOval(x, y, width, height);
g.setColor(Main.nodeColor);
g.drawOval(x, y, width, height);
drawText(g);
}
@Override
public boolean[] getBooleanOutputs(boolean[] in) {
boolean[] out = new boolean[outputs.size()];
for (int i = 0; i < outputs.size(); i++) {
out[i] = state;
}
return out;
}
@Override
public void onClick() {
state = !state;
}
@Override
public int[] getOutputNode(Wire w){
return new int[] {(int) x + width/2, (int) y + height/2};
}
}