9cec0cecd2d9705fa3571687fef508a879c35845
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUIand.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.SubmodelComponent;
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 GUIand extends SubmodelComponent
12 {
13         public GUIand(ViewModelModifiable model)
14         {
15                 super(model, "GUIand");
16                 setSize(35, 25);
17                 setSubmodelScale(.4);
18                 initSubmodelComponents();
19         }
20
21         @SuppressWarnings("unused") // for GUIWires being created
22         private void initSubmodelComponents()
23         {
24                 Pin A = addSubmodelInterface(1, 0, 5);
25                 Pin B = addSubmodelInterface(1, 0, 20);
26                 Pin Y = addSubmodelInterface(1, 35, 12.5);
27
28                 GUINandGate nand = new GUINandGate(submodelModifiable, 1);
29                 nand.moveTo(20, 21.25);
30                 GUINandGate not = new GUINandGate(submodelModifiable, 1);
31                 not.moveTo(50, 21.25);
32
33                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
34                 cp1.moveTo(45, 31.25);
35
36                 new GUIWire(submodelModifiable, A, nand.getInputPins().get(0), new Point(10, 12.5), new Point(10, 26.25));
37                 new GUIWire(submodelModifiable, B, nand.getInputPins().get(1), new Point(10, 50), new Point(10, 36.25));
38                 new GUIWire(submodelModifiable, nand.getOutputPin(), cp1.getPin());
39                 new GUIWire(submodelModifiable, cp1.getPin(), not.getInputPins().get(0), new Point(45, 26.25));
40                 new GUIWire(submodelModifiable, cp1.getPin(), not.getInputPins().get(1), new Point(45, 36.25));
41                 new GUIWire(submodelModifiable, not.getOutputPin(), Y);
42         }
43 }