From: Fabian Stemmler Date: Sat, 25 May 2019 18:04:31 +0000 (+0200) Subject: Made LogicUI compatible with ReadEnd and ReadWriteEnd X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=6d944b4deae46eef98beabdea0dab90c455e14a8;p=Mograsim.git Made LogicUI compatible with ReadEnd and ReadWriteEnd --- diff --git a/LogicUI/src/era/mi/gui/components/BasicGUIComponent.java b/LogicUI/src/era/mi/gui/components/BasicGUIComponent.java index b8094a93..2d27685b 100644 --- a/LogicUI/src/era/mi/gui/components/BasicGUIComponent.java +++ b/LogicUI/src/era/mi/gui/components/BasicGUIComponent.java @@ -1,6 +1,6 @@ package era.mi.gui.components; -import era.mi.logic.wires.Wire.WireEnd; +import era.mi.logic.wires.Wire.ReadEnd; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; @@ -35,7 +35,7 @@ public interface BasicGUIComponent /** * Returns the n-th wire array connected to this component. */ - public WireEnd getConnectedWireEnd(int connectionIndex); + public ReadEnd getConnectedWireEnd(int connectionIndex); /** * Returns relative coordinates where the n-th wire array is connected to this component. diff --git a/LogicUI/src/era/mi/gui/components/GUIAndGate.java b/LogicUI/src/era/mi/gui/components/GUIAndGate.java index abc80ff9..aa3b3c66 100644 --- a/LogicUI/src/era/mi/gui/components/GUIAndGate.java +++ b/LogicUI/src/era/mi/gui/components/GUIAndGate.java @@ -6,7 +6,8 @@ import java.util.Collections; import java.util.List; import era.mi.logic.components.gates.AndGate; -import era.mi.logic.wires.Wire.WireEnd; +import era.mi.logic.wires.Wire.ReadEnd; +import era.mi.logic.wires.Wire.ReadWriteEnd; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Font; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; @@ -18,14 +19,14 @@ public class GUIAndGate extends AndGate implements BasicGUIComponent private final int inputCount; private final double height; - private final List connectedWireEnds; + private final List connectedWireEnds; private final List wireEndConnectionPoints; - public GUIAndGate(int processTime, WireEnd out, WireEnd... in) + public GUIAndGate(int processTime, ReadWriteEnd out, ReadEnd... in) { super(processTime, out, in); - List connectedWireEndsModifiable = new ArrayList<>(); + List connectedWireEndsModifiable = new ArrayList<>(); List wireEndConnectionPointsModifiable = new ArrayList<>(); this.inputCount = in.length; @@ -70,7 +71,7 @@ public class GUIAndGate extends AndGate implements BasicGUIComponent } @Override - public WireEnd getConnectedWireEnd(int connectionIndex) + public ReadEnd getConnectedWireEnd(int connectionIndex) { return connectedWireEnds.get(connectionIndex); } diff --git a/LogicUI/src/era/mi/gui/components/GUIManualSwitch.java b/LogicUI/src/era/mi/gui/components/GUIManualSwitch.java index 09e243a7..48662d30 100644 --- a/LogicUI/src/era/mi/gui/components/GUIManualSwitch.java +++ b/LogicUI/src/era/mi/gui/components/GUIManualSwitch.java @@ -8,7 +8,8 @@ import java.util.Map; import era.mi.logic.components.ManualSwitch; import era.mi.logic.types.Bit; -import era.mi.logic.wires.Wire.WireEnd; +import era.mi.logic.wires.Wire.ReadEnd; +import era.mi.logic.wires.Wire.ReadWriteEnd; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Font; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; @@ -28,17 +29,17 @@ public class GUIManualSwitch extends ManualSwitch implements BasicGUIComponent bitNames = Collections.unmodifiableMap(bitNamesModifiable); } - private final WireEnd we; - private final List connectedWireEnds; + private final ReadEnd we; + private final List connectedWireEnds; private final List wireEndConnectionPoints; - public GUIManualSwitch(WireEnd output) + public GUIManualSwitch(ReadWriteEnd output) { super(output); this.we = output; - List connectedWireEndsModifiable = new ArrayList<>(); + List connectedWireEndsModifiable = new ArrayList<>(); List wireEndConnectionPointsModifiable = new ArrayList<>(); connectedWireEndsModifiable.add(output); @@ -81,7 +82,7 @@ public class GUIManualSwitch extends ManualSwitch implements BasicGUIComponent } @Override - public WireEnd getConnectedWireEnd(int connectionIndex) + public ReadEnd getConnectedWireEnd(int connectionIndex) { return connectedWireEnds.get(connectionIndex); } diff --git a/LogicUI/src/era/mi/gui/components/GUIMerger.java b/LogicUI/src/era/mi/gui/components/GUIMerger.java index fed303ba..480da351 100644 --- a/LogicUI/src/era/mi/gui/components/GUIMerger.java +++ b/LogicUI/src/era/mi/gui/components/GUIMerger.java @@ -6,7 +6,8 @@ import java.util.Collections; import java.util.List; import era.mi.logic.components.Merger; -import era.mi.logic.wires.Wire.WireEnd; +import era.mi.logic.wires.Wire.ReadEnd; +import era.mi.logic.wires.Wire.ReadWriteEnd; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; @@ -15,14 +16,14 @@ public class GUIMerger extends Merger implements BasicGUIComponent { private final int inputCount; private final double height; - private final List connectedWireEnds; + private final List connectedWireEnds; private final List WireEndConnectionPoints; - public GUIMerger(WireEnd union, WireEnd... inputs) + public GUIMerger(ReadWriteEnd union, ReadEnd... inputs) { super(union, inputs); - List connectedWireEndsModifiable = new ArrayList<>(); + List connectedWireEndsModifiable = new ArrayList<>(); List WireEndConnectionPointsModifiable = new ArrayList<>(); this.inputCount = inputs.length; @@ -65,7 +66,7 @@ public class GUIMerger extends Merger implements BasicGUIComponent } @Override - public WireEnd getConnectedWireEnd(int connectionIndex) + public ReadEnd getConnectedWireEnd(int connectionIndex) { return connectedWireEnds.get(connectionIndex); } diff --git a/LogicUI/src/era/mi/gui/components/GUIMux.java b/LogicUI/src/era/mi/gui/components/GUIMux.java index c16aa316..5f6dde77 100644 --- a/LogicUI/src/era/mi/gui/components/GUIMux.java +++ b/LogicUI/src/era/mi/gui/components/GUIMux.java @@ -6,7 +6,8 @@ import java.util.Collections; import java.util.List; import era.mi.logic.components.Mux; -import era.mi.logic.wires.Wire.WireEnd; +import era.mi.logic.wires.Wire.ReadEnd; +import era.mi.logic.wires.Wire.ReadWriteEnd; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; @@ -14,10 +15,10 @@ import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; public class GUIMux extends Mux implements BasicGUIComponent { private final double height; - private final List connectedWireEnds; + private final List connectedWireEnds; private final List WireEndConnectionPoints; - public GUIMux(int processTime, WireEnd out, WireEnd select, WireEnd... inputs) + public GUIMux(int processTime, ReadWriteEnd out, ReadEnd select, ReadEnd... inputs) { super(processTime, out, select, inputs); @@ -26,7 +27,7 @@ public class GUIMux extends Mux implements BasicGUIComponent height = 10; this.height = height; - List connectedWireEndsModifiable = new ArrayList<>(); + List connectedWireEndsModifiable = new ArrayList<>(); List WireEndConnectionPointsModifiable = new ArrayList<>(); connectedWireEndsModifiable.add(out); @@ -66,7 +67,7 @@ public class GUIMux extends Mux implements BasicGUIComponent } @Override - public WireEnd getConnectedWireEnd(int connectionIndex) + public ReadEnd getConnectedWireEnd(int connectionIndex) { return connectedWireEnds.get(connectionIndex); } diff --git a/LogicUI/src/era/mi/gui/components/GUINotGate.java b/LogicUI/src/era/mi/gui/components/GUINotGate.java index 24416ada..526e2704 100644 --- a/LogicUI/src/era/mi/gui/components/GUINotGate.java +++ b/LogicUI/src/era/mi/gui/components/GUINotGate.java @@ -5,7 +5,8 @@ import java.util.Collections; import java.util.List; import era.mi.logic.components.gates.NotGate; -import era.mi.logic.wires.Wire.WireEnd; +import era.mi.logic.wires.Wire.ReadEnd; +import era.mi.logic.wires.Wire.ReadWriteEnd; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Font; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; @@ -15,14 +16,14 @@ public class GUINotGate extends NotGate implements BasicGUIComponent { private static final String LABEL = "\u22651";// >=1 - private final List connectedWireEnds; + private final List connectedWireEnds; private final List WireEndConnectionPoints; - public GUINotGate(int processTime, WireEnd in, WireEnd out) + public GUINotGate(int processTime, ReadEnd in, ReadWriteEnd out) { super(processTime, in, out); - List connectedWireEndsModifiable = new ArrayList<>(); + List connectedWireEndsModifiable = new ArrayList<>(); List WireEndConnectionPointsModifiable = new ArrayList<>(); connectedWireEndsModifiable.add(in); @@ -61,7 +62,7 @@ public class GUINotGate extends NotGate implements BasicGUIComponent } @Override - public WireEnd getConnectedWireEnd(int connectionIndex) + public ReadEnd getConnectedWireEnd(int connectionIndex) { return connectedWireEnds.get(connectionIndex); } diff --git a/LogicUI/src/era/mi/gui/components/GUIOrGate.java b/LogicUI/src/era/mi/gui/components/GUIOrGate.java index 9d2b71d2..6eac2957 100644 --- a/LogicUI/src/era/mi/gui/components/GUIOrGate.java +++ b/LogicUI/src/era/mi/gui/components/GUIOrGate.java @@ -6,7 +6,8 @@ import java.util.Collections; import java.util.List; import era.mi.logic.components.gates.OrGate; -import era.mi.logic.wires.Wire.WireEnd; +import era.mi.logic.wires.Wire.ReadEnd; +import era.mi.logic.wires.Wire.ReadWriteEnd; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Font; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; @@ -18,14 +19,14 @@ public class GUIOrGate extends OrGate implements BasicGUIComponent private final int inputCount; private final double height; - private final List connectedWireEnds; + private final List connectedWireEnds; private final List WireEndConnectionPoints; - public GUIOrGate(int processTime, WireEnd out, WireEnd... in) + public GUIOrGate(int processTime, ReadWriteEnd out, ReadEnd... in) { super(processTime, out, in); - List connectedWireEndsModifiable = new ArrayList<>(); + List connectedWireEndsModifiable = new ArrayList<>(); List WireEndConnectionPointsModifiable = new ArrayList<>(); this.inputCount = in.length; @@ -70,7 +71,7 @@ public class GUIOrGate extends OrGate implements BasicGUIComponent } @Override - public WireEnd getConnectedWireEnd(int connectionIndex) + public ReadEnd getConnectedWireEnd(int connectionIndex) { return connectedWireEnds.get(connectionIndex); } diff --git a/LogicUI/src/era/mi/gui/components/GUISplitter.java b/LogicUI/src/era/mi/gui/components/GUISplitter.java index 3b877c6e..1e39983a 100644 --- a/LogicUI/src/era/mi/gui/components/GUISplitter.java +++ b/LogicUI/src/era/mi/gui/components/GUISplitter.java @@ -6,7 +6,8 @@ import java.util.Collections; import java.util.List; import era.mi.logic.components.Splitter; -import era.mi.logic.wires.Wire.WireEnd; +import era.mi.logic.wires.Wire.ReadEnd; +import era.mi.logic.wires.Wire.ReadWriteEnd; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; @@ -15,14 +16,14 @@ public class GUISplitter extends Splitter implements BasicGUIComponent { private final int outputCount; private final double height; - private final List connectedWireEnds; + private final List connectedWireEnds; private final List WireEndConnectionPoints; - public GUISplitter(WireEnd input, WireEnd... outputs) + public GUISplitter(ReadEnd input, ReadWriteEnd... outputs) { super(input, outputs); - List connectedWireEndsModifiable = new ArrayList<>(); + List connectedWireEndsModifiable = new ArrayList<>(); List WireEndConnectionPointsModifiable = new ArrayList<>(); this.outputCount = outputs.length; @@ -65,7 +66,7 @@ public class GUISplitter extends Splitter implements BasicGUIComponent } @Override - public WireEnd getConnectedWireEnd(int connectionIndex) + public ReadEnd getConnectedWireEnd(int connectionIndex) { return connectedWireEnds.get(connectionIndex); } diff --git a/LogicUI/src/era/mi/gui/examples/RSLatchGUIExample.java b/LogicUI/src/era/mi/gui/examples/RSLatchGUIExample.java index c3a7ea25..c36ba3a9 100644 --- a/LogicUI/src/era/mi/gui/examples/RSLatchGUIExample.java +++ b/LogicUI/src/era/mi/gui/examples/RSLatchGUIExample.java @@ -33,12 +33,12 @@ public class RSLatchGUIExample Wire q = new Wire(1, WIRE_DELAY); Wire nq = new Wire(1, WIRE_DELAY); - GUIManualSwitch rIn = ui.addComponent(new GUIManualSwitch(r.createEnd()), 100, 100); - GUIManualSwitch sIn = ui.addComponent(new GUIManualSwitch(s.createEnd()), 100, 200); - GUIOrGate or1 = ui.addComponent(new GUIOrGate(OR_DELAY, t1.createEnd(), r.createReadOnlyEnd(), nq.createReadOnlyEnd()), 160, 102.5); - GUIOrGate or2 = ui.addComponent(new GUIOrGate(OR_DELAY, t2.createEnd(), q.createReadOnlyEnd(), s.createReadOnlyEnd()), 160, 192.5); - GUINotGate not1 = ui.addComponent(new GUINotGate(NOT_DELAY, t1.createReadOnlyEnd(), q.createEnd()), 200, 107.5); - GUINotGate not2 = ui.addComponent(new GUINotGate(NOT_DELAY, t2.createReadOnlyEnd(), nq.createEnd()), 200, 197.5); + GUIManualSwitch rIn = ui.addComponent(new GUIManualSwitch(r.createReadWriteEnd()), 100, 100); + GUIManualSwitch sIn = ui.addComponent(new GUIManualSwitch(s.createReadWriteEnd()), 100, 200); + GUIOrGate or1 = ui.addComponent(new GUIOrGate(OR_DELAY, t1.createReadWriteEnd(), r.createReadOnlyEnd(), nq.createReadOnlyEnd()), 160, 102.5); + GUIOrGate or2 = ui.addComponent(new GUIOrGate(OR_DELAY, t2.createReadWriteEnd(), q.createReadOnlyEnd(), s.createReadOnlyEnd()), 160, 192.5); + GUINotGate not1 = ui.addComponent(new GUINotGate(NOT_DELAY, t1.createReadOnlyEnd(), q.createReadWriteEnd()), 200, 107.5); + GUINotGate not2 = ui.addComponent(new GUINotGate(NOT_DELAY, t2.createReadOnlyEnd(), nq.createReadWriteEnd()), 200, 197.5); WireConnectionPoint p1 = ui.addComponent(new WireConnectionPoint(q, 3), 250, 112.5); WireConnectionPoint p2 = ui.addComponent(new WireConnectionPoint(nq, 3), 250, 202.5); diff --git a/LogicUI/src/era/mi/gui/wires/GUIWire.java b/LogicUI/src/era/mi/gui/wires/GUIWire.java index a60d3243..53e122a3 100644 --- a/LogicUI/src/era/mi/gui/wires/GUIWire.java +++ b/LogicUI/src/era/mi/gui/wires/GUIWire.java @@ -35,7 +35,7 @@ public class GUIWire this.path[this.path.length - 2] = component2Pos.x + component2ConnectionPoint.x; this.path[this.path.length - 1] = component2Pos.y + component2ConnectionPoint.y; - wire.addObserver((initiator, oldValues) -> redraw.run()); + wire.createReadOnlyEnd().addObserver((initiator, oldValues) -> redraw.run()); } public void render(GeneralGC gc) diff --git a/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java b/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java index f095f0d0..df82a733 100644 --- a/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java +++ b/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java @@ -8,7 +8,7 @@ import org.eclipse.swt.graphics.Color; import era.mi.gui.components.BasicGUIComponent; import era.mi.logic.wires.Wire; -import era.mi.logic.wires.Wire.WireEnd; +import era.mi.logic.wires.Wire.ReadEnd; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; @@ -16,13 +16,13 @@ import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; public class WireConnectionPoint implements BasicGUIComponent { private final Wire wire; - private final List wireEnds; + private final List wireEnds; private final int wiresCrossing; public WireConnectionPoint(Wire wire, int wiresCrossing) { this.wire = wire; - List wireEndsModifiable = new ArrayList<>(); + List wireEndsModifiable = new ArrayList<>(); for (int i = 0; i < wiresCrossing; i++) wireEndsModifiable.add(wire.createReadOnlyEnd()); wireEnds = Collections.unmodifiableList(wireEndsModifiable); @@ -52,7 +52,7 @@ public class WireConnectionPoint implements BasicGUIComponent } @Override - public WireEnd getConnectedWireEnd(int connectionIndex) + public ReadEnd getConnectedWireEnd(int connectionIndex) { return wireEnds.get(connectionIndex); }