33f00e15716a7146ac81ba8218bfbdeb39cc834e
[Mograsim.git] /
1 package net.mograsim.logic.model.serializing;
2
3 import com.google.gson.JsonElement;
4
5 import net.mograsim.logic.model.model.LogicModelModifiable;
6 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
7 import net.mograsim.logic.model.model.wires.MovablePin;
8 import net.mograsim.logic.model.model.wires.Pin;
9 import net.mograsim.logic.model.snippets.HighLevelStateHandler;
10 import net.mograsim.logic.model.snippets.Renderer;
11
12 public class DeserializedSubmodelComponent extends SubmodelComponent
13 {
14         /**
15          * If a DeserializedSubmodelComponent is part of another SubmodelComponent, when it it serialized, it should not return its internal
16          * structure, but rather the component ID used to create it.
17          * 
18          * @see SubmodelComponentSerializer#deserialize(LogicModelModifiable, SubmodelComponentParams, String, String, JsonElement)
19          *      SubmodelComponentSerializer.deserialize(...)
20          * @see SubmodelComponentSerializer#serialize(SubmodelComponent, java.util.function.Function) SubmodelComponentSerializer.serialize(...)
21          */
22         public final String idForSerializingOverride;
23         /**
24          * See {@link #idForSerializingOverride}
25          */
26         public final JsonElement paramsForSerializingOverride;
27
28         public DeserializedSubmodelComponent(LogicModelModifiable model, String name, String idForSerializingOverride,
29                         JsonElement paramsForSerializingOverride)
30         {
31                 super(model, name, false);
32                 this.idForSerializingOverride = idForSerializingOverride;
33                 this.paramsForSerializingOverride = paramsForSerializingOverride;
34                 init();
35         }
36
37         @Override
38         public void setSymbolRenderer(Renderer symbolRenderer)
39         {
40                 super.setSymbolRenderer(symbolRenderer);
41         }
42
43         @Override
44         public void setOutlineRenderer(Renderer outlineRenderer)
45         {
46                 super.setOutlineRenderer(outlineRenderer);
47         }
48
49         @Override
50         public void setHighLevelStateHandler(HighLevelStateHandler handler)
51         {
52                 super.setHighLevelStateHandler(handler);
53         }
54
55         public LogicModelModifiable getSubmodelModifiable()
56         {
57                 return submodelModifiable;
58         }
59
60         @Override
61         public void setSubmodelScale(double submodelScale)
62         {
63                 super.setSubmodelScale(submodelScale);
64         }
65
66         @Override
67         public void setSize(double width, double height)
68         {
69                 super.setSize(width, height);
70         }
71
72         @Override
73         public Pin addSubmodelInterface(MovablePin supermodelPin)
74         {
75                 return super.addSubmodelInterface(supermodelPin);
76         }
77
78         @Override
79         public void removeSubmodelInterface(String name)
80         {
81                 super.removeSubmodelInterface(name);
82         }
83 }