Merge branch 'development' of
authorFabian Stemmler <stemmler@in.tum.de>
Mon, 15 Jul 2019 16:19:15 +0000 (18:19 +0200)
committerFabian Stemmler <stemmler@in.tum.de>
Mon, 15 Jul 2019 16:19:15 +0000 (18:19 +0200)
https://gitlab.lrz.de/lrr-tum/students/eragp-misim-2019 into development

# Conflicts:
# net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/HandleManager.java

1  2 
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/WireHandle.java

@@@ -114,19 -115,24 +115,24 @@@ public class HandleManage
  
        private void registerWire(GUIWire wire)
        {
-               wire.addPathChangedListener((w, diff) ->
+               Point[] path = wire.getPath();
+               AtomicInteger oldLength = new AtomicInteger(path == null ? 0 : path.length);
+               wire.addPathChangedListener(w ->
                {
 -                      if(diff != 0)
+                       Point[] newPath = w.getPath();
+                       int newLength = newPath == null ? 0 : newPath.length;
+                       int diff = oldLength.getAndSet(newLength) - newLength;
 +                      if (diff != 0)
                        {
 -                              if(diff > 0)
 +                              if (diff > 0)
                                {
 -                                      for(int i = 0; i < diff; i++)
 +                                      for (int i = 0; i < diff; i++)
                                                addWirePointHandle(w);
                                }
 -                              
 +
                                List<WirePointHandle> wpHandles = pointHandlesPerWire.get(w);
                                int size = wpHandles.size();
 -                              for(int i = 0; i < size; i++)
 +                              for (int i = 0; i < size; i++)
                                {
                                        wpHandles.get(i).setIndex(i);
                                }
                entryState.clicked(clicked, stateMask);
        }
  
--      private boolean click(Collection<? extends Handle> handles, Point clicked, EditorState state, int stateMask)
++      private static boolean click(Collection<? extends Handle> handles, Point clicked, EditorState state, int stateMask)
        {
                for (Handle h : handles)
                        if (h.click(clicked.x, clicked.y, stateMask, state))
@@@ -22,10 -21,10 +21,10 @@@ public class WireHandle extends Handl
        public WireHandle(GUIWire parent)
        {
                this.parent = parent;
-               parent.addPathChangedListener(this);
+               parent.addPathChangedListener(c -> updateBounds());
                updateBounds();
        }
 -      
 +
        @Override
        void destroy()
        {