Speedup by changing redraw listener system
[Mograsim.git] / net.mograsim.logic.model.am2900 / test / net / mograsim / logic / model / am2900 / Am2901Testbench.java
index d6057f8..a5b6b8a 100644 (file)
@@ -1,6 +1,7 @@
 package net.mograsim.logic.model.am2900;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 
 import net.mograsim.logic.model.SimpleLogicUIStandalone;
@@ -51,7 +52,7 @@ public class Am2901Testbench
                Pin last = and.getPin("Y");
 
                // guess which pins are outputs and which are inputs
-               // TODO this code exists three times... but it seems too "hacky" to put it in a helper class
+               // TODO this code exists four times... but it seems too "hacky" to put it in a helper class
                List<String> inputPinNames = new ArrayList<>();
                List<String> outputPinNames = new ArrayList<>();
                for (Pin p : comp.getPins().values())
@@ -60,6 +61,9 @@ public class Am2901Testbench
                        else
                                outputPinNames.add(p.name);
 
+               inputPinNames.sort(Comparator.comparing(comp::getPin, Comparator.comparing(Pin::getRelY)));
+               outputPinNames.sort(Comparator.comparing(comp::getPin, Comparator.comparing(Pin::getRelY)));
+
                for (int i = 0; i < inputPinNames.size(); i++)
                {
                        double x = 55 + 70 * (i % 2);