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=58e3a02a8380cba84ce858439d308f2382b9546e;hb=05f3deb7ee3a0b7162c75e1963be9a739618e3df;hp=6235f343d6a82906397a3ddecd7c6f51b6b5c10c;hpb=01c5d7035474a5eb58f216b6831b2c0d8c174efa;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 6235f343..58e3a02a 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,16 +1,18 @@ package net.mograsim.logic.ui.model.wires; -import java.util.Map; +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; import net.mograsim.logic.core.types.BitVectorFormatter; import net.mograsim.logic.core.wires.Wire.ReadEnd; -import net.mograsim.logic.ui.ColorHelper; import net.mograsim.logic.ui.model.ViewModelModifiable; import net.mograsim.logic.ui.model.components.GUIComponent; -import net.mograsim.logic.ui.model.components.atomic.SimpleRectangularGUIGate; +import net.mograsim.logic.ui.serializing.IndirectGUIComponentCreator; +import net.mograsim.preferences.ColorDefinition; +import net.mograsim.preferences.ColorManager; /** * A {@link GUIComponent} with only one pin. Is used to create wires connecting more than two pins.
@@ -21,7 +23,7 @@ import net.mograsim.logic.ui.model.components.atomic.SimpleRectangularGUIGate; * * @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; @@ -53,7 +55,6 @@ public class WireCrossPoint extends GUIComponent implements ConnectionPoint // pins - @Override public Pin getPin() { return pin; @@ -74,8 +75,10 @@ public class WireCrossPoint extends GUIComponent implements ConnectionPoint @Override public void render(GeneralGC gc, Rectangle visibleRegion) { - ColorHelper.executeWithDifferentBackground(gc, BitVectorFormatter.formatAsColor(end), - () -> gc.fillOval(getPosX(), getPosY(), CIRCLE_DIAM, CIRCLE_DIAM)); + ColorDefinition wireColor = BitVectorFormatter.formatAsColor(end); + if (wireColor != null) + gc.setBackground(ColorManager.current().toColor(wireColor)); + gc.fillOval(getPosX(), getPosY(), CIRCLE_DIAM, CIRCLE_DIAM); } // logic model binding @@ -107,10 +110,14 @@ public class WireCrossPoint extends GUIComponent implements ConnectionPoint // serializing @Override - public Map getInstantiationParameters() + public JsonElement getParams() + { + return new JsonPrimitive(pin.logicWidth); + } + + static { - Map m = super.getInstantiationParameters(); - m.put(SimpleRectangularGUIGate.kLogicWidth, pin.logicWidth); - return m; + IndirectGUIComponentCreator.setComponentSupplier(WireCrossPoint.class.getCanonicalName(), + (m, p) -> new WireCrossPoint(m, p.getAsInt())); } } \ No newline at end of file