Added convenience constructors in GUIWire
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUIand.java
1 package net.mograsim.logic.ui.model.components.mi.nandbased;
2
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.ui.model.ViewModelModifiable;
5 import net.mograsim.logic.ui.model.components.GUINandGate;
6 import net.mograsim.logic.ui.model.components.SubmodelComponent;
7 import net.mograsim.logic.ui.model.wires.GUIWire;
8 import net.mograsim.logic.ui.model.wires.Pin;
9 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
10
11 public class GUIand extends SubmodelComponent
12 {
13         private final Pin pinA;
14         private final Pin pinB;
15         private final Pin pinY;
16
17         public GUIand(ViewModelModifiable model)
18         {
19                 super(model, "GUIand");
20                 setSize(35, 25);
21                 setSubmodelScale(.4);
22
23                 Pin A = addSubmodelInterface(1, 0, 5);
24                 Pin B = addSubmodelInterface(1, 0, 20);
25                 Pin Y = addSubmodelInterface(1, 35, 12.5);
26
27                 this.pinA = getSupermodelPin(A);
28                 this.pinB = getSupermodelPin(B);
29                 this.pinY = getSupermodelPin(Y);
30
31                 initSubmodelComponents(A, B, Y);
32         }
33
34         @SuppressWarnings("unused") // for GUIWires being created
35         private void initSubmodelComponents(Pin A, Pin B, Pin Y)
36         {
37                 GUINandGate nand = new GUINandGate(submodelModifiable, 1);
38                 GUINandGate not = new GUINandGate(submodelModifiable, 1);
39
40                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
41
42                 nand.moveTo(20, 21.25);
43                 not.moveTo(50, 21.25);
44                 cp1.moveTo(45, 31.25);
45
46                 new GUIWire(submodelModifiable, A, nand.getInputPins().get(0), new Point(10, 12.5), new Point(10, 26.25));
47                 new GUIWire(submodelModifiable, B, nand.getInputPins().get(1), new Point(10, 50), new Point(10, 36.25));
48                 new GUIWire(submodelModifiable, nand.getOutputPin(), cp1);
49                 new GUIWire(submodelModifiable, cp1, not.getInputPins().get(0), new Point(45, 26.25));
50                 new GUIWire(submodelModifiable, cp1, not.getInputPins().get(1), new Point(45, 36.25));
51                 new GUIWire(submodelModifiable, not.getOutputPin(), Y);
52         }
53
54         public Pin getPinA()
55         {
56                 return pinA;
57         }
58
59         public Pin getPinB()
60         {
61                 return pinB;
62         }
63
64         public Pin getPinY()
65         {
66                 return pinY;
67         }
68
69 }