1 package net.mograsim.logic.ui.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.ui.model.components.submodels.SubmodelComponent;
9 import net.mograsim.logic.ui.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 static class InterfacePinParams
30 public Point location;
32 public int logicWidth;
35 public static class SubmodelParameters
37 public double innerScale;
38 public InnerComponentParams[] subComps;
39 public InnerWireParams[] innerWires;
41 public static class InnerComponentParams
46 public JsonElement params;
49 public static class InnerWireParams
51 public InnerPinParams pin1, pin2;
54 public static class InnerPinParams
56 public String compName;
57 public String pinName;
62 public static SubmodelComponentParams readJson(String path) throws IOException
64 return JsonHandler.readJson(path, SubmodelComponentParams.class);
68 * Writes this {@link SubmodelComponentParams} object into a file in json format. The correct file extension is important! Check
69 * {@link SubmodelComponentParams}.fileExtension
71 public void writeJson(String path)
75 JsonHandler.writeJson(this, path);
79 System.err.println("Failed to write SubComponentParams to file");