Merge remote-tracking branch 'origin/development' into development
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUImux1.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 GUImux1 extends SimpleRectangularSubmodelComponent
12 {
13         public GUImux1(ViewModelModifiable model)
14         {
15                 super(model, 1, "GUImux1");
16                 setSize(80, 40);
17                 setSubmodelScale(.4);
18
19                 setInputCount(3);
20                 setOutputCount(1);
21                 initSubmodelComponents();
22         }
23
24         @SuppressWarnings("unused")
25         private void initSubmodelComponents()
26         {
27                 Pin S0 = getInputSubmodelPins().get(0);
28                 Pin I0 = getInputSubmodelPins().get(1);
29                 Pin I1 = getInputSubmodelPins().get(2);
30                 Pin Y = getOutputSubmodelPins().get(0);
31
32                 GUINandGate nandS0 = new GUINandGate(submodelModifiable, 1);
33                 GUINandGate nandI0 = new GUINandGate(submodelModifiable, 1);
34                 GUINandGate nandI1 = new GUINandGate(submodelModifiable, 1);
35                 GUINandGate nandY = new GUINandGate(submodelModifiable, 1);
36
37                 nandS0.moveTo(10, 7.5);
38                 nandI0.moveTo(35, 22.5);
39                 nandI1.moveTo(35, 47.5);
40                 nandY.moveTo(60, 30);
41
42                 WireCrossPoint cp0 = new WireCrossPoint(submodelModifiable, 1);
43                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
44
45                 cp0.moveTo(5, 12.5);
46                 cp1.moveTo(5, 22.5);
47
48                 new GUIWire(submodelModifiable, S0, cp0);
49                 new GUIWire(submodelModifiable, cp0, nandS0.getInputPins().get(0));
50                 new GUIWire(submodelModifiable, cp0, cp1);
51                 new GUIWire(submodelModifiable, cp1, nandS0.getInputPins().get(1));
52
53                 new GUIWire(submodelModifiable, nandS0.getOutputPin(), nandI0.getInputPins().get(0));
54                 new GUIWire(submodelModifiable, I0, nandI0.getInputPins().get(1));
55
56                 new GUIWire(submodelModifiable, cp1, nandI1.getInputPins().get(0),
57                                 new Point(cp1.getPin().getPos().x, nandI1.getInputPins().get(0).getPos().y));
58                 new GUIWire(submodelModifiable, I1, nandI1.getInputPins().get(1));
59
60                 new GUIWire(submodelModifiable, nandI0.getOutputPin(), nandY.getInputPins().get(0));
61                 new GUIWire(submodelModifiable, nandI1.getOutputPin(), nandY.getInputPins().get(1));
62
63                 new GUIWire(submodelModifiable, nandY.getOutputPin(), Y);
64         }
65 }