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;
ViewModelModifiable model = editor.getSubmodel();
Map<String, GUIComponent> compsByName = model.getComponentsByName();
Set<GUIComponent> 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));
{
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)
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)
{
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))