X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fcomponents%2Fmi%2Fnandbased%2FGUIdff.java;h=4756547368ce5c2ab1097f4d8a6eaf419b2ca3d5;hb=5ece0acf049bf9af2933f513fe0206565681f622;hp=8f183dccff924c21a8e581eae02c0fa4986895ae;hpb=74bced7a3a38f65c65f3395cc422eb98e34da0b8;p=Mograsim.git diff --git a/net.mograsim.logic.ui.am2900/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdff.java b/net.mograsim.logic.ui.am2900/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdff.java index 8f183dcc..47565473 100644 --- a/net.mograsim.logic.ui.am2900/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdff.java +++ b/net.mograsim.logic.ui.am2900/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdff.java @@ -2,11 +2,12 @@ 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.SimpleRectangularSubmodelComponent; +import net.mograsim.logic.ui.model.components.atomic.GUINandGate; +import net.mograsim.logic.ui.model.components.submodels.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; +import net.mograsim.logic.ui.serializing.IndirectGUIComponentCreator; public class GUIdff extends SimpleRectangularSubmodelComponent { @@ -14,7 +15,12 @@ public class GUIdff extends SimpleRectangularSubmodelComponent public GUIdff(ViewModelModifiable model) { - super(model, 1, "GUIdff"); + this(model, null); + } + + public GUIdff(ViewModelModifiable model, String name) + { + super(model, 1, "GUIdff", name); setSubmodelScale(.2); setInputPins("C", "D"); setOutputPins("Q", "_Q"); @@ -63,10 +69,12 @@ public class GUIdff extends SimpleRectangularSubmodelComponent new GUIWire(submodelModifiable, cp4, nand2.getPin("A"), new Point(100, 65)); new GUIWire(submodelModifiable, _rsLatch2.getPin("Q"), Q); new GUIWire(submodelModifiable, _rsLatch2.getPin("_Q"), _Q); + + addAtomicHighLevelStateID("q"); } @Override - public void setHighLevelState(String stateID, Object newState) + public void setAtomicHighLevelState(String stateID, Object newState) { switch (stateID) { @@ -74,20 +82,26 @@ public class GUIdff extends SimpleRectangularSubmodelComponent _rsLatch.setHighLevelState("q", newState); break; default: - super.setHighLevelState(stateID, newState); - break; + // should not happen because we tell SubmodelComponent to only allow these state IDs. + throw new IllegalStateException("Illegal atomic state ID: " + stateID); } } @Override - public Object getHighLevelState(String stateID) + public Object getAtomicHighLevelState(String stateID) { switch (stateID) { case "q": return _rsLatch.getHighLevelState("q"); default: - return super.getHighLevelState(stateID); + // should not happen because we tell SubmodelComponent to only allow these state IDs. + throw new IllegalStateException("Illegal atomic state ID: " + stateID); } } + + static + { + IndirectGUIComponentCreator.setComponentSupplier(GUIdff.class.getCanonicalName(), (m, p, n) -> new GUIdff(m, n)); + } } \ No newline at end of file