A GUIWire now can trigger a redraw
[Mograsim.git] / LogicUI / src / era / mi / wires / gui / GUIWire.java
index 7cfa796..1de3e9e 100644 (file)
@@ -12,7 +12,7 @@ public class GUIWire
        private final WireArray wa;\r
        private final double[]  path;\r
 \r
-       public GUIWire(BasicGUIComponent component1, int component1ConnectionIndex, Point component1Pos, BasicGUIComponent component2, int component2ConnectionIndex, Point component2Pos, Point... path)\r
+       public GUIWire(Runnable redraw, BasicGUIComponent component1, int component1ConnectionIndex, Point component1Pos, BasicGUIComponent component2, int component2ConnectionIndex, Point component2Pos, Point... path)\r
        {\r
                this.wa = component1.getConnectedWireArray(component1ConnectionIndex);\r
                if(!Objects.equals(wa, component2.getConnectedWireArray(component2ConnectionIndex)))\r
@@ -29,6 +29,8 @@ public class GUIWire
                Point component2ConnectionPoint = component2.getWireArrayConnectionPoint(component2ConnectionIndex);\r
                this.path[this.path.length - 2] = component2Pos.x + component2ConnectionPoint.x;\r
                this.path[this.path.length - 1] = component2Pos.y + component2ConnectionPoint.y;\r
+\r
+               wa.addObserver((initiator, oldValues) -> redraw.run());\r
        }\r
 \r
        public void render(GeneralGC gc)\r