X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fwires%2FWireCrossPoint.java;h=da0a45062ac4d0dc2c6a1788f77dadccbfa2f553;hb=5ece0acf049bf9af2933f513fe0206565681f622;hp=ea79cc72d7cc3e1be52bc6e3287be8bfac8d8aba;hpb=5897a6d81c418d27ca5bb402e5f1038e10a191fb;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/WireCrossPoint.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/WireCrossPoint.java index ea79cc72..da0a4506 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/WireCrossPoint.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/WireCrossPoint.java @@ -1,5 +1,8 @@ package net.mograsim.logic.ui.model.wires; +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.mograsim.logic.core.LogicObserver; @@ -20,7 +23,7 @@ import net.mograsim.preferences.ColorManager; * * @author Daniel Kirschten */ -public class WireCrossPoint extends GUIComponent implements ConnectionPoint +public class WireCrossPoint extends GUIComponent { private static final int CIRCLE_RADIUS = 1; private static final int CIRCLE_DIAM = CIRCLE_RADIUS * 2; @@ -43,7 +46,12 @@ public class WireCrossPoint extends GUIComponent implements ConnectionPoint public WireCrossPoint(ViewModelModifiable model, int logicWidth) { - super(model); + this(model, logicWidth, null); + } + + public WireCrossPoint(ViewModelModifiable model, int logicWidth, String name) + { + super(model, name); logicObs = (i) -> requestRedraw(); setSize(CIRCLE_DIAM, CIRCLE_DIAM); @@ -52,7 +60,6 @@ public class WireCrossPoint extends GUIComponent implements ConnectionPoint // pins - @Override public Pin getPin() { return pin; @@ -105,9 +112,17 @@ public class WireCrossPoint extends GUIComponent implements ConnectionPoint return end != null; } + // serializing + + @Override + public JsonElement getParams() + { + return new JsonPrimitive(pin.logicWidth); + } + static { - // TODO read params - IndirectGUIComponentCreator.setComponentProvider(WireCrossPoint.class.getCanonicalName(), (m, p) -> new WireCrossPoint(m, 1)); + IndirectGUIComponentCreator.setComponentSupplier(WireCrossPoint.class.getCanonicalName(), + (m, p, n) -> new WireCrossPoint(m, p.getAsInt(), n)); } } \ No newline at end of file