X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fcomponents%2Fmi%2Fnandbased%2FGUIdlatch.java;h=5fae33547c1a5a8dd61778151e178781c5a2e698;hb=7d29de9658db31195b8b13d54b1efe2f72e0b157;hp=4e04f803bdbb530049d7d0193701ab6bed220e4e;hpb=f84fb965a1f4dc6d6675445426d4e68aa5b989fb;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdlatch.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdlatch.java index 4e04f803..5fae3354 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdlatch.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdlatch.java @@ -3,40 +3,30 @@ package net.mograsim.logic.ui.model.components.mi.nandbased; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.mograsim.logic.ui.model.ViewModelModifiable; import net.mograsim.logic.ui.model.components.GUINandGate; -import net.mograsim.logic.ui.model.components.SubmodelComponent; +import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent; import net.mograsim.logic.ui.model.wires.GUIWire; import net.mograsim.logic.ui.model.wires.Pin; import net.mograsim.logic.ui.model.wires.WireCrossPoint; -public class GUIdlatch extends SubmodelComponent +public class GUIdlatch extends SimpleRectangularSubmodelComponent { - private final Pin pinD; - private final Pin pinE; - private final Pin pinQ; - private final Pin pin_Q; - public GUIdlatch(ViewModelModifiable model) { - super(model, "GUIdlatch"); - setSize(35, 25); + super(model, 1, "GUIdlatch"); setSubmodelScale(.4); - - Pin D = addSubmodelInterface(1, 0, 5); - Pin E = addSubmodelInterface(1, 0, 20); - Pin Q = addSubmodelInterface(1, 35, 5); - Pin _Q = addSubmodelInterface(1, 35, 20); - - this.pinD = getSupermodelPin(D); - this.pinE = getSupermodelPin(E); - this.pinQ = getSupermodelPin(Q); - this.pin_Q = getSupermodelPin(_Q); - - initSubmodelComponents(D, E, Q, _Q); + setInputCount(2); + setOutputCount(2); + initSubmodelComponents(); } @SuppressWarnings("unused") // for GUIWires being created - private void initSubmodelComponents(Pin D, Pin E, Pin Q, Pin _Q) + private void initSubmodelComponents() { + Pin D = getInputSubmodelPins().get(0); + Pin E = getInputSubmodelPins().get(1); + Pin Q = getOutputSubmodelPins().get(0); + Pin _Q = getOutputSubmodelPins().get(1); + GUINandGate nand1 = new GUINandGate(submodelModifiable, 1); GUINandGate nand2 = new GUINandGate(submodelModifiable, 1); GUI_rsLatch _rsLatch = new GUI_rsLatch(submodelModifiable); @@ -44,41 +34,21 @@ public class GUIdlatch extends SubmodelComponent WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1); WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1); - nand1.moveTo(10, 7.5); - nand2.moveTo(15, 35); + nand1.moveTo(10, 2.5); + nand2.moveTo(15, 27.5); _rsLatch.moveTo(45, 7.5); - cp1.moveTo(5, 50); - cp2.moveTo(35, 17.5); + cp1.moveCenterTo(5, 37.5); + cp2.moveCenterTo(35, 12.5); new GUIWire(submodelModifiable, D, nand1.getInputPins().get(0)); - new GUIWire(submodelModifiable, E, cp1); - new GUIWire(submodelModifiable, cp1, nand1.getInputPins().get(1), new Point(5, 22.5)); - new GUIWire(submodelModifiable, cp1, nand2.getInputPins().get(1)); - new GUIWire(submodelModifiable, nand1.getOutputPin(), cp2); - new GUIWire(submodelModifiable, cp2, nand2.getInputPins().get(0), new Point(35, 30), new Point(10, 30), new Point(10, 40)); - new GUIWire(submodelModifiable, cp2, _rsLatch.getPin_S(), new Point(35, 12.5)); - new GUIWire(submodelModifiable, nand2.getOutputPin(), _rsLatch.getPin_R(), new Point(40, 45), new Point(40, 27.5)); - new GUIWire(submodelModifiable, _rsLatch.getPinQ(), Q); - new GUIWire(submodelModifiable, _rsLatch.getPin_Q(), _Q, new Point(82.5, 27.5), new Point(82.5, 50)); - } - - public Pin getPinD() - { - return pinD; - } - - public Pin getPinE() - { - return pinE; - } - - public Pin getPinQ() - { - return pinQ; - } - - public Pin getPin_Q() - { - return pin_Q; + new GUIWire(submodelModifiable, E, cp1, new Point[0]); + new GUIWire(submodelModifiable, cp1, nand1.getInputPins().get(1), new Point(5, 17.5)); + new GUIWire(submodelModifiable, cp1, nand2.getInputPins().get(1), new Point(5, 42.5)); + new GUIWire(submodelModifiable, nand1.getOutputPin(), cp2, new Point[0]); + new GUIWire(submodelModifiable, cp2, nand2.getInputPins().get(0), new Point(35, 25), new Point(10, 25), new Point(10, 32.5)); + new GUIWire(submodelModifiable, cp2, _rsLatch.getInputPins().get(0), new Point[0]); + new GUIWire(submodelModifiable, nand2.getOutputPin(), _rsLatch.getInputPins().get(1), new Point(40, 37.5), new Point(40, 22.5)); + new GUIWire(submodelModifiable, _rsLatch.getOutputPins().get(0), Q, new Point[0]); + new GUIWire(submodelModifiable, _rsLatch.getOutputPins().get(1), _Q); } } \ No newline at end of file