Added convenience constructors in GUIWire
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUIdlatch4.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.SubmodelComponent;
6 import net.mograsim.logic.ui.model.wires.GUIWire;
7 import net.mograsim.logic.ui.model.wires.Pin;
8 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
9
10 public class GUIdlatch4 extends SubmodelComponent
11 {
12         private final Pin pinD1;
13         private final Pin pinD2;
14         private final Pin pinD3;
15         private final Pin pinD4;
16         private final Pin pinC;
17         private final Pin pinQ1;
18         private final Pin pinQ2;
19         private final Pin pinQ3;
20         private final Pin pinQ4;
21
22         public GUIdlatch4(ViewModelModifiable model)
23         {
24                 super(model, "GUIdlatch4");
25                 setSize(35, 55);
26                 setSubmodelScale(.4);
27
28                 Pin D1 = addSubmodelInterface(1, 0, 5);
29                 Pin D2 = addSubmodelInterface(1, 0, 15);
30                 Pin D3 = addSubmodelInterface(1, 0, 25);
31                 Pin D4 = addSubmodelInterface(1, 0, 35);
32                 Pin C = addSubmodelInterface(1, 0, 50);
33                 Pin Q1 = addSubmodelInterface(1, 35, 5);
34                 Pin Q2 = addSubmodelInterface(1, 35, 15);
35                 Pin Q3 = addSubmodelInterface(1, 35, 25);
36                 Pin Q4 = addSubmodelInterface(1, 35, 35);
37
38                 this.pinC = getSupermodelPin(C);
39                 this.pinD1 = getSupermodelPin(D1);
40                 this.pinD2 = getSupermodelPin(D2);
41                 this.pinD3 = getSupermodelPin(D3);
42                 this.pinD4 = getSupermodelPin(D4);
43                 this.pinQ1 = getSupermodelPin(Q1);
44                 this.pinQ2 = getSupermodelPin(Q2);
45                 this.pinQ3 = getSupermodelPin(Q3);
46                 this.pinQ4 = getSupermodelPin(Q4);
47
48                 initSubmodelComponents(C, D1, D2, D3, D4, Q1, Q2, Q3, Q4);
49         }
50
51         @SuppressWarnings("unused") // for GUIWires being created
52         private void initSubmodelComponents(Pin C, Pin D1, Pin D2, Pin D3, Pin D4, Pin Q1, Pin Q2, Pin Q3, Pin Q4)
53         {
54                 GUIdlatch dlatch1 = new GUIdlatch(submodelModifiable);
55                 GUIdlatch dlatch2 = new GUIdlatch(submodelModifiable);
56                 GUIdlatch dlatch3 = new GUIdlatch(submodelModifiable);
57                 GUIdlatch dlatch4 = new GUIdlatch(submodelModifiable);
58
59                 WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1);
60                 WireCrossPoint cp3 = new WireCrossPoint(submodelModifiable, 1);
61                 WireCrossPoint cp4 = new WireCrossPoint(submodelModifiable, 1);
62
63                 dlatch1.moveTo(30, 7.5);
64                 dlatch2.moveTo(30, 32.5);
65                 dlatch3.moveTo(30, 57.5);
66                 dlatch4.moveTo(30, 82.5);
67                 cp2.moveTo(15, 52.5);
68                 cp3.moveTo(15, 77.5);
69                 cp4.moveTo(15, 102.5);
70
71                 new GUIWire(submodelModifiable, C, cp4, new Point(15, 125));
72                 new GUIWire(submodelModifiable, cp4, dlatch4.getPinE());
73                 new GUIWire(submodelModifiable, cp4, cp3);
74                 new GUIWire(submodelModifiable, cp3, dlatch3.getPinE());
75                 new GUIWire(submodelModifiable, cp3, cp2);
76                 new GUIWire(submodelModifiable, cp2, dlatch2.getPinE());
77                 new GUIWire(submodelModifiable, cp2, dlatch1.getPinE(), new Point(15, 27.5));
78                 new GUIWire(submodelModifiable, D1, dlatch1.getPinD());
79                 new GUIWire(submodelModifiable, D2, dlatch2.getPinD());
80                 new GUIWire(submodelModifiable, D3, dlatch3.getPinD());
81                 new GUIWire(submodelModifiable, D4, dlatch4.getPinD());
82                 new GUIWire(submodelModifiable, dlatch1.getPinQ(), Q1);
83                 new GUIWire(submodelModifiable, dlatch2.getPinQ(), Q2);
84                 new GUIWire(submodelModifiable, dlatch3.getPinQ(), Q3);
85                 new GUIWire(submodelModifiable, dlatch4.getPinQ(), Q4);
86         }
87
88         public Pin getPinC()
89         {
90                 return pinC;
91         }
92
93         public Pin getPinD1()
94         {
95                 return pinD1;
96         }
97
98         public Pin getPinD2()
99         {
100                 return pinD2;
101         }
102
103         public Pin getPinD3()
104         {
105                 return pinD3;
106         }
107
108         public Pin getPinD4()
109         {
110                 return pinD4;
111         }
112
113         public Pin getPinQ1()
114         {
115                 return pinQ1;
116         }
117
118         public Pin getPinQ2()
119         {
120                 return pinQ2;
121         }
122
123         public Pin getPinQ3()
124         {
125                 return pinQ3;
126         }
127
128         public Pin getPinQ4()
129         {
130                 return pinQ4;
131         }
132 }