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=1124233bc000ce139e21bf97b1eabfd5676aac2c;hb=a19dde054ec5cab3c835840d569880ee8ee156dc;hp=eb3028eb8f507badc5a21465001d81e02937cdd4;hpb=9c142c9ad59d2af070ebb6495b1ca48242da62d8;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 eb3028eb..1124233b 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,7 @@ package net.mograsim.logic.ui.model.wires; +import java.util.Map; + import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.mograsim.logic.core.LogicObservable; @@ -9,9 +11,13 @@ 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.SimpleRectangularGUIGate; public class WireCrossPoint extends GUIComponent { + private static final int CIRCLE_RADIUS = 1; + private static final int CIRCLE_DIAM = CIRCLE_RADIUS * 2; + private final Pin pin; private final int logicWidth; @@ -24,8 +30,13 @@ public class WireCrossPoint extends GUIComponent logicObs = (i) -> requestRedraw(); this.logicWidth = logicWidth; - setSize(0, 0); - addPin(this.pin = new Pin(this, logicWidth, 0, 0)); + setSize(CIRCLE_DIAM, CIRCLE_DIAM); + addPin(this.pin = new Pin(this, "", logicWidth, CIRCLE_RADIUS, CIRCLE_RADIUS)); + } + + public void moveCenterTo(double x, double y) + { + moveTo(x - CIRCLE_RADIUS, y - CIRCLE_RADIUS); } @Override @@ -33,7 +44,7 @@ public class WireCrossPoint extends GUIComponent { Rectangle bounds = getBounds(); ColorHelper.executeWithDifferentBackground(gc, BitVectorFormatter.formatAsColor(end), - () -> gc.fillOval(bounds.x - 1, bounds.y - 1, 2, 2)); + () -> gc.fillOval(bounds.x, bounds.y, CIRCLE_DIAM, CIRCLE_DIAM)); } public void setLogicModelBinding(ReadEnd end) @@ -64,4 +75,13 @@ public class WireCrossPoint extends GUIComponent { return pin; } + + @Override + public Map getInstantiationParameters() + { + Map m = super.getInstantiationParameters(); + m.put(SimpleRectangularGUIGate.kLogicWidth, logicWidth); + return m; + } + } \ No newline at end of file