X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fmodel%2Fwires%2FGUIWire.java;h=99241a3e4372cee8e4d0952c8949b8000c4ab970;hb=662eb9515b9fcbccc4997f50fecfb597ee8eb316;hp=144a1a380fb684cd51636dc56835cfde57878abe;hpb=a47c9b1f38bbb6d2f5a3c482f3b09d1f42270401;p=Mograsim.git diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java index 144a1a38..99241a3e 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/GUIWire.java @@ -61,7 +61,6 @@ public class GUIWire */ private double[] effectivePath; - private final List redrawListeners; private final List> pathChangedListeners; /** @@ -244,10 +243,9 @@ public class GUIWire this.path = path == null ? null : Arrays.copyOf(path, path.length); this.bounds = new Rectangle(0, 0, -1, -1); - redrawListeners = new ArrayList<>(); pathChangedListeners = new ArrayList<>(); - logicObs = (i) -> callRedrawListeners(); + logicObs = (i) -> model.requestRedraw(); pin1.addPinMovedListener(p -> pinMoved()); pin2.addPinMovedListener(p -> pinMoved()); @@ -298,7 +296,7 @@ public class GUIWire private void pinMoved() { recalculateEffectivePath(); - callRedrawListeners(); + model.requestRedraw(); } // "graphical" operations @@ -366,6 +364,7 @@ public class GUIWire */ public void render(GeneralGC gc) { + // TODO maybe make wires with logicWidth!=1 thicker? Maybe make thickness selectable? ColorDefinition wireColor = BitVectorFormatter.formatAsColor(end); if (wireColor != null) gc.setForeground(ColorManager.current().toColor(wireColor)); @@ -392,7 +391,7 @@ public class GUIWire this.path = deepPathCopy(path); recalculateEffectivePath(); callPathChangedListeners(); - callRedrawListeners(); + model.requestRedraw(); } public Point getPathPoint(int index) @@ -405,7 +404,7 @@ public class GUIWire path[index] = pointCopy(p); recalculateEffectivePath(); callPathChangedListeners(); - callRedrawListeners(); + model.requestRedraw(); } public void insertPathPoint(Point p, int index) @@ -514,13 +513,10 @@ public class GUIWire // listeners // @formatter:off - public void addRedrawListener (Runnable listener) {redrawListeners .add (listener);} public void addPathChangedListener (Consumer listener) {pathChangedListeners.add (listener);} - public void removeRedrawListener (Runnable listener) {redrawListeners .remove(listener);} public void removePathChangedListener(Consumer listener) {pathChangedListeners.remove(listener);} - private void callRedrawListeners () {redrawListeners .forEach(l -> l.run ( ));} private void callPathChangedListeners() {pathChangedListeners.forEach(l -> l.accept(this));} // @formatter:on