From: Daniel Kirschten Date: Wed, 17 Jul 2019 10:50:07 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/development' into development X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=53e2bb4363368cc84b12da42bdd228d69b2aca9b;hp=a25f554756e1bc9a1f842293aefe60a220d8b950;p=Mograsim.git Merge remote-tracking branch 'origin/development' into development --- diff --git a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/HandleManager.java b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/HandleManager.java index 7fe6e432..f3ef9a88 100644 --- a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/HandleManager.java +++ b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/HandleManager.java @@ -122,7 +122,7 @@ public class HandleManager { Point[] newPath = w.getPath(); int newLength = newPath == null ? 0 : newPath.length; - int diff = oldLength.getAndSet(newLength) - newLength; + int diff = newLength - oldLength.getAndSet(newLength); if (diff != 0) { if (diff > 0) @@ -217,11 +217,14 @@ public class HandleManager void destroyWirePointHandle(GUIWire owner, WirePointHandle h) { - List handles = pointHandlesPerWire.get(owner); - int pointIndex = handles.indexOf(h); - handles.remove(pointIndex); - removeHandle(h); - owner.removePathPoint(pointIndex); + if (pointHandlesPerWire.containsKey(owner)) + { + List handles = pointHandlesPerWire.get(owner); + int pointIndex = handles.indexOf(h); + handles.remove(pointIndex); + removeHandle(h); + owner.removePathPoint(pointIndex); + } } private void removeWirePointHandles(GUIWire owner) diff --git a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/WirePointHandle.java b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/WirePointHandle.java index 8fd0acd2..48c7c227 100644 --- a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/WirePointHandle.java +++ b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/WirePointHandle.java @@ -32,6 +32,7 @@ public class WirePointHandle extends Handle { Point p = parent.getPathPoint(pointIndex); moveTo(p.x, p.y); + callRedrawListeners(); } @Override diff --git a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/ui/EditorCanvas.java b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/ui/EditorCanvas.java index 641aaa46..aedaa481 100644 --- a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/ui/EditorCanvas.java +++ b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/ui/EditorCanvas.java @@ -22,9 +22,17 @@ public class EditorCanvas extends LogicUICanvas super(parent, style, editor.toBeEdited.submodel); handles = editor.handleManager.getHandles(); - editor.handleManager.addHandleAddedListener(h -> h.addRedrawListener(this::redrawThreadsafe)); + editor.handleManager.addHandleAddedListener(h -> + { + redrawThreadsafe(); + h.addRedrawListener(this::redrawThreadsafe); + }); // TODO: Is this even necessary? The Handle should be finalized by the gc - editor.handleManager.addHandleRemovedListener(h -> h.removeRedrawListener(this::redrawThreadsafe)); + editor.handleManager.addHandleRemovedListener(h -> + { + redrawThreadsafe(); + h.removeRedrawListener(this::redrawThreadsafe); + }); addZoomedRenderer(gc -> { diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java index f59355ce..144a1a38 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java @@ -421,6 +421,8 @@ public class GUIWire System.arraycopy(oldPath, index, path, index + 1, oldPath.length - index); path[index] = pointCopy(p); } + recalculateEffectivePath(); + callPathChangedListeners(); } public void removePathPoint(int index) @@ -435,6 +437,8 @@ public class GUIWire if (index < oldPath.length - 1) System.arraycopy(oldPath, index + 1, path, index, oldPath.length - index - 1); } + recalculateEffectivePath(); + callPathChangedListeners(); } public double[] getEffectivePath()