Improvements in LogicUI
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 13 May 2019 20:06:53 +0000 (22:06 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 13 May 2019 20:06:53 +0000 (22:06 +0200)
LogicUI/.classpath
LogicUI/.settings/org.eclipse.jdt.core.prefs
LogicUI/src/LogicUI.java [new file with mode: 0644]
LogicUI/src/LogicUIPlayground.java [deleted file]
LogicUI/src/era/mi/components/gui/BasicGUIComponent.java [new file with mode: 0644]
LogicUI/src/era/mi/components/gui/GUIMux.java [new file with mode: 0644]
SWTHelper

index 66c470d..56baf23 100644 (file)
@@ -1,6 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
+               <attributes>
+                       <attribute name="module" value="true"/>
+               </attributes>
+       </classpathentry>
        <classpathentry kind="src" path="src"/>
        <classpathentry combineaccessrules="false" kind="src" path="/SWTZoomableCanvas"/>
        <classpathentry combineaccessrules="false" kind="src" path="/SWT"/>
index 3a21537..a54bb93 100644 (file)
@@ -1,11 +1,12 @@
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.compliance=10
 org.eclipse.jdt.core.compiler.debug.lineNumber=generate
 org.eclipse.jdt.core.compiler.debug.localVariable=generate
 org.eclipse.jdt.core.compiler.debug.sourceFile=generate
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.8
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=10
diff --git a/LogicUI/src/LogicUI.java b/LogicUI/src/LogicUI.java
new file mode 100644 (file)
index 0000000..6b8b500
--- /dev/null
@@ -0,0 +1,76 @@
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import era.mi.components.gui.BasicGUIComponent;
+import era.mi.components.gui.GUIMux;
+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.TranslatedGC;
+import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
+import net.haspamelodica.swt.helper.zoomablecanvas.ZoomableCanvas;
+import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasOverlay;
+import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;
+
+public class LogicUI
+{
+       private final Display                                           display;
+       private final Shell                                                     shell;
+       private final Set<BasicGUIComponent>            components;
+       private final Map<BasicGUIComponent, Point>     componentPositions;
+
+       public LogicUI()
+       {
+               display = new Display();
+               shell = new Shell(display);
+               shell.setLayout(new FillLayout());
+               ZoomableCanvas canvas = new ZoomableCanvas(shell, SWT.NONE);
+
+               components = new HashSet<>();
+               componentPositions = new HashMap<>();
+               initComponents();
+
+               canvas.addZoomedRenderer(gc -> components.forEach(
+                               component -> component.render(new TranslatedGC(gc, componentPositions.get(component)))));
+               new ZoomableCanvasUserInput(canvas).enableUserInput();
+               new ZoomableCanvasOverlay(canvas, null).enableScale();
+       }
+       private void initComponents()
+       {
+               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 GUIMux(1, i, e, h, d), 10, 10);
+               new Splitter(i, k, j);
+       }
+       private void addComponent(BasicGUIComponent component, double x, double y)
+       {
+               components.add(component);
+               componentPositions.put(component, new Point(x, y));
+       }
+       public void run()
+       {
+               shell.open();
+               while(!shell.isDisposed())
+                       if(!display.readAndDispatch())
+                               display.sleep();
+       }
+
+       public static void main(String[] args)
+       {
+               new LogicUI().run();
+       }
+}
\ No newline at end of file
diff --git a/LogicUI/src/LogicUIPlayground.java b/LogicUI/src/LogicUIPlayground.java
deleted file mode 100644 (file)
index 73ca537..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import net.haspamelodica.swt.helper.zoomablecanvas.ZoomableCanvas;
-import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasOverlay;
-import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;
-
-public class LogicUIPlayground
-{
-       public static void main(String[] args)
-       {
-               Display display = new Display();
-               Shell shell = new Shell(display);
-               shell.setLayout(new FillLayout());
-               ZoomableCanvas canvas = new ZoomableCanvas(shell, SWT.NONE);
-               canvas.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
-               canvas.addZoomedRenderer(gc -> gc.drawText("Test", 0, 0));
-               new ZoomableCanvasUserInput(canvas).enableUserInput();
-               new ZoomableCanvasOverlay(canvas, null).enableScale();
-               shell.open();
-               while(!shell.isDisposed())
-                       if(!display.readAndDispatch())
-                               display.sleep();
-       }
-}
\ No newline at end of file
diff --git a/LogicUI/src/era/mi/components/gui/BasicGUIComponent.java b/LogicUI/src/era/mi/components/gui/BasicGUIComponent.java
new file mode 100644 (file)
index 0000000..29df4f6
--- /dev/null
@@ -0,0 +1,8 @@
+package era.mi.components.gui;
+
+import net.haspamelodica.swt.helper.gcs.GeneralGC;
+
+public interface BasicGUIComponent
+{
+       public void render(GeneralGC gc);
+}
\ No newline at end of file
diff --git a/LogicUI/src/era/mi/components/gui/GUIMux.java b/LogicUI/src/era/mi/components/gui/GUIMux.java
new file mode 100644 (file)
index 0000000..d5b7c48
--- /dev/null
@@ -0,0 +1,28 @@
+package era.mi.components.gui;
+
+import era.mi.logic.components.Mux;
+import era.mi.logic.wires.WireArray;
+import net.haspamelodica.swt.helper.gcs.GeneralGC;
+
+public class GUIMux extends Mux implements BasicGUIComponent
+{
+       private final int inputCount;
+
+       public GUIMux(int processTime, WireArray out, WireArray select, WireArray... inputs)
+       {
+               super(processTime, out, select, inputs);
+               this.inputCount = inputs.length;
+       }
+       @Override
+       public void render(GeneralGC gc)
+       {
+               double height = inputCount * 10;
+               if(height < 20)
+                       height = 20;
+               gc.drawPolygon(new double[] {
+                               0, 0,
+                               20, 10,
+                               20, height + 10,
+                               0, height + 20});
+       }
+}
\ No newline at end of file
index 42ad035..0275db1 160000 (submodule)
--- a/SWTHelper
+++ b/SWTHelper
@@ -1 +1 @@
-Subproject commit 42ad03598e4fb87df86e9e60c7abacb27015918d
+Subproject commit 0275db10c78d3c3d98bf197eca5f29e4556ffb90