SimpleRectangularSubmodelComponent now supports pin names
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUIxor.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 GUIxor extends SimpleRectangularSubmodelComponent
12 {
13         public GUIxor(ViewModelModifiable model)
14         {
15                 super(model, 1, "GUIxor");
16                 setSubmodelScale(.4);
17                 setInputPins("A", "B");
18                 setOutputPins("Y");
19                 initSubmodelComponents();
20         }
21
22         @SuppressWarnings("unused") // for GUIWires being created
23         private void initSubmodelComponents()
24         {
25                 Pin A = getInputSubmodelPins().get(0);
26                 Pin B = getInputSubmodelPins().get(1);
27                 Pin Y = getOutputSubmodelPins().get(0);
28
29                 GUINandGate nandAB = new GUINandGate(submodelModifiable, 1);
30                 GUINandGate nandYA = new GUINandGate(submodelModifiable, 1);
31                 GUINandGate nandYB = new GUINandGate(submodelModifiable, 1);
32                 GUINandGate nandY = new GUINandGate(submodelModifiable, 1);
33
34                 WireCrossPoint cpA = new WireCrossPoint(submodelModifiable, 1);
35                 WireCrossPoint cpB = new WireCrossPoint(submodelModifiable, 1);
36                 WireCrossPoint cpAB = new WireCrossPoint(submodelModifiable, 1);
37
38                 nandAB.moveTo(7.5, 15);
39                 nandYA.moveTo(35, 2.5);
40                 nandYB.moveTo(35, 27.5);
41                 nandY.moveTo(62.5, 15);
42                 cpA.moveCenterTo(5, 12.5);
43                 cpB.moveCenterTo(5, 37.5);
44                 cpAB.moveCenterTo(30, 25);
45
46                 new GUIWire(submodelModifiable, A, cpA, new Point[0]);
47                 new GUIWire(submodelModifiable, B, cpB, new Point[0]);
48                 new GUIWire(submodelModifiable, cpA, nandAB.getInputPins().get(0), new Point(5, 20));
49                 new GUIWire(submodelModifiable, cpB, nandAB.getInputPins().get(1), new Point(5, 30));
50                 new GUIWire(submodelModifiable, nandAB.getOutputPin(), cpAB);
51                 new GUIWire(submodelModifiable, cpAB, nandYA.getInputPins().get(1), new Point(30, 17.5));
52                 new GUIWire(submodelModifiable, cpAB, nandYB.getInputPins().get(0), new Point(30, 32.5));
53                 new GUIWire(submodelModifiable, cpA, nandYA.getInputPins().get(0), new Point(5, 7.5));
54                 new GUIWire(submodelModifiable, cpB, nandYB.getInputPins().get(1), new Point(5, 42.5));
55                 new GUIWire(submodelModifiable, nandYA.getOutputPin(), nandY.getInputPins().get(0));
56                 new GUIWire(submodelModifiable, nandYB.getOutputPin(), nandY.getInputPins().get(1));
57                 new GUIWire(submodelModifiable, nandY.getOutputPin(), Y);
58         }
59 }