import org.eclipse.swt.widgets.Shell;\r
\r
import era.mi.components.gui.BasicGUIComponent;\r
+import era.mi.components.gui.GUIMerger;\r
import era.mi.components.gui.GUIMux;\r
+import era.mi.components.gui.GUISplitter;\r
import era.mi.logic.Simulation;\r
-import era.mi.logic.components.Merger;\r
-import era.mi.logic.components.Splitter;\r
import era.mi.logic.components.gates.AndGate;\r
import era.mi.logic.components.gates.NotGate;\r
import era.mi.logic.wires.WireArray;\r
+import net.haspamelodica.swt.helper.gcs.GeneralGC;\r
import net.haspamelodica.swt.helper.gcs.TranslatedGC;\r
import net.haspamelodica.swt.helper.swtobjectwrappers.Point;\r
import net.haspamelodica.swt.helper.zoomablecanvas.ZoomableCanvas;\r
componentPositions = new HashMap<>();\r
initComponents();\r
\r
- canvas.addZoomedRenderer(gc -> components.forEach(\r
- component -> component.render(new TranslatedGC(gc, componentPositions.get(component)))));\r
+ canvas.addZoomedRenderer(gc -> components.forEach(component -> drawComponent(gc, component)));\r
new ZoomableCanvasUserInput(canvas).enableUserInput();\r
new ZoomableCanvasOverlay(canvas, null).enableScale();\r
}\r
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);\r
new AndGate(1, f, a, b);\r
new NotGate(1, f, g);\r
- new Merger(h, c, g);\r
+ addComponent(new GUIMerger(h, c, g), 70, 10);\r
addComponent(new GUIMux(1, i, e, h, d), 10, 10);\r
- new Splitter(i, k, j);\r
+ addComponent(new GUISplitter(i, k, j), 40, 10);\r
}\r
private void addComponent(BasicGUIComponent component, double x, double y)\r
{\r
components.add(component);\r
componentPositions.put(component, new Point(x, y));\r
}\r
+ private void drawComponent(GeneralGC gc, BasicGUIComponent component)\r
+ {\r
+ TranslatedGC tgc = new TranslatedGC(gc, componentPositions.get(component));\r
+ component.render(tgc);\r
+ tgc.setBackground(display.getSystemColor(SWT.COLOR_BLUE));\r
+ for(int i = 0; i < component.getConnectedWireArraysCount(); i ++)\r
+ {\r
+ Point connectionPoint = component.getWireArrayConnectionPoint(i);\r
+ if(connectionPoint != null)\r
+ tgc.fillOval(connectionPoint.x - 2, connectionPoint.y - 2, 4, 4);\r
+ }\r
+ }\r
public void run()\r
{\r
shell.open();\r