X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fmodel%2Fwires%2FGUIWire.java;h=8ecf1c459309751a50a7ffc0b5e2483119bbb1fa;hb=dbdd4bbf4d1a1709f74aecbb3212ef29f4c82d0f;hp=112133595601a90c139626aafa3382354bd68df3;hpb=8eb61f917f31b0cff935538606df04e1c610bdf9;p=Mograsim.git diff --git a/LogicUI/src/era/mi/gui/model/wires/GUIWire.java b/LogicUI/src/era/mi/gui/model/wires/GUIWire.java index 11213359..8ecf1c45 100644 --- a/LogicUI/src/era/mi/gui/model/wires/GUIWire.java +++ b/LogicUI/src/era/mi/gui/model/wires/GUIWire.java @@ -27,16 +27,30 @@ public class GUIWire this.path[dstI + 0] = path[srcI].x; this.path[dstI + 1] = path[srcI].y; } - // TODO support moving pins - Point pos; - pos = pin1.getPos(); + + this.pin1 = pin1; + this.pin2 = pin2; + + pin1.addPinMovedListener(p -> pin1Moved()); + pin2.addPinMovedListener(p -> pin2Moved()); + pin1Moved(); + pin2Moved(); + + model.wireCreated(this); + } + + private void pin1Moved() + { + Point pos = pin1.getPos(); this.path[0] = pos.x; this.path[1] = pos.y; - pos = pin2.getPos(); + } + + private void pin2Moved() + { + Point pos = pin2.getPos(); this.path[this.path.length - 2] = pos.x; this.path[this.path.length - 1] = pos.y; - - model.wireCreated(this); } public void destroy()