X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fexamples%2FPlayground.java;h=5e6bb6664545f8884e4c978fd8a189ad9f959882;hb=15c8ce02755ed263e121fa469b3ef5955b63e707;hp=372381a43551f8807c908169c7e425693da9d4a7;hpb=8e290cad73b372b954f7677f2287c6a9eb9a6313;p=Mograsim.git diff --git a/LogicUI/src/era/mi/gui/examples/Playground.java b/LogicUI/src/era/mi/gui/examples/Playground.java index 372381a4..5e6bb666 100644 --- a/LogicUI/src/era/mi/gui/examples/Playground.java +++ b/LogicUI/src/era/mi/gui/examples/Playground.java @@ -5,21 +5,39 @@ 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.wires.GUIWire; +import era.mi.gui.model.wires.WireCrossPoint; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; public class Playground { - 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) { ViewModel model = new ViewModel(); + GUIAndGate andGate = new GUIAndGate(model, 1); + andGate.moveTo(10, 10); + GUINotGate notGate = new GUINotGate(model, 1); + notGate.moveTo(10, 40); + + WireCrossPoint wcp1 = new WireCrossPoint(model, 1); + wcp1.moveTo(150, 10); + + new GUIWire(model, andGate.getOutputPin(), notGate.getInputPins().get(0), new Point(60, 50)); + new GUIWire(model, notGate.getOutputPin(), wcp1.getPin()); + + GUIManualSwitch sw1 = new GUIManualSwitch(model); + sw1.moveTo(-20, 0); + GUIManualSwitch sw2 = new GUIManualSwitch(model); + sw2.moveTo(-20, 50); + + new GUIWire(model, sw1.getOutputPin(), andGate.getInputPins().get(0)); + new GUIWire(model, sw2.getOutputPin(), andGate.getInputPins().get(1)); + LogicUIStandalone ui = new LogicUIStandalone(model); - addComponentsAndWires(ui, model); + + ui.getLogicUICanvas().addListener(SWT.KeyDown, e -> notGate.moveTo(100, 10)); ui.run(); }