"symbolRendererParams": {
"centerText": "_rsLatch",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "and",
+ "centerText": "GUIand",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "and41",
+ "centerText": "GUIand41",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "andor414",
+ "centerText": "GUIandor414",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "demux2",
+ "centerText": "GUIdemux2",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "dff",
+ "centerText": "GUIdff",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "dlatch",
+ "centerText": "GUIdlatch",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "dlatch4",
+ "centerText": "GUIdlatch4",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "fulladder",
+ "centerText": "GUIfulladder",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "halfadder",
+ "centerText": "GUIhalfadder",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "mux1",
+ "centerText": "GUImux1",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "mux1_4",
+ "centerText": "GUImux1_4",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "nand3",
+ "centerText": "GUInand3",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "not4",
+ "centerText": "GUInot4",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "or4",
+ "centerText": "GUIor4",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "or_4",
+ "centerText": "GUIor_4",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "ram2",
+ "centerText": "GUIram2",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "ram4",
+ "centerText": "GUIram4",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "sel2_4",
+ "centerText": "GUIsel2_4",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "sel3_4",
+ "centerText": "GUIsel3_4",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "xor",
+ "centerText": "GUIxor",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "Am2901",
+ "centerText": "GUIAm2901",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "Am2901ALUFuncDecode",
+ "centerText": "GUIAm2901ALUFuncDecode",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "Am2901ALUInclDecode",
+ "centerText": "GUIAm2901ALUInclDecode",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "Am2901ALUInclSourceDecodeInclFunctionDecode",
+ "centerText": "GUIAm2901ALUInclSourceDecodeInclFunctionDecode",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "Am2901ALUOneBit",
+ "centerText": "GUIAm2901ALUOneBit",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "Am2901DestDecode",
+ "centerText": "GUIAm2901DestDecode",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
},
"symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
"symbolRendererParams": {
- "centerText": "Am2901QReg",
+ "centerText": "GUIAm2901QReg",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
"symbolRendererParams": {
"centerText": "Am2901SourceDecode",
"horizontalComponentCenter": 17.5,
- "centerTextHeight": 5,
+ "centerTextHeight": 5.0,
"pinLabelHeight": 3.5,
"pinLabelMargin": 0.5
}
import java.io.IOException;
import java.util.function.Function;
-import com.google.gson.JsonObject;
-
import net.mograsim.logic.ui.model.ViewModelModifiable;
import net.mograsim.logic.ui.model.components.GUIComponent;
import net.mograsim.logic.ui.model.components.mi.nandbased.GUI_rsLatch;
for (SubmodelComponent comp : components)
{
SubmodelComponentParams params = comp.calculateParams(getIdentifier);
- JsonObject symbolRendererParams = new JsonObject();
- symbolRendererParams.addProperty("centerText", comp.getClass().getSimpleName().substring(3)); // cut away the "GUI" part
- symbolRendererParams.addProperty("horizontalComponentCenter", comp.getWidth() / 2);
- // use the defaults from SimpleRectangularSubmodelComponent
- symbolRendererParams.addProperty("centerTextHeight", 5);
- symbolRendererParams.addProperty("pinLabelHeight", 3.5);
- symbolRendererParams.addProperty("pinLabelMargin", .5);
- params.symbolRendererSnippetID = "SimpleRectangularLikeSymbolRenderer";
- params.symbolRendererParams = symbolRendererParams;
JsonHandler.writeJson(params, "components/"
+ comp.getClass().getName().substring("net.mograsim.logic.ui.model.components.mi.nandbased.".length()).replace('.', '/')
+ ".json");
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.function.Function;
import org.eclipse.swt.graphics.Color;
+import com.google.gson.JsonObject;
+
import net.haspamelodica.swt.helper.gcs.GeneralGC;
import net.haspamelodica.swt.helper.swtobjectwrappers.Font;
import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
import net.mograsim.logic.ui.model.ViewModelModifiable;
+import net.mograsim.logic.ui.model.components.GUIComponent;
import net.mograsim.logic.ui.model.wires.MovablePin;
import net.mograsim.logic.ui.model.wires.Pin;
+import net.mograsim.logic.ui.serializing.SubmodelComponentParams;
import net.mograsim.preferences.Preferences;
public class SimpleRectangularSubmodelComponent extends SubmodelComponent
gc.drawRectangle(getBounds());
}
+ // serializing
+
+ @Override
+ public SubmodelComponentParams calculateParams(Function<GUIComponent, String> getIdentifier)
+ {
+ SubmodelComponentParams params = super.calculateParams(getIdentifier);
+ JsonObject symbolRendererParams = new JsonObject();
+ symbolRendererParams.addProperty("centerText", label);
+ symbolRendererParams.addProperty("horizontalComponentCenter", getWidth() / 2);
+ symbolRendererParams.addProperty("centerTextHeight", labelFontHeight);
+ symbolRendererParams.addProperty("pinLabelHeight", pinNameFontHeight);
+ symbolRendererParams.addProperty("pinLabelMargin", pinNameMargin);
+ params.symbolRendererSnippetID = "SimpleRectangularLikeSymbolRenderer";
+ params.symbolRendererParams = symbolRendererParams;
+ return params;
+ }
+
@Override
protected Pin addSubmodelInterface(MovablePin supermodelPin)
{