Merged logicui into master
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 20 May 2019 17:31:07 +0000 (19:31 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 20 May 2019 17:31:07 +0000 (19:31 +0200)
1  2 
.gitmodules
LogicUI/.classpath
LogicUI/.project
era.mi/.settings/org.eclipse.jdt.ui.prefs
era.mi/src/era/mi/logic/components/ManualSwitch.java
era.mi/src/era/mi/logic/tests/GUITest.java

diff --cc .gitmodules
@@@ -1,8 -1,4 +1,8 @@@
- [submodule "logicui"]
-       path = logicui
-       url = <address of this repo>
-       branch = logicui
 +[submodule "SampleERCP"]
 +      path = SampleERCP
 +      url = <address of this repo>
 +      branch = SampleERCP
+ [submodule "SWTHelper"]
+       path = SWTHelper
+       url = https://github.com/Haspamelodica/SWTHelper
+       branch = master
index 0000000,effa05b..56baf23
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,13 +1,13 @@@
 -<?xml version="1.0" encoding="UTF-8"?>\r
 -<classpath>\r
 -      <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">\r
 -              <attributes>\r
 -                      <attribute name="module" value="true"/>\r
 -              </attributes>\r
 -      </classpathentry>\r
 -      <classpathentry kind="src" path="src"/>\r
 -      <classpathentry combineaccessrules="false" kind="src" path="/SWTZoomableCanvas"/>\r
 -      <classpathentry combineaccessrules="false" kind="src" path="/SWT"/>\r
 -      <classpathentry combineaccessrules="false" kind="src" path="/era.mi"/>\r
 -      <classpathentry kind="output" path="bin"/>\r
 -</classpath>\r
++<?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-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"/>
++      <classpathentry combineaccessrules="false" kind="src" path="/era.mi"/>
++      <classpathentry kind="output" path="bin"/>
++</classpath>
index 0000000,b5e0280..8b40ae1
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,17 +1,17 @@@
 -<?xml version="1.0" encoding="UTF-8"?>\r
 -<projectDescription>\r
 -      <name>LogicUI</name>\r
 -      <comment></comment>\r
 -      <projects>\r
 -      </projects>\r
 -      <buildSpec>\r
 -              <buildCommand>\r
 -                      <name>org.eclipse.jdt.core.javabuilder</name>\r
 -                      <arguments>\r
 -                      </arguments>\r
 -              </buildCommand>\r
 -      </buildSpec>\r
 -      <natures>\r
 -              <nature>org.eclipse.jdt.core.javanature</nature>\r
 -      </natures>\r
 -</projectDescription>\r
++<?xml version="1.0" encoding="UTF-8"?>
++<projectDescription>
++      <name>LogicUI</name>
++      <comment></comment>
++      <projects>
++      </projects>
++      <buildSpec>
++              <buildCommand>
++                      <name>org.eclipse.jdt.core.javabuilder</name>
++                      <arguments>
++                      </arguments>
++              </buildCommand>
++      </buildSpec>
++      <natures>
++              <nature>org.eclipse.jdt.core.javanature</nature>
++      </natures>
++</projectDescription>
index 7c7eca3,0000000..07b37c1
mode 100644,000000..100644
--- /dev/null
@@@ -1,63 -1,0 +1,63 @@@
- eclipse.preferences.version=1\r
- editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true\r
- formatter_profile=_ERA-MI\r
- formatter_settings_version=16\r
- sp_cleanup.add_default_serial_version_id=true\r
- sp_cleanup.add_generated_serial_version_id=false\r
- sp_cleanup.add_missing_annotations=true\r
- sp_cleanup.add_missing_deprecated_annotations=true\r
- sp_cleanup.add_missing_methods=false\r
- sp_cleanup.add_missing_nls_tags=false\r
- sp_cleanup.add_missing_override_annotations=true\r
- sp_cleanup.add_missing_override_annotations_interface_methods=true\r
- sp_cleanup.add_serial_version_id=false\r
- sp_cleanup.always_use_blocks=false\r
- sp_cleanup.always_use_parentheses_in_expressions=false\r
- sp_cleanup.always_use_this_for_non_static_field_access=false\r
- sp_cleanup.always_use_this_for_non_static_method_access=false\r
- sp_cleanup.convert_functional_interfaces=true\r
- sp_cleanup.convert_to_enhanced_for_loop=true\r
- sp_cleanup.correct_indentation=true\r
- sp_cleanup.format_source_code=true\r
- sp_cleanup.format_source_code_changes_only=false\r
- sp_cleanup.insert_inferred_type_arguments=false\r
- sp_cleanup.make_local_variable_final=true\r
- sp_cleanup.make_parameters_final=false\r
- sp_cleanup.make_private_fields_final=true\r
- sp_cleanup.make_type_abstract_if_missing_method=false\r
- sp_cleanup.make_variable_declarations_final=true\r
- sp_cleanup.never_use_blocks=true\r
- sp_cleanup.never_use_parentheses_in_expressions=true\r
- sp_cleanup.on_save_use_additional_actions=false\r
- sp_cleanup.organize_imports=true\r
- sp_cleanup.qualify_static_field_accesses_with_declaring_class=false\r
- sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true\r
- sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true\r
- sp_cleanup.qualify_static_member_accesses_with_declaring_class=true\r
- sp_cleanup.qualify_static_method_accesses_with_declaring_class=false\r
- sp_cleanup.remove_private_constructors=true\r
- sp_cleanup.remove_redundant_modifiers=true\r
- sp_cleanup.remove_redundant_semicolons=true\r
- sp_cleanup.remove_redundant_type_arguments=true\r
- sp_cleanup.remove_trailing_whitespaces=true\r
- sp_cleanup.remove_trailing_whitespaces_all=true\r
- sp_cleanup.remove_trailing_whitespaces_ignore_empty=false\r
- sp_cleanup.remove_unnecessary_casts=true\r
- sp_cleanup.remove_unnecessary_nls_tags=true\r
- sp_cleanup.remove_unused_imports=true\r
- sp_cleanup.remove_unused_local_variables=false\r
- sp_cleanup.remove_unused_private_fields=true\r
- sp_cleanup.remove_unused_private_members=false\r
- sp_cleanup.remove_unused_private_methods=true\r
- sp_cleanup.remove_unused_private_types=true\r
- sp_cleanup.sort_members=false\r
- sp_cleanup.sort_members_all=false\r
- sp_cleanup.use_anonymous_class_creation=false\r
- sp_cleanup.use_blocks=false\r
- sp_cleanup.use_blocks_only_for_return_and_throw=false\r
- sp_cleanup.use_lambda=true\r
- sp_cleanup.use_parentheses_in_expressions=false\r
- sp_cleanup.use_this_for_non_static_field_access=true\r
- sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true\r
- sp_cleanup.use_this_for_non_static_method_access=true\r
- sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true\r
++eclipse.preferences.version=1
++editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
++formatter_profile=_ERA-MI
++formatter_settings_version=16
++sp_cleanup.add_default_serial_version_id=true
++sp_cleanup.add_generated_serial_version_id=false
++sp_cleanup.add_missing_annotations=true
++sp_cleanup.add_missing_deprecated_annotations=true
++sp_cleanup.add_missing_methods=false
++sp_cleanup.add_missing_nls_tags=false
++sp_cleanup.add_missing_override_annotations=true
++sp_cleanup.add_missing_override_annotations_interface_methods=true
++sp_cleanup.add_serial_version_id=false
++sp_cleanup.always_use_blocks=false
++sp_cleanup.always_use_parentheses_in_expressions=false
++sp_cleanup.always_use_this_for_non_static_field_access=false
++sp_cleanup.always_use_this_for_non_static_method_access=false
++sp_cleanup.convert_functional_interfaces=true
++sp_cleanup.convert_to_enhanced_for_loop=true
++sp_cleanup.correct_indentation=true
++sp_cleanup.format_source_code=true
++sp_cleanup.format_source_code_changes_only=false
++sp_cleanup.insert_inferred_type_arguments=false
++sp_cleanup.make_local_variable_final=true
++sp_cleanup.make_parameters_final=false
++sp_cleanup.make_private_fields_final=true
++sp_cleanup.make_type_abstract_if_missing_method=false
++sp_cleanup.make_variable_declarations_final=true
++sp_cleanup.never_use_blocks=true
++sp_cleanup.never_use_parentheses_in_expressions=true
++sp_cleanup.on_save_use_additional_actions=false
++sp_cleanup.organize_imports=true
++sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
++sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
++sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
++sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
++sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
++sp_cleanup.remove_private_constructors=true
++sp_cleanup.remove_redundant_modifiers=true
++sp_cleanup.remove_redundant_semicolons=true
++sp_cleanup.remove_redundant_type_arguments=true
++sp_cleanup.remove_trailing_whitespaces=true
++sp_cleanup.remove_trailing_whitespaces_all=true
++sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
++sp_cleanup.remove_unnecessary_casts=true
++sp_cleanup.remove_unnecessary_nls_tags=true
++sp_cleanup.remove_unused_imports=true
++sp_cleanup.remove_unused_local_variables=false
++sp_cleanup.remove_unused_private_fields=true
++sp_cleanup.remove_unused_private_members=false
++sp_cleanup.remove_unused_private_methods=true
++sp_cleanup.remove_unused_private_types=true
++sp_cleanup.sort_members=false
++sp_cleanup.sort_members_all=false
++sp_cleanup.use_anonymous_class_creation=false
++sp_cleanup.use_blocks=false
++sp_cleanup.use_blocks_only_for_return_and_throw=false
++sp_cleanup.use_lambda=true
++sp_cleanup.use_parentheses_in_expressions=false
++sp_cleanup.use_this_for_non_static_field_access=true
++sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
++sp_cleanup.use_this_for_non_static_method_access=true
++sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
index c4b4ffa,0000000..0ad4a76
mode 100644,000000..100644
--- /dev/null
@@@ -1,71 -1,0 +1,71 @@@
- package era.mi.logic.components;\r
\r
- import java.util.List;\r
\r
- import era.mi.logic.types.Bit;\r
- import era.mi.logic.wires.Wire.WireEnd;\r
\r
- /**\r
-  * This class models a simple on/off (ONE/ZERO) switch for user interaction.\r
-  *\r
-  * @author Christian Femers\r
-  *\r
-  */\r
- public class ManualSwitch implements Component\r
- {\r
-       private WireEnd output;\r
-       private boolean isOn;\r
\r
-       public ManualSwitch(WireEnd output)\r
-       {\r
-               if (output.length() != 1)\r
-                       throw new IllegalArgumentException("Switch output can be only a single wire");\r
-               this.output = output;\r
-       }\r
\r
-       public void switchOn()\r
-       {\r
-               setState(true);\r
-       }\r
\r
-       public void switchOff()\r
-       {\r
-               setState(false);\r
-       }\r
\r
-       public void toggle()\r
-       {\r
-               setState(!isOn);\r
-       }\r
\r
-       public void setState(boolean isOn)\r
-       {\r
-               if (this.isOn == isOn)\r
-                       return;\r
-               this.isOn = isOn;\r
-               output.feedSignals(getValue());\r
-       }\r
\r
-       public boolean isOn()\r
-       {\r
-               return isOn;\r
-       }\r
\r
-       public Bit getValue()\r
-       {\r
-               return isOn ? Bit.ONE : Bit.ZERO;\r
-       }\r
\r
-       @Override\r
-       public List<WireEnd> getAllInputs()\r
-       {\r
-               return List.of();\r
-       }\r
\r
-       @Override\r
-       public List<WireEnd> getAllOutputs()\r
-       {\r
-               return List.of(output);\r
-       }\r
\r
- }\r
++package era.mi.logic.components;
++
++import java.util.List;
++
++import era.mi.logic.types.Bit;
++import era.mi.logic.wires.Wire.WireEnd;
++
++/**
++ * This class models a simple on/off (ONE/ZERO) switch for user interaction.
++ *
++ * @author Christian Femers
++ *
++ */
++public class ManualSwitch implements Component
++{
++      private WireEnd output;
++      private boolean isOn;
++
++      public ManualSwitch(WireEnd output)
++      {
++              if (output.length() != 1)
++                      throw new IllegalArgumentException("Switch output can be only a single wire");
++              this.output = output;
++      }
++
++      public void switchOn()
++      {
++              setState(true);
++      }
++
++      public void switchOff()
++      {
++              setState(false);
++      }
++
++      public void toggle()
++      {
++              setState(!isOn);
++      }
++
++      public void setState(boolean isOn)
++      {
++              if (this.isOn == isOn)
++                      return;
++              this.isOn = isOn;
++              output.feedSignals(getValue());
++      }
++
++      public boolean isOn()
++      {
++              return isOn;
++      }
++
++      public Bit getValue()
++      {
++              return isOn ? Bit.ONE : Bit.ZERO;
++      }
++
++      @Override
++      public List<WireEnd> getAllInputs()
++      {
++              return List.of();
++      }
++
++      @Override
++      public List<WireEnd> getAllOutputs()
++      {
++              return List.of(output);
++      }
++
++}
index adc4c32,0000000..b93d4b6
mode 100644,000000..100644
--- /dev/null
@@@ -1,294 -1,0 +1,294 @@@
- package era.mi.logic.tests;\r
\r
- import java.awt.Color;\r
- import java.awt.Graphics;\r
- import java.awt.Graphics2D;\r
- import java.awt.Rectangle;\r
- import java.awt.RenderingHints;\r
- import java.awt.event.MouseEvent;\r
- import java.awt.event.MouseListener;\r
- import java.util.HashMap;\r
- import java.util.Map;\r
- import java.util.Map.Entry;\r
\r
- import javax.swing.JFrame;\r
- import javax.swing.JPanel;\r
- import javax.swing.WindowConstants;\r
\r
- import era.mi.logic.Simulation;\r
- import era.mi.logic.components.ManualSwitch;\r
- import era.mi.logic.components.gates.NotGate;\r
- import era.mi.logic.components.gates.OrGate;\r
- import era.mi.logic.timeline.Timeline.ExecutionResult;\r
- import era.mi.logic.wires.Wire;\r
\r
- public class GUITest extends JPanel\r
- {\r
\r
-       private static final long serialVersionUID = 1L;\r
\r
-       private static final int WIRE_DELAY = 40;\r
-       private static final int OR_DELAY = 100;\r
-       private static final int NOT_DELAY = 100;\r
\r
-       Wire r = new Wire(1, WIRE_DELAY);\r
-       Wire s = new Wire(1, WIRE_DELAY);\r
-       Wire t1 = new Wire(1, WIRE_DELAY);\r
-       Wire t2 = new Wire(1, WIRE_DELAY);\r
-       Wire q = new Wire(1, WIRE_DELAY);\r
-       Wire nq = new Wire(1, WIRE_DELAY);\r
\r
-       ManualSwitch rIn = new ManualSwitch(r.createEnd());\r
-       ManualSwitch sIn = new ManualSwitch(s.createEnd());\r
\r
-       OrGate or1 = new OrGate(OR_DELAY, t2.createEnd(), r.createEnd(), nq.createEnd());\r
-       OrGate or2 = new OrGate(OR_DELAY, t1.createEnd(), s.createEnd(), q.createEnd());\r
-       NotGate not1 = new NotGate(NOT_DELAY, t2.createEnd(), q.createEnd());\r
-       NotGate not2 = new NotGate(NOT_DELAY, t1.createEnd(), nq.createEnd());\r
\r
-       Map<ManualSwitch, Rectangle> switchMap = new HashMap<>();\r
\r
-       int height;\r
-       int width;\r
-       boolean sizeChanged;\r
\r
-       public GUITest()\r
-       {\r
-               addMouseListener(new MouseListener()\r
-               {\r
\r
-                       @Override\r
-                       public void mouseReleased(MouseEvent e)\r
-                       {\r
-                               for (Entry<ManualSwitch, Rectangle> dim : switchMap.entrySet())\r
-                               {\r
-                                       if (dim.getValue().contains(e.getPoint()))\r
-                                       {\r
-                                               dim.getKey().switchOff();\r
-                                               repaint();\r
-                                       }\r
-                               }\r
-                       }\r
\r
-                       @Override\r
-                       public void mousePressed(MouseEvent e)\r
-                       {\r
-                               for (Entry<ManualSwitch, Rectangle> dim : switchMap.entrySet())\r
-                               {\r
-                                       if (dim.getValue().contains(e.getPoint()))\r
-                                       {\r
-                                               dim.getKey().switchOn();\r
-                                               repaint();\r
-                                       }\r
-                               }\r
-                       }\r
\r
-                       @Override\r
-                       public void mouseExited(MouseEvent e)\r
-                       {\r
-                               // none\r
-                       }\r
\r
-                       @Override\r
-                       public void mouseEntered(MouseEvent e)\r
-                       {\r
-                               // none\r
-                       }\r
\r
-                       @Override\r
-                       public void mouseClicked(MouseEvent e)\r
-                       {\r
-                               // If you want toggle buttons, use this code instead\r
- //                            for (Entry<ManualSwitch, Rectangle> dim : switchMap.entrySet()) {\r
- //                                    if (dim.getValue().contains(e.getPoint())) {\r
- //                                            dim.getKey().toggle();\r
- //                                            repaint();\r
- //                                    }\r
- //                            }\r
-                       }\r
-               });\r
-       }\r
\r
-       @Override\r
-       public void paint(Graphics some_g)\r
-       {\r
-               super.paint(some_g);\r
-               Graphics2D g = ((Graphics2D) some_g);\r
-               g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);\r
-               g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);\r
-               g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);\r
\r
-               checkSizeChange();\r
-               adaptFont(g);\r
\r
-               drawWire(g, r, "r", 2, 9, 4, 9);\r
\r
-               drawWire(g, s, "s", 2, 3, 4, 3);\r
\r
-               drawWire(g, t2, "t2", 5, 8.5, 6, 8.5);\r
\r
-               drawWire(g, t1, "t1", 5, 3.5, 6, 3.5);\r
\r
-               drawWire(g, q, "q", 7, 8.5, 9, 8.5);\r
\r
-               drawWire(g, nq, "nq", 7, 3.5, 9, 3.5);\r
\r
-               drawWire(g, q, "", 7.5, 8.5, 7.5, 7.5);\r
-               drawWire(g, q, "", 7.5, 7.5, 3, 4.5);\r
-               drawWire(g, q, "", 3, 4.5, 3, 4);\r
-               drawWire(g, q, "q", 3, 4, 4, 4);\r
\r
-               drawWire(g, nq, "", 7.5, 3.5, 7.5, 4.5);\r
-               drawWire(g, nq, "", 7.5, 4.5, 3, 7.5);\r
-               drawWire(g, nq, "", 3, 7.5, 3, 8);\r
-               drawWire(g, nq, "nq", 3, 8, 4, 8);\r
\r
-               drawSquare(g, 4, 8, "OR");\r
-               drawSquare(g, 4, 3, "OR");\r
\r
-               drawSquare(g, 6, 8, "NOT");\r
-               drawSquare(g, 6, 3, "NOT");\r
\r
-               drawSwitch(g, rIn, "Switch R", 0.5, 8.25, 2, 9.75);\r
-               drawSwitch(g, sIn, "Switch S", 0.5, 2.25, 2, 3.75);\r
\r
-               drawString(g, "Hint: drag the cursor out of the pressed switch to keep it's state", 5, 0, 0.0, 1.0);\r
-       }\r
\r
-       private void checkSizeChange()\r
-       {\r
-               sizeChanged = height != getHeight() || width != getWidth();\r
-               if (sizeChanged)\r
-               {\r
-                       height = getHeight();\r
-                       width = getWidth();\r
-               }\r
-       }\r
\r
-       private void adaptFont(Graphics g)\r
-       {\r
-               g.setFont(g.getFont().deriveFont(Math.min(height, width) / 40f));\r
-       }\r
\r
-       private void drawString(Graphics g, String s, int x, int y, double anchorX, double anchorY)\r
-       {\r
-               int h = g.getFontMetrics().getAscent();\r
-               int w = g.getFontMetrics().stringWidth(s);\r
-               g.drawString(s, x - (int) (w * anchorX), y + (int) (h * anchorY));\r
-       }\r
\r
-       private void drawWire(Graphics g, Wire wa, String name, double x1, double y1, double x2, double y2)\r
-       {\r
-               setTo(g, wa);\r
-               g.drawLine(gX(x1), gY(y1), gX(x2), gY(y2));\r
-               drawString(g, name, (gX(x1) + gX(x2)) / 2, (gY(y1) + gY(y2)) / 2 - 5, 0, 0);\r
-       }\r
\r
-       private void drawSquare(Graphics g, int posX, int posY, String text)\r
-       {\r
-               int x1 = gX(posX) - 5;\r
-               int x2 = gX(posX + 1) + 5;\r
-               int y1 = gY(posY) - 5;\r
-               int y2 = gY(posY + 1) + 5;\r
\r
-               g.setColor(Color.WHITE);\r
-               g.fillRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);\r
-               setBlack(g);\r
-               g.drawRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);\r
-               drawString(g, text, (x1 + x2) / 2, (y1 + y2) / 2, 0.5, 0.5);\r
\r
-       }\r
\r
-       private void drawSwitch(Graphics g, ManualSwitch ms, String text, double posX1, double posY1, double posX2, double posY2)\r
-       {\r
-               int x1 = gX(posX1) - 5;\r
-               int x2 = gX(posX2) + 5;\r
-               int y1 = gY(posY1) - 5;\r
-               int y2 = gY(posY2) + 5;\r
\r
-               if (sizeChanged)\r
-               {\r
-                       Rectangle r = new Rectangle(x1, y1, x2 - x1, y2 - y1);\r
-                       switchMap.put(ms, r);\r
-               }\r
\r
-               g.setColor(ms.isOn() ? Color.getHSBColor(.3f, .5f, 1f) : Color.WHITE);\r
-               g.fillRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);\r
-               setBlack(g);\r
-               g.drawRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);\r
-               drawString(g, text, (x1 + x2) / 2, (y1 + y2) / 2, 0.5, 0.5);\r
-       }\r
\r
-       private static void setBlack(Graphics g)\r
-       {\r
-               g.setColor(Color.BLACK);\r
-       }\r
\r
-       private static void setTo(Graphics g, Wire wa)\r
-       {\r
-               switch (wa.getValue())\r
-               {\r
-               case ONE:\r
-                       g.setColor(Color.GREEN);\r
-                       break;\r
-               case X:\r
-                       g.setColor(Color.RED);\r
-                       break;\r
-               case Z:\r
-                       g.setColor(Color.DARK_GRAY);\r
-                       break;\r
-               case ZERO:\r
-                       g.setColor(Color.BLACK);\r
-                       break;\r
-               case U:\r
-                       g.setColor(Color.MAGENTA);\r
-                       break;\r
-               default:\r
-                       throw new IllegalArgumentException();\r
-               }\r
-       }\r
\r
-       private int gY(double pos)\r
-       {\r
-               return (int) (pos * height / 11);\r
-       }\r
\r
-       private int gX(double pos)\r
-       {\r
-               return (int) (pos * width / 11) + 50;\r
-       }\r
\r
-       public static void main(String[] args)\r
-       {\r
-               JFrame f = new JFrame("Test circuit 1.0.0");\r
-               GUITest gt = new GUITest();\r
-               f.add(gt);\r
-               f.setSize(800, 600);\r
-               f.setLocation(500, 400);\r
-               f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);\r
-               f.setVisible(true);\r
\r
-               long begin = System.currentTimeMillis();\r
\r
-               long lastFrame = begin;\r
-               long updateT = 16;\r
\r
-               while (f.isVisible())\r
-               {\r
-                       ExecutionResult er = Simulation.TIMELINE.executeUpTo((lastFrame - begin) * 3, lastFrame + 14);\r
- //                            if (Simulation.TIMELINE.hasNext()) \r
- //                            Simulation.TIMELINE.executeNext();\r
-                       if (er != ExecutionResult.NOTHING_DONE)\r
-                               gt.repaint(12);\r
-                       try\r
-                       {\r
-                               Thread.sleep(Math.max(updateT - System.currentTimeMillis() + lastFrame, 0));\r
-                       }\r
-                       catch (Exception e)\r
-                       {\r
-                               e.printStackTrace();\r
-                       }\r
-                       lastFrame = System.currentTimeMillis();\r
-               }\r
-       }\r
- }\r
++package era.mi.logic.tests;
++
++import java.awt.Color;
++import java.awt.Graphics;
++import java.awt.Graphics2D;
++import java.awt.Rectangle;
++import java.awt.RenderingHints;
++import java.awt.event.MouseEvent;
++import java.awt.event.MouseListener;
++import java.util.HashMap;
++import java.util.Map;
++import java.util.Map.Entry;
++
++import javax.swing.JFrame;
++import javax.swing.JPanel;
++import javax.swing.WindowConstants;
++
++import era.mi.logic.Simulation;
++import era.mi.logic.components.ManualSwitch;
++import era.mi.logic.components.gates.NotGate;
++import era.mi.logic.components.gates.OrGate;
++import era.mi.logic.timeline.Timeline.ExecutionResult;
++import era.mi.logic.wires.Wire;
++
++public class GUITest extends JPanel
++{
++
++      private static final long serialVersionUID = 1L;
++
++      private static final int WIRE_DELAY = 40;
++      private static final int OR_DELAY = 100;
++      private static final int NOT_DELAY = 100;
++
++      Wire r = new Wire(1, WIRE_DELAY);
++      Wire s = new Wire(1, WIRE_DELAY);
++      Wire t1 = new Wire(1, WIRE_DELAY);
++      Wire t2 = new Wire(1, WIRE_DELAY);
++      Wire q = new Wire(1, WIRE_DELAY);
++      Wire nq = new Wire(1, WIRE_DELAY);
++
++      ManualSwitch rIn = new ManualSwitch(r.createEnd());
++      ManualSwitch sIn = new ManualSwitch(s.createEnd());
++
++      OrGate or1 = new OrGate(OR_DELAY, t2.createEnd(), r.createEnd(), nq.createEnd());
++      OrGate or2 = new OrGate(OR_DELAY, t1.createEnd(), s.createEnd(), q.createEnd());
++      NotGate not1 = new NotGate(NOT_DELAY, t2.createEnd(), q.createEnd());
++      NotGate not2 = new NotGate(NOT_DELAY, t1.createEnd(), nq.createEnd());
++
++      Map<ManualSwitch, Rectangle> switchMap = new HashMap<>();
++
++      int height;
++      int width;
++      boolean sizeChanged;
++
++      public GUITest()
++      {
++              addMouseListener(new MouseListener()
++              {
++
++                      @Override
++                      public void mouseReleased(MouseEvent e)
++                      {
++                              for (Entry<ManualSwitch, Rectangle> dim : switchMap.entrySet())
++                              {
++                                      if (dim.getValue().contains(e.getPoint()))
++                                      {
++                                              dim.getKey().switchOff();
++                                              repaint();
++                                      }
++                              }
++                      }
++
++                      @Override
++                      public void mousePressed(MouseEvent e)
++                      {
++                              for (Entry<ManualSwitch, Rectangle> dim : switchMap.entrySet())
++                              {
++                                      if (dim.getValue().contains(e.getPoint()))
++                                      {
++                                              dim.getKey().switchOn();
++                                              repaint();
++                                      }
++                              }
++                      }
++
++                      @Override
++                      public void mouseExited(MouseEvent e)
++                      {
++                              // none
++                      }
++
++                      @Override
++                      public void mouseEntered(MouseEvent e)
++                      {
++                              // none
++                      }
++
++                      @Override
++                      public void mouseClicked(MouseEvent e)
++                      {
++                              // If you want toggle buttons, use this code instead
++//                            for (Entry<ManualSwitch, Rectangle> dim : switchMap.entrySet()) {
++//                                    if (dim.getValue().contains(e.getPoint())) {
++//                                            dim.getKey().toggle();
++//                                            repaint();
++//                                    }
++//                            }
++                      }
++              });
++      }
++
++      @Override
++      public void paint(Graphics some_g)
++      {
++              super.paint(some_g);
++              Graphics2D g = ((Graphics2D) some_g);
++              g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
++              g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
++              g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
++
++              checkSizeChange();
++              adaptFont(g);
++
++              drawWire(g, r, "r", 2, 9, 4, 9);
++
++              drawWire(g, s, "s", 2, 3, 4, 3);
++
++              drawWire(g, t2, "t2", 5, 8.5, 6, 8.5);
++
++              drawWire(g, t1, "t1", 5, 3.5, 6, 3.5);
++
++              drawWire(g, q, "q", 7, 8.5, 9, 8.5);
++
++              drawWire(g, nq, "nq", 7, 3.5, 9, 3.5);
++
++              drawWire(g, q, "", 7.5, 8.5, 7.5, 7.5);
++              drawWire(g, q, "", 7.5, 7.5, 3, 4.5);
++              drawWire(g, q, "", 3, 4.5, 3, 4);
++              drawWire(g, q, "q", 3, 4, 4, 4);
++
++              drawWire(g, nq, "", 7.5, 3.5, 7.5, 4.5);
++              drawWire(g, nq, "", 7.5, 4.5, 3, 7.5);
++              drawWire(g, nq, "", 3, 7.5, 3, 8);
++              drawWire(g, nq, "nq", 3, 8, 4, 8);
++
++              drawSquare(g, 4, 8, "OR");
++              drawSquare(g, 4, 3, "OR");
++
++              drawSquare(g, 6, 8, "NOT");
++              drawSquare(g, 6, 3, "NOT");
++
++              drawSwitch(g, rIn, "Switch R", 0.5, 8.25, 2, 9.75);
++              drawSwitch(g, sIn, "Switch S", 0.5, 2.25, 2, 3.75);
++
++              drawString(g, "Hint: drag the cursor out of the pressed switch to keep it's state", 5, 0, 0.0, 1.0);
++      }
++
++      private void checkSizeChange()
++      {
++              sizeChanged = height != getHeight() || width != getWidth();
++              if (sizeChanged)
++              {
++                      height = getHeight();
++                      width = getWidth();
++              }
++      }
++
++      private void adaptFont(Graphics g)
++      {
++              g.setFont(g.getFont().deriveFont(Math.min(height, width) / 40f));
++      }
++
++      private void drawString(Graphics g, String s, int x, int y, double anchorX, double anchorY)
++      {
++              int h = g.getFontMetrics().getAscent();
++              int w = g.getFontMetrics().stringWidth(s);
++              g.drawString(s, x - (int) (w * anchorX), y + (int) (h * anchorY));
++      }
++
++      private void drawWire(Graphics g, Wire wa, String name, double x1, double y1, double x2, double y2)
++      {
++              setTo(g, wa);
++              g.drawLine(gX(x1), gY(y1), gX(x2), gY(y2));
++              drawString(g, name, (gX(x1) + gX(x2)) / 2, (gY(y1) + gY(y2)) / 2 - 5, 0, 0);
++      }
++
++      private void drawSquare(Graphics g, int posX, int posY, String text)
++      {
++              int x1 = gX(posX) - 5;
++              int x2 = gX(posX + 1) + 5;
++              int y1 = gY(posY) - 5;
++              int y2 = gY(posY + 1) + 5;
++
++              g.setColor(Color.WHITE);
++              g.fillRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
++              setBlack(g);
++              g.drawRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
++              drawString(g, text, (x1 + x2) / 2, (y1 + y2) / 2, 0.5, 0.5);
++
++      }
++
++      private void drawSwitch(Graphics g, ManualSwitch ms, String text, double posX1, double posY1, double posX2, double posY2)
++      {
++              int x1 = gX(posX1) - 5;
++              int x2 = gX(posX2) + 5;
++              int y1 = gY(posY1) - 5;
++              int y2 = gY(posY2) + 5;
++
++              if (sizeChanged)
++              {
++                      Rectangle r = new Rectangle(x1, y1, x2 - x1, y2 - y1);
++                      switchMap.put(ms, r);
++              }
++
++              g.setColor(ms.isOn() ? Color.getHSBColor(.3f, .5f, 1f) : Color.WHITE);
++              g.fillRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
++              setBlack(g);
++              g.drawRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
++              drawString(g, text, (x1 + x2) / 2, (y1 + y2) / 2, 0.5, 0.5);
++      }
++
++      private static void setBlack(Graphics g)
++      {
++              g.setColor(Color.BLACK);
++      }
++
++      private static void setTo(Graphics g, Wire wa)
++      {
++              switch (wa.getValue())
++              {
++              case ONE:
++                      g.setColor(Color.GREEN);
++                      break;
++              case X:
++                      g.setColor(Color.RED);
++                      break;
++              case Z:
++                      g.setColor(Color.DARK_GRAY);
++                      break;
++              case ZERO:
++                      g.setColor(Color.BLACK);
++                      break;
++              case U:
++                      g.setColor(Color.MAGENTA);
++                      break;
++              default:
++                      throw new IllegalArgumentException();
++              }
++      }
++
++      private int gY(double pos)
++      {
++              return (int) (pos * height / 11);
++      }
++
++      private int gX(double pos)
++      {
++              return (int) (pos * width / 11) + 50;
++      }
++
++      public static void main(String[] args)
++      {
++              JFrame f = new JFrame("Test circuit 1.0.0");
++              GUITest gt = new GUITest();
++              f.add(gt);
++              f.setSize(800, 600);
++              f.setLocation(500, 400);
++              f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
++              f.setVisible(true);
++
++              long begin = System.currentTimeMillis();
++
++              long lastFrame = begin;
++              long updateT = 16;
++
++              while (f.isVisible())
++              {
++                      ExecutionResult er = Simulation.TIMELINE.executeUpTo((lastFrame - begin) * 3, lastFrame + 14);
++//                            if (Simulation.TIMELINE.hasNext()) 
++//                            Simulation.TIMELINE.executeNext();
++                      if (er != ExecutionResult.NOTHING_DONE)
++                              gt.repaint(12);
++                      try
++                      {
++                              Thread.sleep(Math.max(updateT - System.currentTimeMillis() + lastFrame, 0));
++                      }
++                      catch (Exception e)
++                      {
++                              e.printStackTrace();
++                      }
++                      lastFrame = System.currentTimeMillis();
++              }
++      }
++}