35c47b06a71a4d1785bca4aa03942b2234b7a253
[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.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 GUIand extends SimpleRectangularSubmodelComponent
12 {
13         public GUIand(ViewModelModifiable model)
14         {
15                 super(model, 1, "GUIand");
16                 setSubmodelScale(.4);
17                 setInputCount(2);
18                 setOutputCount(1);
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 nand = new GUINandGate(submodelModifiable, 1);
30                 GUINandGate not = new GUINandGate(submodelModifiable, 1);
31
32                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
33
34                 nand.moveTo(20, 15);
35                 not.moveTo(50, 15);
36                 cp1.moveTo(45, 25);
37
38                 new GUIWire(submodelModifiable, A, nand.getInputPins().get(0));
39                 new GUIWire(submodelModifiable, B, nand.getInputPins().get(1));
40                 new GUIWire(submodelModifiable, nand.getOutputPin(), cp1, new Point[0]);
41                 new GUIWire(submodelModifiable, cp1, not.getInputPins().get(0), new Point(45, 20));
42                 new GUIWire(submodelModifiable, cp1, not.getInputPins().get(1), new Point(45, 30));
43                 new GUIWire(submodelModifiable, not.getOutputPin(), Y);
44         }
45 }