Merge branch 'development' of
[Mograsim.git] / net.mograsim.logic.model.editor / src / net / mograsim / logic / model / editor / handles / HandleManager.java
index c5e06a5..58e1f6c 100644 (file)
@@ -90,7 +90,7 @@ public class HandleManager
                        comps.remove(interfaceComp);
                        registerInterfaceComponent(interfaceComp);
                        comps.forEach(c -> registerComponent(c));
                        comps.remove(interfaceComp);
                        registerInterfaceComponent(interfaceComp);
                        comps.forEach(c -> registerComponent(c));
-                       
+
                        model.getWires().forEach(w -> registerWire(w));
                        addHandle(cornerHandle = new CornerHandle(editor.toBeEdited));
                }
                        model.getWires().forEach(w -> registerWire(w));
                        addHandle(cornerHandle = new CornerHandle(editor.toBeEdited));
                }
@@ -122,17 +122,17 @@ public class HandleManager
                        Point[] newPath = w.getPath();
                        int newLength = newPath == null ? 0 : newPath.length;
                        int diff = oldLength.getAndSet(newLength) - newLength;
                        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)
+                               if (diff > 0)
                                {
                                {
-                                       for(int i = 0; i < diff; i++)
+                                       for (int i = 0; i < diff; i++)
                                                addWirePointHandle(w);
                                }
                                                addWirePointHandle(w);
                                }
-                               
+
                                List<WirePointHandle> wpHandles = pointHandlesPerWire.get(w);
                                int size = wpHandles.size();
                                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);
                                }
                                {
                                        wpHandles.get(i).setIndex(i);
                                }
@@ -182,8 +182,8 @@ public class HandleManager
 
        private void addInterfacePinHandle(Pin p)
        {
 
        private void addInterfacePinHandle(Pin p)
        {
-               //The following is not an alternative to the cast, because the new pin is not yet in the map, when the listener is called
-               //editor.toBeEdited.getSubmodelMovablePins().get(p.name);
+               // The following is not an alternative to the cast, because the new pin is not yet in the map, when the listener is called
+               // editor.toBeEdited.getSubmodelMovablePins().get(p.name);
                MovablePin pM = (MovablePin) p;
                InterfacePinHandle h = new InterfacePinHandle(pM, editor.toBeEdited);
                handlePerInterfacePin.put(pM, h);
                MovablePin pM = (MovablePin) p;
                InterfacePinHandle h = new InterfacePinHandle(pM, editor.toBeEdited);
                handlePerInterfacePin.put(pM, h);
@@ -213,7 +213,7 @@ public class HandleManager
                this.wirePointHandles.add(h);
                addHandle(h);
        }
                this.wirePointHandles.add(h);
                addHandle(h);
        }
-       
+
        void destroyWirePointHandle(GUIWire owner, WirePointHandle h)
        {
                List<WirePointHandle> handles = pointHandlesPerWire.get(owner);
        void destroyWirePointHandle(GUIWire owner, WirePointHandle h)
        {
                List<WirePointHandle> handles = pointHandlesPerWire.get(owner);
@@ -225,7 +225,7 @@ public class HandleManager
 
        private void removeWirePointHandles(GUIWire owner)
        {
 
        private void removeWirePointHandles(GUIWire owner)
        {
-               if(!pointHandlesPerWire.containsKey(owner))
+               if (!pointHandlesPerWire.containsKey(owner))
                        return;
                pointHandlesPerWire.get(owner).forEach(h ->
                {
                        return;
                pointHandlesPerWire.get(owner).forEach(h ->
                {
@@ -276,7 +276,7 @@ public class HandleManager
        {
                return handlePerWire.get(parent);
        }
        {
                return handlePerWire.get(parent);
        }
-       
+
        public Handle getInterfacePinHandle(Pin p)
        {
                return handlePerInterfacePin.get(p);
        public Handle getInterfacePinHandle(Pin p)
        {
                return handlePerInterfacePin.get(p);
@@ -305,7 +305,7 @@ public class HandleManager
        {
                return Collections.unmodifiableCollection(handlePerPin.values());
        }
        {
                return Collections.unmodifiableCollection(handlePerPin.values());
        }
-       
+
        /**
         * @return An unmodifiable view of all registered {@link InterfacePinHandle}s
         */
        /**
         * @return An unmodifiable view of all registered {@link InterfacePinHandle}s
         */
@@ -348,11 +348,11 @@ public class HandleManager
                                        if (!click(getWirePointHandles(), clicked, entryState, stateMask))
                                                if (!click(getWireHandles(), clicked, entryState, stateMask))
                                                        if (!click(handlePerComp.values(), clicked, entryState, stateMask))
                                        if (!click(getWirePointHandles(), clicked, entryState, stateMask))
                                                if (!click(getWireHandles(), clicked, entryState, stateMask))
                                                        if (!click(handlePerComp.values(), clicked, entryState, stateMask))
-                                                                       entryState.clickedEmpty(clicked, stateMask);
+                                                               entryState.clickedEmpty(clicked, stateMask);
                entryState.clicked(clicked, stateMask);
        }
 
                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))
        {
                for (Handle h : handles)
                        if (h.click(clicked.x, clicked.y, stateMask, state))