X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=LogicUI%2Fsrc%2FLogicUI.java;h=8242666e56cd3d66e1871235ba5be01d32097028;hb=c88be3fe785d0b1f9adcae3d9be3606e6982728d;hp=6b8b500fe8483337b3044bbea62ffb853d723be4;hpb=7ba7a5160d1167f9d0510d811a2865a7d95b6952;p=Mograsim.git diff --git a/LogicUI/src/LogicUI.java b/LogicUI/src/LogicUI.java index 6b8b500f..8242666e 100644 --- a/LogicUI/src/LogicUI.java +++ b/LogicUI/src/LogicUI.java @@ -9,13 +9,14 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import era.mi.components.gui.BasicGUIComponent; +import era.mi.components.gui.GUIAndGate; +import era.mi.components.gui.GUIMerger; import era.mi.components.gui.GUIMux; +import era.mi.components.gui.GUINotGate; +import era.mi.components.gui.GUISplitter; import era.mi.logic.Simulation; -import era.mi.logic.components.Merger; -import era.mi.logic.components.Splitter; -import era.mi.logic.components.gates.AndGate; -import era.mi.logic.components.gates.NotGate; import era.mi.logic.wires.WireArray; +import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.gcs.TranslatedGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.zoomablecanvas.ZoomableCanvas; @@ -40,8 +41,7 @@ public class LogicUI componentPositions = new HashMap<>(); initComponents(); - canvas.addZoomedRenderer(gc -> components.forEach( - component -> component.render(new TranslatedGC(gc, componentPositions.get(component))))); + canvas.addZoomedRenderer(gc -> components.forEach(component -> drawComponent(gc, component))); new ZoomableCanvasUserInput(canvas).enableUserInput(); new ZoomableCanvasOverlay(canvas, null).enableScale(); } @@ -50,17 +50,29 @@ public class LogicUI Simulation.TIMELINE.reset(); WireArray a = new WireArray(1, 1), b = new WireArray(1, 1), c = new WireArray(1, 10), d = new WireArray(2, 1), e = new WireArray(1, 1), f = new WireArray(1, 1), g = new WireArray(1, 1), h = new WireArray(2, 1), i = new WireArray(2, 1), j = new WireArray(1, 1), k = new WireArray(1, 1); - new AndGate(1, f, a, b); - new NotGate(1, f, g); - new Merger(h, c, g); + addComponent(new GUIAndGate(1, f, a, b), 130, 10); + addComponent(new GUINotGate(1, f, g), 100, 10); + addComponent(new GUIMerger(h, c, g), 70, 10); addComponent(new GUIMux(1, i, e, h, d), 10, 10); - new Splitter(i, k, j); + addComponent(new GUISplitter(i, k, j), 40, 10); } private void addComponent(BasicGUIComponent component, double x, double y) { components.add(component); componentPositions.put(component, new Point(x, y)); } + private void drawComponent(GeneralGC gc, BasicGUIComponent component) + { + TranslatedGC tgc = new TranslatedGC(gc, componentPositions.get(component)); + component.render(tgc); + tgc.setBackground(display.getSystemColor(SWT.COLOR_BLUE)); + for(int i = 0; i < component.getConnectedWireArraysCount(); i ++) + { + Point connectionPoint = component.getWireArrayConnectionPoint(i); + if(connectionPoint != null) + tgc.fillOval(connectionPoint.x - 1, connectionPoint.y - 1, 2, 2); + } + } public void run() { shell.open();