X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.editor%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Feditor%2Fhandles%2FHandleManager.java;h=f3ef9a88f1df491ec37253d0539e4ad6136724c2;hb=53e2bb4363368cc84b12da42bdd228d69b2aca9b;hp=7e2316079adaa4053d3b63bdb94d22ecd2132b66;hpb=fa320c0ea9a17efa0b18c1a9a593d72223e94b89;p=Mograsim.git 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 7e231607..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 @@ -17,6 +17,7 @@ import net.mograsim.logic.model.editor.Editor; import net.mograsim.logic.model.editor.states.EditorState; import net.mograsim.logic.model.model.ViewModelModifiable; import net.mograsim.logic.model.model.components.GUIComponent; +import net.mograsim.logic.model.model.components.submodels.SubmodelComponent; import net.mograsim.logic.model.model.wires.GUIWire; import net.mograsim.logic.model.model.wires.MovablePin; import net.mograsim.logic.model.model.wires.Pin; @@ -86,7 +87,7 @@ public class HandleManager ViewModelModifiable model = editor.getSubmodel(); Map compsByName = model.getComponentsByName(); Set comps = new HashSet<>(compsByName.values()); - GUIComponent interfaceComp = compsByName.get("_submodelinterface"); + GUIComponent interfaceComp = compsByName.get(SubmodelComponent.SUBMODEL_INTERFACE_NAME); comps.remove(interfaceComp); registerInterfaceComponent(interfaceComp); comps.forEach(c -> registerComponent(c)); @@ -121,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) @@ -216,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) @@ -342,6 +346,7 @@ public class HandleManager { EditorState entryState = editor.stateManager.getState(); + // TODO: As soon as wires connected to a component being removed also are removed, change priority if (!cornerHandle.click(clicked.x, clicked.y, stateMask, entryState)) if (!click(handlePerPin.values(), clicked, entryState, stateMask)) if (!click(handlePerInterfacePin.values(), clicked, entryState, stateMask))