-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
49 lines (40 loc) · 1.09 KB
/
Node.java
File metadata and controls
49 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
import java.awt.Graphics2D;
public class Node extends Part {
public Node(String name, int x, int y, int width, int height) {
super(name, x, y, width, height, -1, -1);
}
public Node(Node n) {
super(n);
}
public Node clone() {
return new Node(this);
}
@Override
public void draw(Graphics2D g) {
g.setColor(state ? Main.onState_Led : Main.nodeColor);
g.fillOval(x, y, width, height);
}
@Override
public boolean[] getBooleanOutputs(boolean[] in) {
state = false;
for (Wire w : inputs) {
if (w.state) {
state = true;
break;
}
}
boolean[] out = new boolean[outputs.size()];
for (int i = 0; i < outputs.size(); i++) {
out[i] = state;
}
return out;
}
@Override
public int[] getOutputNode(Wire w){
return new int[] {(int) x + width/2, (int) y + height/2};
}
@Override
public int[] getInputNode(Wire w){
return new int[] {(int) x + width/2, (int) y + height/2};
}
}