import net.haspamelodica.swt.helper.gcs.TranslatedGC;
import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.haspamelodica.swt.helper.zoomablecanvas.ZoomableCanvas;
import net.haspamelodica.swt.helper.gcs.TranslatedGC;
import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.haspamelodica.swt.helper.zoomablecanvas.ZoomableCanvas;
- 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();
}
new ZoomableCanvasUserInput(canvas).enableUserInput();
new ZoomableCanvasOverlay(canvas, null).enableScale();
}
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);
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);
addComponent(new GUIMux(1, i, e, h, d), 10, 10);
}
private void addComponent(BasicGUIComponent component, double x, double y)
{
components.add(component);
componentPositions.put(component, new Point(x, y));
}
}
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);
+ }
+ }