1 package net.mograsim.logic.ui.model.components.mi.nandbased;
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.ui.model.ViewModelModifiable;
5 import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent;
6 import net.mograsim.logic.ui.model.wires.GUIWire;
7 import net.mograsim.logic.ui.model.wires.Pin;
8 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
29 public class GUImux1_4 extends SimpleRectangularSubmodelComponent
31 public GUImux1_4(ViewModelModifiable model)
33 super(model, 1, "GUImux1_4");
37 initSubmodelComponents();
40 @SuppressWarnings("unused")
41 private void initSubmodelComponents()
44 GUImux1 mux1 = new GUImux1(submodelModifiable);
45 GUImux1 mux2 = new GUImux1(submodelModifiable);
46 GUImux1 mux3 = new GUImux1(submodelModifiable);
47 GUImux1 mux4 = new GUImux1(submodelModifiable);
49 GUImux1 mux[] = { mux1, mux2, mux3, mux4 };
50 WireCrossPoint[] cps = new WireCrossPoint[mux.length - 1];
52 double muxXOffset = 30, muxYOffset = 7.5, muxYMargin = 5;
53 Pin test = getInputPins().get(0);
54 Pin test2 = mux[0].getInputPins().get(1);
55 for (int i = 0; i < mux.length; i++)
57 mux[i].moveTo(muxXOffset, muxYOffset + (mux[0].getBounds().height + muxYMargin) * i);
58 Pin inPinA = getInputSubmodelPins().get(i + 1);
59 Pin inPinB = getInputSubmodelPins().get(mux.length + i + 1);
60 Pin muxPin = mux[i].getInputPins().get(1);
62 new GUIWire(submodelModifiable, inPinA, muxPin, new Point(inPinA.getPos().x + 5, inPinA.getPos().y),
63 new Point(inPinA.getPos().x + 5, muxPin.getPos().y));
64 new GUIWire(submodelModifiable, inPinB, mux[i].getInputPins().get(2), new Point(10 + 5 * i, inPinB.getPos().y),
65 new Point(10 + 5 * i, mux[i].getInputPins().get(2).getPos().y));
66 new GUIWire(submodelModifiable, mux[i].getOutputPins().get(0), getOutputSubmodelPins().get(i));
68 if (i != mux.length - 1)
70 WireCrossPoint cp = new WireCrossPoint(submodelModifiable, logicWidth);
72 Pin p = mux[i].getInputPins().get(0);
73 cp.moveTo(muxXOffset - 3, p.getPos().y);
74 new GUIWire(submodelModifiable, cp, mux[i].getInputPins().get(0));
76 new GUIWire(submodelModifiable, cps[i - 1], cp, new Point[0]);
78 new GUIWire(submodelModifiable, getInputSubmodelPins().get(0), cp, new Point[0]);
81 new GUIWire(submodelModifiable, cps[i - 1], mux[i].getInputPins().get(0),
82 new Point(cps[i - 1].getPin().getPos().x, mux[i].getInputPins().get(0).getPos().y));