21d4c59681153e8308a5b144c2f2dd1495e0dbc7
[Mograsim.git] / net.mograsim.logic.ui.am2900 / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUIor4.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.SimpleRectangularSubmodelComponent;
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 GUIor4 extends SimpleRectangularSubmodelComponent
12 {
13         public GUIor4(ViewModelModifiable model)
14         {
15                 super(model, 1, "GUIor4");
16                 setSubmodelScale(.2);
17                 setInputPins("A1", "A2", "A3", "A4");
18                 setOutputPins("Y");
19                 initSubmodelComponents();
20         }
21
22         @SuppressWarnings("unused") // for GUIWires being created
23         private void initSubmodelComponents()
24         {
25                 Pin A1 = getSubmodelPin("A1");
26                 Pin A2 = getSubmodelPin("A2");
27                 Pin A3 = getSubmodelPin("A3");
28                 Pin A4 = getSubmodelPin("A4");
29                 Pin Y = getSubmodelPin("Y");
30
31                 GUINandGate nandA1 = new GUINandGate(submodelModifiable, 1);
32                 GUINandGate nandA2 = new GUINandGate(submodelModifiable, 1);
33                 GUINandGate nandA3 = new GUINandGate(submodelModifiable, 1);
34                 GUINandGate nandA4 = new GUINandGate(submodelModifiable, 1);
35                 GUINandGate or12 = new GUINandGate(submodelModifiable, 1);
36                 GUINandGate or34 = new GUINandGate(submodelModifiable, 1);
37                 GUINandGate nor12 = new GUINandGate(submodelModifiable, 1);
38                 GUINandGate nor34 = new GUINandGate(submodelModifiable, 1);
39                 GUINandGate or1234 = new GUINandGate(submodelModifiable, 1);
40
41                 WireCrossPoint cpA1 = new WireCrossPoint(submodelModifiable, 1);
42                 WireCrossPoint cpA2 = new WireCrossPoint(submodelModifiable, 1);
43                 WireCrossPoint cpA3 = new WireCrossPoint(submodelModifiable, 1);
44                 WireCrossPoint cpA4 = new WireCrossPoint(submodelModifiable, 1);
45                 WireCrossPoint cpOr12 = new WireCrossPoint(submodelModifiable, 1);
46                 WireCrossPoint cpOr34 = new WireCrossPoint(submodelModifiable, 1);
47
48                 nandA1.moveTo(20, 15);
49                 nandA2.moveTo(20, 65);
50                 nandA3.moveTo(20, 115);
51                 nandA4.moveTo(20, 165);
52                 or12.moveTo(50, 40);
53                 or34.moveTo(50, 140);
54                 nor12.moveTo(110, 40);
55                 nor34.moveTo(110, 140);
56                 or1234.moveTo(140, 90);
57                 cpA1.moveCenterTo(15, 25);
58                 cpA2.moveCenterTo(15, 75);
59                 cpA3.moveCenterTo(15, 125);
60                 cpA4.moveCenterTo(15, 175);
61                 cpOr12.moveCenterTo(105, 50);
62                 cpOr34.moveCenterTo(105, 150);
63
64                 new GUIWire(submodelModifiable, A1, cpA1, new Point[0]);
65                 new GUIWire(submodelModifiable, A2, cpA2, new Point[0]);
66                 new GUIWire(submodelModifiable, A3, cpA3, new Point[0]);
67                 new GUIWire(submodelModifiable, A4, cpA4, new Point[0]);
68                 new GUIWire(submodelModifiable, cpA1, nandA1.getPin("A"), new Point(15, 20));
69                 new GUIWire(submodelModifiable, cpA2, nandA2.getPin("A"), new Point(15, 70));
70                 new GUIWire(submodelModifiable, cpA3, nandA3.getPin("A"), new Point(15, 120));
71                 new GUIWire(submodelModifiable, cpA4, nandA4.getPin("A"), new Point(15, 170));
72                 new GUIWire(submodelModifiable, cpA1, nandA1.getPin("B"), new Point(15, 30));
73                 new GUIWire(submodelModifiable, cpA2, nandA2.getPin("B"), new Point(15, 80));
74                 new GUIWire(submodelModifiable, cpA3, nandA3.getPin("B"), new Point(15, 130));
75                 new GUIWire(submodelModifiable, cpA4, nandA4.getPin("B"), new Point(15, 180));
76                 new GUIWire(submodelModifiable, nandA1.getPin("Y"), or12.getPin("A"));
77                 new GUIWire(submodelModifiable, nandA2.getPin("Y"), or12.getPin("B"));
78                 new GUIWire(submodelModifiable, nandA3.getPin("Y"), or34.getPin("A"));
79                 new GUIWire(submodelModifiable, nandA4.getPin("Y"), or34.getPin("B"));
80                 new GUIWire(submodelModifiable, or12.getPin("Y"), cpOr12, new Point[0]);
81                 new GUIWire(submodelModifiable, or34.getPin("Y"), cpOr34, new Point[0]);
82                 new GUIWire(submodelModifiable, cpOr12, nor12.getPin("A"), new Point(105, 45));
83                 new GUIWire(submodelModifiable, cpOr12, nor12.getPin("B"), new Point(105, 55));
84                 new GUIWire(submodelModifiable, cpOr34, nor34.getPin("A"), new Point(105, 145));
85                 new GUIWire(submodelModifiable, cpOr34, nor34.getPin("B"), new Point(105, 155));
86                 new GUIWire(submodelModifiable, nor12.getPin("Y"), or1234.getPin("A"));
87                 new GUIWire(submodelModifiable, nor34.getPin("Y"), or1234.getPin("B"));
88                 new GUIWire(submodelModifiable, or1234.getPin("Y"), Y);
89         }
90 }