"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "_rsLatch",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
}
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "and",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "and41",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
]
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "andor414",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
}
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "demux2",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
}
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "dff",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
}
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "dlatch",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "dlatch4",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
}
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "fulladder",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "halfadder",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
}
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "mux1",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
}
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "mux1_4",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "nand3",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "not4",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
}
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "or4",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "or_4",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
]
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "ram2",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
]
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "ram4",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "sel2_4",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "sel3_4",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
}
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "xor",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "Am2901",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "Am2901ALUFuncDecode",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
}
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "Am2901ALUInclDecode",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
]
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "Am2901ALUInclSourceDecodeInclFunctionDecode",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "Am2901ALUOneBit",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "Am2901DestDecode",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "Am2901QReg",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
"path": []
}
]
+ },
+ "symbolRendererSnippetID": "SimpleRectangularLikeSymbolRenderer",
+ "symbolRendererParams": {
+ "centerText": "Am2901SourceDecode",
+ "horizontalComponentCenter": 17.5,
+ "centerTextHeight": 5,
+ "pinLabelHeight": 3.5,
+ "pinLabelMargin": 0.5
}
}
\ No newline at end of file
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");
@Override
protected void renderSymbol(GeneralGC gc, Rectangle visibleRegion)
{
+ // TODO code duplication: see SimpleRectagularLikeSymbolRendererProvider
Font oldFont = gc.getFont();
gc.setFont(new Font(oldFont.getName(), labelFontHeight, oldFont.getStyle()));
Point textExtent = gc.textExtent(label);
import com.google.gson.JsonElement;
-import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
-import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
import net.mograsim.logic.ui.serializing.snippets.Renderer;
import net.mograsim.logic.ui.serializing.snippets.RendererProvider;
+import net.mograsim.logic.ui.serializing.snippets.outlinerenderers.DefaultOutlineRendererProvider;
+import net.mograsim.logic.ui.serializing.snippets.symbolrenderers.DefaultSymbolRendererProvider;
import net.mograsim.logic.ui.util.JsonHandler;
-import net.mograsim.preferences.ColorDefinition;
-import net.mograsim.preferences.ColorManager;
-import net.mograsim.preferences.Preferences;
public class CodeSnippetSupplier
{
private static final RendererProvider defaultSymbolRendererProvider;
static
{
- // TODO this code does not belong here
- defaultOutlineRendererProvider = (comp, params) -> (gc, visReg) ->
- {
- ColorDefinition fg = Preferences.current().getColorDefinition("net.mograsim.logic.ui.color.foreground");
- if (fg != null)
- gc.setForeground(ColorManager.current().toColor(fg));
- gc.drawRectangle(comp.getBounds());
- };
- defaultSymbolRendererProvider = (comp, params) -> (gc, visReg) ->
- {
- ColorDefinition fg = Preferences.current().getColorDefinition("net.mograsim.logic.ui.color.text");
- if (fg != null)
- gc.setForeground(ColorManager.current().toColor(fg));
- String id = "TODO";// TODO add an ID of sorts to DeserializedSubmodelComponent
- Point idSize = gc.textExtent(id);
- Rectangle bounds = comp.getBounds();
- gc.drawText(id, bounds.x + (bounds.width - idSize.x) / 2, bounds.y + (bounds.height - idSize.y) / 2, true);
- };
+ defaultOutlineRendererProvider = new DefaultOutlineRendererProvider();
+ defaultSymbolRendererProvider = new DefaultSymbolRendererProvider();
}
static
return specializedCode;
}
}
+ System.err.println("Couldn't load snippet " + id + "; using default");
return defaultSnippet;
}
private static void tryLoadSnippetClass(String snippetClassName)
{
- tryInvokeStaticInitializer(snippetClassName, "Error getting snippet code for component class: %s: %s\n");
+ tryInvokeStaticInitializer(snippetClassName, "Error getting snippet class: %s: %s\n");
}
public static void tryInvokeStaticInitializer(String className, String errorMessageFormat)
DeserializedSubmodelComponent comp = new DeserializedSubmodelComponent(model);
comp.setSubmodelScale(params.submodel.innerScale);
comp.setOutlineRenderer(
- CodeSnippetSupplier.createOutlineRenderer(params.outlineRendererSnippetClass, comp, params.outlineRendererParams));
- comp.setSymbolRenderer(
- CodeSnippetSupplier.createSymbolRenderer(params.symbolRendererSnippetClass, comp, params.symbolRendererParams));
+ CodeSnippetSupplier.createOutlineRenderer(params.outlineRendererSnippetID, comp, params.outlineRendererParams));
+ comp.setSymbolRenderer(CodeSnippetSupplier.createSymbolRenderer(params.symbolRendererSnippetID, comp, params.symbolRendererParams));
// TODO high level states
comp.setSize(params.width, params.height);
for (InterfacePinParams iPinParams : params.interfacePins)
public SubmodelParameters submodel;
// functionality that needs to be expressed in Java code
- public String outlineRendererSnippetClass;
+ public String outlineRendererSnippetID;
public JsonElement outlineRendererParams;
- public String symbolRendererSnippetClass;
+ public String symbolRendererSnippetID;
public JsonElement symbolRendererParams;
public static class InterfacePinParams
--- /dev/null
+package net.mograsim.logic.ui.serializing.snippets.outlinerenderers;
+
+import com.google.gson.JsonElement;
+
+import net.mograsim.logic.ui.serializing.DeserializedSubmodelComponent;
+import net.mograsim.logic.ui.serializing.snippets.Renderer;
+import net.mograsim.logic.ui.serializing.snippets.RendererProvider;
+import net.mograsim.preferences.ColorDefinition;
+import net.mograsim.preferences.ColorManager;
+import net.mograsim.preferences.Preferences;
+
+public class DefaultOutlineRendererProvider implements RendererProvider
+{
+ @Override
+ public Renderer create(DeserializedSubmodelComponent component, JsonElement params)
+ {
+ return (gc, visReg) ->
+ {
+ ColorDefinition fg = Preferences.current().getColorDefinition("net.mograsim.logic.ui.color.foreground");
+ if (fg != null)
+ gc.setForeground(ColorManager.current().toColor(fg));
+ gc.drawRectangle(component.getBounds());
+ };
+
+ }
+}
\ No newline at end of file
--- /dev/null
+package net.mograsim.logic.ui.serializing.snippets.symbolrenderers;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+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.serializing.CodeSnippetSupplier;
+import net.mograsim.logic.ui.serializing.DeserializedSubmodelComponent;
+import net.mograsim.logic.ui.serializing.snippets.Renderer;
+import net.mograsim.logic.ui.serializing.snippets.RendererProvider;
+import net.mograsim.preferences.ColorDefinition;
+import net.mograsim.preferences.ColorManager;
+import net.mograsim.preferences.Preferences;
+
+/**
+ * Renders a text (<code>"text"</code>) with a given font height (<code>"height"</code>) in the center of the component.<br>
+ * Parameter format:
+ *
+ * <pre>
+ * {
+ * "text": [String]
+ * "height": [int]
+ * }
+ * </pre>
+ *
+ * @author Daniel Kirschten
+ */
+public class CenteredTextSymbolRendererProvider implements RendererProvider
+{
+ @Override
+ public Renderer create(DeserializedSubmodelComponent component, JsonElement params)
+ {
+ JsonObject asJsonObject = params.getAsJsonObject();
+ String text = asJsonObject.getAsJsonPrimitive("text").getAsString();
+ int fontHeight = asJsonObject.getAsJsonPrimitive("height").getAsInt();
+ return (gc, visReg) ->
+ {
+ Font oldFont = gc.getFont();
+ gc.setFont(new Font(oldFont.getName(), fontHeight, oldFont.getStyle()));
+ ColorDefinition fg = Preferences.current().getColorDefinition("net.mograsim.logic.ui.color.text");
+ if (fg != null)
+ gc.setForeground(ColorManager.current().toColor(fg));
+ Point idSize = gc.textExtent(text);
+ Rectangle bounds = component.getBounds();
+ gc.drawText(text, bounds.x + (bounds.width - idSize.x) / 2, bounds.y + (bounds.height - idSize.y) / 2, true);
+ gc.setFont(oldFont);
+ };
+ }
+
+ static
+ {
+ CodeSnippetSupplier.setSymbolRendererProvider(CenteredTextSymbolRendererProvider.class.getCanonicalName(),
+ new CenteredTextSymbolRendererProvider());
+ }
+}
\ No newline at end of file
--- /dev/null
+package net.mograsim.logic.ui.serializing.snippets.symbolrenderers;
+
+import com.google.gson.JsonElement;
+
+import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
+import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
+import net.mograsim.logic.ui.serializing.DeserializedSubmodelComponent;
+import net.mograsim.logic.ui.serializing.snippets.Renderer;
+import net.mograsim.logic.ui.serializing.snippets.RendererProvider;
+import net.mograsim.preferences.ColorDefinition;
+import net.mograsim.preferences.ColorManager;
+import net.mograsim.preferences.Preferences;
+
+public class DefaultSymbolRendererProvider implements RendererProvider
+{
+ private static final String id = "<Symbol\nunknown>";
+
+ @Override
+ public Renderer create(DeserializedSubmodelComponent component, JsonElement params)
+ {
+ return (gc, visReg) ->
+ {
+ ColorDefinition fg = Preferences.current().getColorDefinition("net.mograsim.logic.ui.color.text");
+ if (fg != null)
+ gc.setForeground(ColorManager.current().toColor(fg));
+ Point idSize = gc.textExtent(id);
+ Rectangle bounds = component.getBounds();
+ gc.drawText(id, bounds.x + (bounds.width - idSize.x) / 2, bounds.y + (bounds.height - idSize.y) / 2, true);
+ };
+ }
+}
\ No newline at end of file
--- /dev/null
+package net.mograsim.logic.ui.serializing.snippets.symbolrenderers;
+
+import java.util.Map.Entry;
+
+import org.eclipse.swt.graphics.Color;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+import net.haspamelodica.swt.helper.swtobjectwrappers.Font;
+import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
+import net.mograsim.logic.ui.model.wires.Pin;
+import net.mograsim.logic.ui.serializing.CodeSnippetSupplier;
+import net.mograsim.logic.ui.serializing.DeserializedSubmodelComponent;
+import net.mograsim.logic.ui.serializing.snippets.Renderer;
+import net.mograsim.logic.ui.serializing.snippets.RendererProvider;
+import net.mograsim.preferences.Preferences;
+
+/**
+ * Renders a text (<code>"centerText"</code>) with a given font height (<code>"centerTextHeight"</code>) in the center of the component and
+ * draws a label for each pin with a given font height (<code>"pinLabelHeight"</code>). The labels of pins to the left of a given x
+ * coordinate (<code>"horizontalComponentCenter"</code>) are drawn to the right of the respective pin; labels of pins to the right are drawn
+ * left. A margin (<code>"pinLabelMargin"</code>) is applied for pin label drawing.<br>
+ * Parameter format:
+ *
+ * <pre>
+ * {
+ * "centerText": [String]
+ * "centerTextHeight": [double]
+ * "horizontalComponentCenter": [double]
+ * "pinLabelHeight": [double]
+ * "pinLabelMargin": [double]
+ * }
+ * </pre>
+ *
+ * @author Daniel Kirschten
+ */
+public class SimpleRectangularLikeSymbolRendererProvider implements RendererProvider
+{
+ @Override
+ public Renderer create(DeserializedSubmodelComponent component, JsonElement params)
+ {
+ JsonObject asJsonObject = params.getAsJsonObject();
+ String centerText = asJsonObject.getAsJsonPrimitive("centerText").getAsString();
+ double centerTextHeight = asJsonObject.getAsJsonPrimitive("centerTextHeight").getAsDouble();
+ double horizontalComponentCenter = asJsonObject.getAsJsonPrimitive("horizontalComponentCenter").getAsDouble();
+ double pinLabelHeight = asJsonObject.getAsJsonPrimitive("pinLabelHeight").getAsDouble();
+ double pinLabelMargin = asJsonObject.getAsJsonPrimitive("pinLabelMargin").getAsDouble();
+ return (gc, visReg) ->
+ {
+ double posX = component.getPosX();
+ double posY = component.getPosY();
+ double width = component.getWidth();
+ double height = component.getHeight();
+
+ Font oldFont = gc.getFont();
+ gc.setFont(new Font(oldFont.getName(), centerTextHeight, oldFont.getStyle()));
+ Point textExtent = gc.textExtent(centerText);
+ Color textColor = Preferences.current().getColor("net.mograsim.logic.ui.color.text");
+ if (textColor != null)
+ gc.setForeground(textColor);
+ gc.drawText(centerText, posX + (width - textExtent.x) / 2, posY + (height - textExtent.y) / 2, true);
+ gc.setFont(new Font(oldFont.getName(), pinLabelHeight, oldFont.getStyle()));
+ for (Entry<String, Pin> pinEntry : component.getPins().entrySet())
+ {
+ String pinName = pinEntry.getKey();
+ Pin pin = pinEntry.getValue();
+ double pinX = pin.getRelX();
+ double pinY = posY + pin.getRelY();
+ textExtent = gc.textExtent(pinName);
+ gc.drawText(pinName, posX + pinX + (pinX > horizontalComponentCenter ? -textExtent.x - pinLabelMargin : pinLabelMargin),
+ pinY - textExtent.y / 2, true);
+ }
+ gc.setFont(oldFont);
+ };
+ }
+
+ static
+ {
+ CodeSnippetSupplier.setSymbolRendererProvider(SimpleRectangularLikeSymbolRendererProvider.class.getCanonicalName(),
+ new SimpleRectangularLikeSymbolRendererProvider());
+ }
+}
\ No newline at end of file
mograsim version: 0.1.3
{
+ "CenteredTextSymbolRenderer": "net.mograsim.logic.ui.serializing.snippets.symbolrenderers.CenteredTextSymbolRendererProvider",
+ "SimpleRectangularLikeSymbolRenderer": "net.mograsim.logic.ui.serializing.snippets.symbolrenderers.SimpleRectangularLikeSymbolRendererProvider"
}
\ No newline at end of file