SimpleRectangularSubmodelComponent now supports pin names
[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.SimpleRectangularSubmodelComponent;
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 SimpleRectangularSubmodelComponent
11 {
12         public GUIdlatch4(ViewModelModifiable model)
13         {
14                 super(model, 1, "GUIdlatch4");
15                 setSubmodelScale(.4);
16                 setInputPins("D1", "D2", "D3", "D4", "C");
17                 setOutputPins("Q1", "Q2", "Q3", "Q4");
18                 initSubmodelComponents();
19         }
20
21         @SuppressWarnings("unused") // for GUIWires being created
22         private void initSubmodelComponents()
23         {
24                 Pin D1 = getInputSubmodelPins().get(0);
25                 Pin D2 = getInputSubmodelPins().get(1);
26                 Pin D3 = getInputSubmodelPins().get(2);
27                 Pin D4 = getInputSubmodelPins().get(3);
28                 Pin C = getInputSubmodelPins().get(4);
29                 Pin Q1 = getOutputSubmodelPins().get(0);
30                 Pin Q2 = getOutputSubmodelPins().get(1);
31                 Pin Q3 = getOutputSubmodelPins().get(2);
32                 Pin Q4 = getOutputSubmodelPins().get(3);
33
34                 GUIdlatch dlatch1 = new GUIdlatch(submodelModifiable);
35                 GUIdlatch dlatch2 = new GUIdlatch(submodelModifiable);
36                 GUIdlatch dlatch3 = new GUIdlatch(submodelModifiable);
37                 GUIdlatch dlatch4 = new GUIdlatch(submodelModifiable);
38
39                 WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1);
40                 WireCrossPoint cp3 = new WireCrossPoint(submodelModifiable, 1);
41                 WireCrossPoint cp4 = new WireCrossPoint(submodelModifiable, 1);
42
43                 dlatch1.moveTo(30, 7.5);
44                 dlatch2.moveTo(30, 32.5);
45                 dlatch3.moveTo(30, 57.5);
46                 dlatch4.moveTo(30, 82.5);
47                 cp2.moveCenterTo(15, 47.5);
48                 cp3.moveCenterTo(15, 72.5);
49                 cp4.moveCenterTo(15, 97.5);
50
51                 new GUIWire(submodelModifiable, C, cp4, new Point(15, 112.5));
52                 new GUIWire(submodelModifiable, cp4, dlatch4.getInputPins().get(1), new Point[0]);
53                 new GUIWire(submodelModifiable, cp4, cp3, new Point[0]);
54                 new GUIWire(submodelModifiable, cp3, dlatch3.getInputPins().get(1), new Point[0]);
55                 new GUIWire(submodelModifiable, cp3, cp2, new Point[0]);
56                 new GUIWire(submodelModifiable, cp2, dlatch2.getInputPins().get(1), new Point[0]);
57                 new GUIWire(submodelModifiable, cp2, dlatch1.getInputPins().get(1), new Point(15, 22.5));
58                 new GUIWire(submodelModifiable, D1, dlatch1.getInputPins().get(0), new Point[0]);
59                 new GUIWire(submodelModifiable, D2, dlatch2.getInputPins().get(0), new Point[0]);
60                 new GUIWire(submodelModifiable, D3, dlatch3.getInputPins().get(0), new Point[0]);
61                 new GUIWire(submodelModifiable, D4, dlatch4.getInputPins().get(0), new Point[0]);
62                 new GUIWire(submodelModifiable, dlatch1.getOutputPins().get(0), Q1, new Point[0]);
63                 new GUIWire(submodelModifiable, dlatch2.getOutputPins().get(0), Q2, new Point[0]);
64                 new GUIWire(submodelModifiable, dlatch3.getOutputPins().get(0), Q3, new Point[0]);
65                 new GUIWire(submodelModifiable, dlatch4.getOutputPins().get(0), Q4, new Point[0]);
66         }
67 }