Recreated RSLatchExample in Playground
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 29 May 2019 15:56:29 +0000 (17:56 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 29 May 2019 15:56:38 +0000 (17:56 +0200)
LogicUI/oldsrc/RSLatchGUIExample.java [deleted file]
LogicUI/src/era/mi/gui/examples/Playground.java

diff --git a/LogicUI/oldsrc/RSLatchGUIExample.java b/LogicUI/oldsrc/RSLatchGUIExample.java
deleted file mode 100644 (file)
index 0fb1886..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-package era.mi.gui.examples;
-
-import era.mi.gui.LogicUICanvas;
-import era.mi.gui.LogicUIStandalone;
-import era.mi.gui.components.GUIManualSwitch;
-import era.mi.gui.components.GUINotGate;
-import era.mi.gui.components.GUIOrGateOld;
-import era.mi.gui.wires.WireConnectionPoint;
-import era.mi.logic.timeline.Timeline;
-import era.mi.logic.wires.Wire;
-import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
-
-public class RSLatchGUIExample
-{
-       private static final int WIRE_DELAY = 10;
-       private static final int OR_DELAY = 50;
-       private static final int NOT_DELAY = 50;
-
-       public static void main(String[] args)
-       {
-               Timeline t = new Timeline(11);
-               LogicUIStandalone ui = new LogicUIStandalone(t);
-               addComponentsAndWires(ui.getLogicUICanvas(), t);
-               ui.run();
-       }
-
-       public static void addComponentsAndWires(LogicUICanvas ui, Timeline t)
-       {
-               Wire r = new Wire(t, 1, WIRE_DELAY);
-               Wire s = new Wire(t, 1, WIRE_DELAY);
-               Wire t2 = new Wire(t, 1, WIRE_DELAY);
-               Wire t1 = new Wire(t, 1, WIRE_DELAY);
-               Wire q = new Wire(t, 1, WIRE_DELAY);
-               Wire nq = new Wire(t, 1, WIRE_DELAY);
-
-               GUIManualSwitch rIn = ui.addComponent(new GUIManualSwitch(t, r.createReadWriteEnd()), 100, 100);
-               GUIManualSwitch sIn = ui.addComponent(new GUIManualSwitch(t, s.createReadWriteEnd()), 100, 200);
-               GUIOrGateOld or1 = ui.addComponent(new GUIOrGateOld(t, OR_DELAY, t1.createReadWriteEnd(), r.createReadOnlyEnd(), nq.createReadOnlyEnd()),
-                               160, 102.5);
-               GUIOrGateOld or2 = ui.addComponent(new GUIOrGateOld(t, OR_DELAY, t2.createReadWriteEnd(), q.createReadOnlyEnd(), s.createReadOnlyEnd()),
-                               160, 192.5);
-               GUINotGate not1 = ui.addComponent(new GUINotGate(t, NOT_DELAY, t1.createReadOnlyEnd(), q.createReadWriteEnd()), 200, 107.5);
-               GUINotGate not2 = ui.addComponent(new GUINotGate(t, 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);
-               WireConnectionPoint o1 = ui.addComponent(new WireConnectionPoint(q, 1), 270, 112.5);
-               WireConnectionPoint o2 = ui.addComponent(new WireConnectionPoint(nq, 1), 270, 202.5);
-
-               ui.addWire(rIn, 0, or1, 0);
-               ui.addWire(sIn, 0, or2, 1);
-               ui.addWire(or1, 2, not1, 0);
-               ui.addWire(or2, 2, not2, 0);
-               ui.addWire(not1, 1, p1, 0);
-               ui.addWire(not2, 1, p2, 0);
-               ui.addWire(p1, 1, or2, 0, new Point(250, 130), new Point(140, 185), new Point(140, 197.5));
-               ui.addWire(p2, 1, or1, 1, new Point(250, 185), new Point(140, 130), new Point(140, 117.5));
-               ui.addWire(p1, 2, o1, 0);
-               ui.addWire(p2, 2, o2, 0);
-       }
-}
\ No newline at end of file
index 5e6bb66..9309eef 100644 (file)
@@ -1,12 +1,11 @@
 package era.mi.gui.examples;
 
-import org.eclipse.swt.SWT;
-
 import era.mi.gui.LogicUIStandalone;
 import era.mi.gui.model.ViewModel;
 import era.mi.gui.model.components.GUIAndGate;
 import era.mi.gui.model.components.GUIManualSwitch;
 import era.mi.gui.model.components.GUINotGate;
+import era.mi.gui.model.components.GUIOrGate;
 import era.mi.gui.model.wires.GUIWire;
 import era.mi.gui.model.wires.WireCrossPoint;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
@@ -16,6 +15,56 @@ public class Playground
        public static void main(String[] args)
        {
                ViewModel model = new ViewModel();
+               createRSLatchExample(model);
+               LogicUIStandalone ui = new LogicUIStandalone(model);
+               ui.run();
+       }
+
+       private static void createRSLatchExample(ViewModel model)
+       {
+               GUIManualSwitch rIn = new GUIManualSwitch(model);
+               rIn.moveTo(100, 100);
+               GUIManualSwitch sIn = new GUIManualSwitch(model);
+               sIn.moveTo(100, 200);
+
+               GUIOrGate or1 = new GUIOrGate(model, 1);
+               or1.moveTo(160, 102.5);
+               new GUIWire(model, rIn.getOutputPin(), or1.getInputPins().get(0));
+
+               GUIOrGate or2 = new GUIOrGate(model, 1);
+               or2.moveTo(160, 192.5);
+               new GUIWire(model, sIn.getOutputPin(), or2.getInputPins().get(1));
+
+               GUINotGate not1 = new GUINotGate(model, 1);
+               not1.moveTo(200, 107.5);
+               new GUIWire(model, or1.getOutputPin(), not1.getInputPins().get(0));
+
+               GUINotGate not2 = new GUINotGate(model, 1);
+               not2.moveTo(200, 197.5);
+               new GUIWire(model, or2.getOutputPin(), not2.getInputPins().get(0));
+
+               WireCrossPoint p1 = new WireCrossPoint(model, 1);
+               p1.moveTo(250, 112.5);
+               new GUIWire(model, not1.getOutputPin(), p1.getPin());
+               new GUIWire(model, p1.getPin(), or2.getInputPins().get(0), new Point(250, 130), new Point(140, 185), new Point(140, 197.5));
+
+               WireCrossPoint p2 = new WireCrossPoint(model, 1);
+               p2.moveTo(250, 202.5);
+               new GUIWire(model, not2.getOutputPin(), p2.getPin());
+               new GUIWire(model, p2.getPin(), or1.getInputPins().get(1), new Point(250, 185), new Point(140, 130), new Point(140, 117.5));
+
+               WireCrossPoint o1 = new WireCrossPoint(model, 1);
+               o1.moveTo(270, 112.5);
+               new GUIWire(model, p1.getPin(), o1.getPin());
+
+               WireCrossPoint o2 = new WireCrossPoint(model, 1);
+               o2.moveTo(270, 202.5);
+               new GUIWire(model, p2.getPin(), o2.getPin());
+       }
+
+       @SuppressWarnings("unused")
+       private static void createBasicExample(ViewModel model)
+       {
                GUIAndGate andGate = new GUIAndGate(model, 1);
                andGate.moveTo(10, 10);
                GUINotGate notGate = new GUINotGate(model, 1);
@@ -34,22 +83,5 @@ public class Playground
 
                new GUIWire(model, sw1.getOutputPin(), andGate.getInputPins().get(0));
                new GUIWire(model, sw2.getOutputPin(), andGate.getInputPins().get(1));
-
-               LogicUIStandalone ui = new LogicUIStandalone(model);
-
-               ui.getLogicUICanvas().addListener(SWT.KeyDown, e -> notGate.moveTo(100, 10));
-               ui.run();
-       }
-
-       public static void addComponentsAndWires(LogicUIStandalone ui, ViewModel model)
-       {
-               GUIAndGate andGate = new GUIAndGate(model, 1);
-               andGate.moveTo(10, 10);
-               GUINotGate notGate = new GUINotGate(model, 1);
-               notGate.moveTo(10, 40);
-
-               new GUIWire(model, andGate.getPins().get(0), notGate.getPins().get(1), new Point(20, 50));
-
-               ui.getLogicUICanvas().addListener(SWT.KeyDown, e -> notGate.moveTo(150, 10));
        }
 }
\ No newline at end of file