package net.mograsim.logic.model.editor;
+import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
dialogManager = new DialogManager(gui.shell);
toBeEdited.submodel.addComponentRemovedListener(c -> identifierPerComponent.remove(c));
-
+
gui.open();
}
-
+
public ViewModelModifiable getSubmodel()
{
return toBeEdited.getSubmodelModifiable();
return selection;
}
- //TODO: Remove this error prone method: Relative offset may change between multiple moves,
- //because Handles have different ways of responding to reqMove(...), causing strange behaviour
+ // TODO: Remove this error prone method: Relative offset may change between multiple moves,
+ // because Handles have different ways of responding to reqMove(...), causing strange behaviour
@Deprecated
public void moveSelection(double x, double y)
{
c.reqMove(newX, newY);
}
}
-
+
public void moveHandles(double x, double y, Map<Handle, Point> handleOffsetMap)
{
Point snapped = new Point(x, y);
for (Handle h : selection)
{
Optional<ComponentInfo> cInfo = h.reqCopy(refPoint);
- if(cInfo.isPresent())
+ if (cInfo.isPresent())
copyBuffer.add(cInfo.get());
}
}
}
moveSelection(x, y);
}
-
+
public void save()
{
saveManager.save();
}
-
+
public void saveAs()
{
saveManager.openSaveAsDialog();
{
boolean successful = false;
JsonElement params = JsonNull.INSTANCE;
- outer:
- while(!successful)
+ outer: while (!successful)
{
String selected = gui.getAddListSelected();
try
moveSelection(x, y);
successful = true;
}
- catch(UnsupportedOperationException | JsonSyntaxException | NumberFormatException e)
+ catch (@SuppressWarnings("unused") UnsupportedOperationException | JsonSyntaxException | NumberFormatException e)
{
String result = DialogManager.openMultiLineTextDialog("Add component", "Create", "Cancel", "Parameters:");
- if(result == null)
+ if (result == null)
break outer;
params = new JsonParser().parse(result);
}
}
}
-
+
private GUIComponent addComponent(String identifier, JsonElement params)
{
- GUIComponent comp = IndirectGUIComponentCreator.createComponent(toBeEdited.getSubmodelModifiable(), identifier,
- params);
+ GUIComponent comp = IndirectGUIComponentCreator.createComponent(toBeEdited.getSubmodelModifiable(), identifier, params);
identifierPerComponent.put(comp, identifier);
return comp;
}
-
+
public static String getIdentifier(GUIComponent c)
{
return identifierPerComponent.get(c);
newP.x -= newP.x % snapX;
newP.y -= newP.y % snapY;
break;
+ default:
+ break;
}
}
public final double relX, relY;
public final String identifier;
public final JsonElement params;
-
+
public ComponentInfo(double relX, double relY, String identifier, JsonElement params)
{
this.relX = relX;
}
}
+ @SuppressWarnings("unused")
public void addWire(PinHandle a, PinHandle b)
{
new GUIWire(toBeEdited.getSubmodelModifiable(), a.getPin(), b.getPin(), new Point[0]);
public static enum Snapping
{
OFF, ABSOLUTE;
-
+
@Override
public String toString()
{
return super.toString().toLowerCase();
}
}
-
- public static void main(String[] args)
+
+ public static void main(String[] args) throws IOException
{
SaveLoadManager.openLoadDialog();
}