Merge remote-tracking branch 'origin/development' into development
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 17 Jul 2019 10:50:07 +0000 (12:50 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 17 Jul 2019 10:50:07 +0000 (12:50 +0200)
net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/HandleManager.java
net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/WirePointHandle.java
net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/ui/EditorCanvas.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java

index 7fe6e43..f3ef9a8 100644 (file)
@@ -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<WirePointHandle> handles = pointHandlesPerWire.get(owner);
-               int pointIndex = handles.indexOf(h);
-               handles.remove(pointIndex);
-               removeHandle(h);
-               owner.removePathPoint(pointIndex);
+               if (pointHandlesPerWire.containsKey(owner))
+               {
+                       List<WirePointHandle> handles = pointHandlesPerWire.get(owner);
+                       int pointIndex = handles.indexOf(h);
+                       handles.remove(pointIndex);
+                       removeHandle(h);
+                       owner.removePathPoint(pointIndex);
+               }
        }
 
        private void removeWirePointHandles(GUIWire owner)
index 8fd0acd..48c7c22 100644 (file)
@@ -32,6 +32,7 @@ public class WirePointHandle extends Handle
        {
                Point p = parent.getPathPoint(pointIndex);
                moveTo(p.x, p.y);
+               callRedrawListeners();
        }
 
        @Override
index 641aaa4..aedaa48 100644 (file)
@@ -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 ->
                {
index f59355c..144a1a3 100644 (file)
@@ -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()