X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fmodel%2Fcomponents%2Fatomic%2FSimpleRectangularModelGate.java;h=89366013892ec806c46f9293b2deac7292e55e72;hb=8bed58cd47f4e53a0a83e066d38864aa6875502f;hp=890c482f9bbe0aa52219bfb2523b9179b44416df;hpb=93b398d6271a538a2a4c9f4de07a3b4a8a2a7fd4;p=Mograsim.git diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/SimpleRectangularModelGate.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/SimpleRectangularModelGate.java index 890c482f..89366013 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/SimpleRectangularModelGate.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/SimpleRectangularModelGate.java @@ -11,7 +11,7 @@ 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.model.model.ViewModelModifiable; +import net.mograsim.logic.model.model.LogicModelModifiable; import net.mograsim.logic.model.model.components.ModelComponent; import net.mograsim.logic.model.model.wires.MovablePin; import net.mograsim.logic.model.model.wires.Pin; @@ -36,18 +36,28 @@ public class SimpleRectangularModelGate extends ModelComponent private MovablePin outputPin; private final List inputPins; - protected SimpleRectangularModelGate(ViewModelModifiable model, String id, String label, boolean isInverted, int logicWidth, String name) + protected SimpleRectangularModelGate(LogicModelModifiable model, String id, String label, boolean isInverted, int logicWidth, + String name) { - super(model, name); + this(model, id, label, isInverted, logicWidth, name, true); + } + + protected SimpleRectangularModelGate(LogicModelModifiable model, String id, String label, boolean isInverted, int logicWidth, + String name, boolean callInit) + { + super(model, name, false); this.id = id; this.label = label; this.logicWidth = logicWidth; this.isInverted = isInverted; this.rectWidth = width - (isInverted ? invertedCircleDiam : 0); - this.outputPin = new MovablePin(this, "Y", logicWidth, PinUsage.OUTPUT, width, 0); + this.outputPin = new MovablePin(model, this, "Y", logicWidth, PinUsage.OUTPUT, width, 0); addPin(outputPin); this.inputPins = new ArrayList<>(); setInputCount(1); + + if (callInit) + init(); } protected void setInputCount(int inputCount) @@ -61,7 +71,8 @@ public class SimpleRectangularModelGate extends ModelComponent for (int i = oldInputCount; i < inputCount; i++) { // TODO what for more than 24 input pins? - Pin pin = new Pin(this, String.valueOf((char) ('A' + i)), logicWidth, PinUsage.INPUT, 0, pinDistance / 2 + i * pinDistance); + Pin pin = new Pin(model, this, String.valueOf((char) ('A' + i)), logicWidth, PinUsage.INPUT, 0, + pinDistance / 2 + i * pinDistance); inputPins.add(pin); addPin(pin); }