1 package net.mograsim.logic.model.serializing;
3 import java.io.IOException;
5 import com.google.gson.JsonElement;
7 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
8 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
9 import net.mograsim.logic.model.util.JsonHandler;
12 * This class contains all the information necessary to create a new {@link SubmodelComponent}
14 public class LegacySubmodelComponentParams
17 public double width, height;
18 public LegacyInterfacePinParams[] interfacePins;
19 public LegacySubmodelParameters submodel;
21 // functionality that needs to be expressed in Java code
22 public String symbolRendererSnippetID;
23 public JsonElement symbolRendererParams;
25 public String outlineRendererSnippetID;
26 public JsonElement outlineRendererParams;
28 public String highLevelStateHandlerSnippetID;
29 public JsonElement highLevelStateHandlerParams;
31 public static class LegacyInterfacePinParams
33 public Point location;
35 public int logicWidth;
38 public static class LegacySubmodelParameters
40 public double innerScale;
41 public LegacyInnerComponentParams[] subComps;
42 public LegacyInnerWireParams[] innerWires;
44 public static class LegacyInnerComponentParams
49 public JsonElement params;
52 public static class LegacyInnerWireParams
54 public LegacyInnerPinParams pin1, pin2;
58 public static class LegacyInnerPinParams
60 public String compName;
61 public String pinName;
66 public static LegacySubmodelComponentParams readJson(String path) throws IOException
68 return JsonHandler.readJson(path, LegacySubmodelComponentParams.class);
72 * Writes this {@link LegacySubmodelComponentParams} object into a file in json format. The correct file extension is important! Check
73 * {@link LegacySubmodelComponentParams}.fileExtension
75 public void writeJson(String path)
79 JsonHandler.writeJson(this, path);
83 System.err.println("Failed to write SubComponentParams to file");