From: Daniel Kirschten Date: Mon, 16 Sep 2019 15:51:29 +0000 (+0200) Subject: Removed legacy ModelMerger X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=b747938743350ebf62c48348506899dc7b867f21;p=Mograsim.git Removed legacy ModelMerger --- diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelMerger.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelMerger.java deleted file mode 100644 index 6efc9ad3..00000000 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelMerger.java +++ /dev/null @@ -1,126 +0,0 @@ -package net.mograsim.logic.model.model.components.atomic; - -import org.eclipse.swt.SWT; - -import net.haspamelodica.swt.helper.gcs.GeneralGC; -import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; -import net.mograsim.logic.core.types.BitVectorFormatter; -import net.mograsim.logic.core.wires.CoreWire.ReadEnd; -import net.mograsim.logic.model.model.LogicModelModifiable; -import net.mograsim.logic.model.model.components.ModelComponent; -import net.mograsim.logic.model.model.components.Orientation; -import net.mograsim.logic.model.model.components.atomic.ModelSplitter.SplitterParams; -import net.mograsim.logic.model.model.wires.Pin; -import net.mograsim.logic.model.model.wires.PinUsage; -import net.mograsim.logic.model.modeladapter.LogicCoreAdapter; -import net.mograsim.logic.model.modeladapter.componentadapters.MergerAdapter; -import net.mograsim.logic.model.serializing.IdentifyParams; -import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; -import net.mograsim.preferences.ColorDefinition; -import net.mograsim.preferences.ColorManager; -import net.mograsim.preferences.Preferences; - -//TODO delete this legacy class -public class ModelMerger extends ModelComponent -{ - private static final double width = 10; - private static final double heightPerPin = 10; - - public final int logicWidth; - private final Pin outputPin; - - private final ReadEnd[] inputEnds; - private ReadEnd outputEnd; - - public ModelMerger(LogicModelModifiable model, int logicWidth) - { - this(model, logicWidth, null); - } - - public ModelMerger(LogicModelModifiable model, int logicWidth, String name) - { - super(model, name, false); - this.logicWidth = logicWidth; - setSize(width, (logicWidth - 1) * heightPerPin); - double inputHeight = (logicWidth - 1) * heightPerPin; - for (int i = 0; i < logicWidth; i++, inputHeight -= 10) - addPin(new Pin(model, this, "O" + i, 1, PinUsage.TRISTATE, 0, inputHeight)); - addPin(this.outputPin = new Pin(model, this, "I", logicWidth, PinUsage.TRISTATE, width, (logicWidth - 1) * heightPerPin / 2)); - inputEnds = new ReadEnd[logicWidth]; - - init(); - } - - @Override - public void render(GeneralGC gc, Rectangle visibleRegion) - { - double posX = getPosX(); - double posY = getPosY(); - - ColorDefinition c = BitVectorFormatter.formatAsColor(outputEnd); - if (c != null) - gc.setForeground(ColorManager.current().toColor(c)); - gc.setLineWidth( - Preferences.current().getDouble("net.mograsim.logic.model.linewidth.wire." + (logicWidth == 1 ? "singlebit" : "multibit"))); - double outLineY = posY + (logicWidth - 1) * heightPerPin / 2; - gc.drawLine(posX + width / 2, outLineY, posX + width, outLineY); - gc.setLineWidth(Preferences.current().getDouble("net.mograsim.logic.model.linewidth.wire.singlebit")); - double inputHeight = posY; - for (int i = 0; i < logicWidth; i++, inputHeight += 10) - { - c = BitVectorFormatter.formatAsColor(inputEnds[i]); - if (c != null) - gc.setForeground(ColorManager.current().toColor(c)); - gc.drawLine(posX, inputHeight, posX + width / 2, inputHeight); - } - gc.setForeground(Preferences.current().getColor("net.mograsim.logic.model.color.foreground")); - int oldLineCap = gc.getLineCap(); - int lineJoin = gc.getLineJoin(); - // TODO find better "replacement" for JOIN_BEVEL - // TODO it looks weird that the vertical line is thinner than the single multibit wire. - gc.setLineCap(lineJoin == SWT.JOIN_MITER ? SWT.CAP_SQUARE : lineJoin == SWT.JOIN_ROUND ? SWT.CAP_ROUND : SWT.CAP_SQUARE); - gc.drawLine(posX + width / 2, posY, posX + width / 2, posY + heightPerPin * (logicWidth - 1)); - gc.setLineWidth(Preferences.current().getDouble("net.mograsim.logic.model.linewidth.default")); - gc.setLineCap(oldLineCap); - } - - @Override - public Pin getPin(String name) - { - Pin pin = getPinOrNull(name); - return pin == null ? getPin(name.replace('O', 'i').replace('I', 'O').replace('i', 'I')) : pin; - } - - @Override - public String getIDForSerializing(IdentifyParams idParams) - { - return "Splitter"; - } - - @Override - public SplitterParams getParamsForSerializing(IdentifyParams idParams) - { - SplitterParams splitterParams = new SplitterParams(); - splitterParams.logicWidth = logicWidth; - splitterParams.orientation = Orientation.LEFT; - return splitterParams; - } - - public void setCoreModelBinding(ReadEnd[] inputEnds, ReadEnd outputEnd) - { - System.arraycopy(inputEnds, 0, this.inputEnds, 0, logicWidth); - this.outputEnd = outputEnd; - } - - public Pin getOutputPin() - { - return outputPin; - } - - static - { - LogicCoreAdapter.addComponentAdapter(new MergerAdapter()); - IndirectModelComponentCreator.setComponentSupplier(ModelMerger.class.getCanonicalName(), - (m, p, n) -> new ModelMerger(m, p.getAsInt(), n)); - } -} \ No newline at end of file diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/componentadapters/MergerAdapter.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/componentadapters/MergerAdapter.java deleted file mode 100644 index 22d61122..00000000 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/componentadapters/MergerAdapter.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.mograsim.logic.model.modeladapter.componentadapters; - -import java.util.Map; - -import net.mograsim.logic.core.timeline.Timeline; -import net.mograsim.logic.core.wires.CoreWire; -import net.mograsim.logic.core.wires.CoreWire.ReadEnd; -import net.mograsim.logic.model.model.components.atomic.ModelMerger; -import net.mograsim.logic.model.model.wires.Pin; -import net.mograsim.logic.model.modeladapter.CoreModelParameters; - -public class MergerAdapter implements ComponentAdapter -{ - @Override - public Class getSupportedClass() - { - return ModelMerger.class; - } - - @Override - public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, ModelMerger modelComponent, - Map logicWiresPerPin) - { - CoreWire output = logicWiresPerPin.get(modelComponent.getPin("O")); - ReadEnd[] inputEnds = new ReadEnd[modelComponent.logicWidth]; - for (int i = 0; i < modelComponent.logicWidth; i++) - { - CoreWire input = logicWiresPerPin.get(modelComponent.getPin("I" + (modelComponent.logicWidth - 1 - i))); - CoreWire.fuse(input, output, 0, i); - inputEnds[i] = input.createReadOnlyEnd(); - } - modelComponent.setCoreModelBinding(inputEnds, output.createReadOnlyEnd()); - } -} \ No newline at end of file diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/standardComponentIDMapping.json b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/standardComponentIDMapping.json index 00cbca1e..9da19e52 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/standardComponentIDMapping.json +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/standardComponentIDMapping.json @@ -4,7 +4,6 @@ "Clock": "class:net.mograsim.logic.model.model.components.atomic.ModelClock", "FixedOutput": "class:net.mograsim.logic.model.model.components.atomic.ModelFixedOutput", "ManualSwitch": "class:net.mograsim.logic.model.model.components.atomic.ModelManualSwitch", - "Merger": "class:net.mograsim.logic.model.model.components.atomic.ModelMerger", "NandGate": "class:net.mograsim.logic.model.model.components.atomic.ModelNandGate", "OrGate": "class:net.mograsim.logic.model.model.components.atomic.ModelOrGate", "Splitter": "class:net.mograsim.logic.model.model.components.atomic.ModelSplitter",