Fixed WireCrossPoints disappearing near edges
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUIhalfadder.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 GUIhalfadder extends SimpleRectangularSubmodelComponent
12 {
13         public GUIhalfadder(ViewModelModifiable model)
14         {
15                 super(model, 1, "GUIhalfadder");
16                 setSubmodelScale(.4);
17                 setInputCount(2);
18                 setOutputCount(2);
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                 Pin _Z = getOutputSubmodelPins().get(1);
29
30                 GUINandGate nand_Z = new GUINandGate(submodelModifiable, 1);
31                 GUINandGate nandYA = new GUINandGate(submodelModifiable, 1);
32                 GUINandGate nandYB = new GUINandGate(submodelModifiable, 1);
33                 GUINandGate nandY = new GUINandGate(submodelModifiable, 1);
34
35                 WireCrossPoint cpA = new WireCrossPoint(submodelModifiable, 1);
36                 WireCrossPoint cpB = new WireCrossPoint(submodelModifiable, 1);
37                 WireCrossPoint cp_Z = new WireCrossPoint(submodelModifiable, 1);
38
39                 nand_Z.moveTo(10, 15);
40                 nandYA.moveTo(40, 2.5);
41                 nandYB.moveTo(40, 27.5);
42                 nandY.moveTo(65, 2.5);
43                 cpA.moveCenterTo(5, 12.5);
44                 cpB.moveCenterTo(5, 37.5);
45                 cp_Z.moveCenterTo(35, 25);
46
47                 new GUIWire(submodelModifiable, A, cpA, new Point[0]);
48                 new GUIWire(submodelModifiable, cpA, nandYA.getInputPins().get(0), new Point(5, 7.5));
49                 new GUIWire(submodelModifiable, cpA, nand_Z.getInputPins().get(0), new Point(5, 20));
50                 new GUIWire(submodelModifiable, B, cpB, new Point[0]);
51                 new GUIWire(submodelModifiable, cpB, nandYB.getInputPins().get(1), new Point(5, 42.5));
52                 new GUIWire(submodelModifiable, cpB, nand_Z.getInputPins().get(1), new Point(5, 30));
53                 new GUIWire(submodelModifiable, nand_Z.getOutputPin(), cp_Z, new Point[0]);
54                 new GUIWire(submodelModifiable, cp_Z, _Z, new Point(80, 25), new Point(80, 37.5));
55                 new GUIWire(submodelModifiable, cp_Z, nandYA.getInputPins().get(1), new Point(35, 17.5));
56                 new GUIWire(submodelModifiable, cp_Z, nandYB.getInputPins().get(0), new Point(35, 32.5));
57                 new GUIWire(submodelModifiable, nandYA.getOutputPin(), nandY.getInputPins().get(0), new Point(62.5, 12.5), new Point(62.5, 7.5));
58                 new GUIWire(submodelModifiable, nandYB.getOutputPin(), nandY.getInputPins().get(1), new Point(62.5, 37.5), new Point(62.5, 17.5));
59                 new GUIWire(submodelModifiable, nandY.getOutputPin(), Y, new Point[0]);
60         }
61 }