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 SubmodelComponentParams
17 public double width, height;
18 public InterfacePinParams[] interfacePins;
19 public SubmodelParameters submodel;
21 // functionality that needs to be expressed in Java code
22 public String outlineRendererSnippetID;
23 public JsonElement outlineRendererParams;
25 public String symbolRendererSnippetID;
26 public JsonElement symbolRendererParams;
28 public String highLevelStateHandlerSnippetID;
29 public JsonElement highLevelStateHandlerParams;
31 public static class InterfacePinParams
33 public Point location;
35 public int logicWidth;
38 public static class SubmodelParameters
40 public double innerScale;
41 public InnerComponentParams[] subComps;
42 public InnerWireParams[] innerWires;
44 public static class InnerComponentParams
49 public JsonElement params;
52 public static class InnerWireParams
54 public InnerPinParams pin1, pin2;
57 public static class InnerPinParams
59 public String compName;
60 public String pinName;
65 public static SubmodelComponentParams readJson(String path) throws IOException
67 return JsonHandler.readJson(path, SubmodelComponentParams.class);
71 * Writes this {@link SubmodelComponentParams} object into a file in json format. The correct file extension is important! Check
72 * {@link SubmodelComponentParams}.fileExtension
74 public void writeJson(String path)
78 JsonHandler.writeJson(this, path);
82 System.err.println("Failed to write SubComponentParams to file");