X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.editor%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Feditor%2Fhandles%2FWireHandle.java;h=be9a5ca69c4c691a267f50b1db1e180df3b74788;hb=148a58630b38b30d4d24a21e3f55c357f5b4d0bc;hp=a5e97d4c8fc3dc503dde1e27d9ddc76c6b88f1c3;hpb=878d036669f4aa9d0c332ced43da3a08b94655e9;p=Mograsim.git diff --git a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/WireHandle.java b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/WireHandle.java index a5e97d4c..be9a5ca6 100644 --- a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/WireHandle.java +++ b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/WireHandle.java @@ -9,20 +9,23 @@ import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.mograsim.logic.model.editor.states.EditorState; +import net.mograsim.logic.model.model.ViewModelModifiable; import net.mograsim.logic.model.model.wires.GUIWire; -import net.mograsim.logic.model.model.wires.GUIWire.PathChangedListener; -public class WireHandle extends Handle implements PathChangedListener +public class WireHandle extends Handle { private boolean selected = false; private final static double WIDTH = 2.0; private final static double WIDTH_SQUARED = WIDTH * WIDTH; + private final ViewModelModifiable model; public final GUIWire parent; - public WireHandle(GUIWire parent) + public WireHandle(ViewModelModifiable model, GUIWire parent) { + super(5); + this.model = model; this.parent = parent; - parent.addPathChangedListener(this); + parent.addPathChangedListener(c -> updateBounds()); updateBounds(); } @@ -30,7 +33,7 @@ public class WireHandle extends Handle implements PathChangedListener void destroy() { super.destroy(); - parent.removePathChangedListener(this); + parent.removePathChangedListener(c -> updateBounds()); } public void updateBounds() @@ -68,7 +71,7 @@ public class WireHandle extends Handle implements PathChangedListener @Override public void reqDelete() { - parent.destroy(); + model.destroyWire(parent); } @Override @@ -153,10 +156,4 @@ public class WireHandle extends Handle implements PathChangedListener { return HandleType.WIRE; } - - @Override - public void pathChanged(GUIWire wire, int diff) - { - updateBounds(); - } }