X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fwires%2FGUIWire.java;h=63c2160dab73d258dd5bbf6eea723b6d2f82b40f;hb=63a0289cdf12e2f349267b6be9897350171d9741;hp=b69c810e999aeb528cfd64d49b17395f40281df4;hpb=f84fb965a1f4dc6d6675445426d4e68aa5b989fb;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java index b69c810e..63c2160d 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java @@ -47,13 +47,15 @@ public class GUIWire this.logicWidth = pin1.logicWidth; if (pin2.logicWidth != pin1.logicWidth) throw new IllegalArgumentException("Can't connect pins of different logic width"); - this.path = new double[path.length * 2 + 4]; - for (int srcI = 0, dstI = 2; srcI < path.length; srcI++, dstI += 2) + + if (path.length == 0) { - this.path[dstI + 0] = path[srcI].x; - this.path[dstI + 1] = path[srcI].y; + Point pos1 = pin1.getPos(), pos2 = pin2.getPos(); + path = new Point[] { new Point((pos1.x + pos2.x) / 2, pos1.y), new Point((pos1.x + pos2.x) / 2, pos2.y) }; } + applyPath(path); + this.pin1 = pin1; this.pin2 = pin2; @@ -67,6 +69,17 @@ public class GUIWire model.wireCreated(this); } + private void applyPath(Point... path) + { + this.path = new double[path.length * 2 + 4]; + + for (int srcI = 0, dstI = 2; srcI < path.length; srcI++, dstI += 2) + { + this.path[dstI + 0] = path[srcI].x; + this.path[dstI + 1] = path[srcI].y; + } + } + private void pin1Moved() { Point pos = pin1.getPos();