X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fexamples%2FGUIComponentTestbench.java;h=25c90ae0d1a1a0f5f6caee62aa0b5eeb657c6f85;hb=d85136c6ced4145e62d704de27abaab0465504a7;hp=e5b24f1c2e1582afc726397c0c845f79f7129ddd;hpb=f37f1f93f2c1ceb780f1c7ecab888bcb8f4f8b89;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java index e5b24f1c..25c90ae0 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java @@ -9,10 +9,9 @@ import net.mograsim.logic.model.model.ViewModelModifiable; import net.mograsim.logic.model.model.components.GUIComponent; import net.mograsim.logic.model.model.components.atomic.GUIBitDisplay; import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch; -import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent; -import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent.Usage; import net.mograsim.logic.model.model.wires.GUIWire; import net.mograsim.logic.model.model.wires.Pin; +import net.mograsim.logic.model.model.wires.PinUsage; import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator; public class GUIComponentTestbench @@ -25,26 +24,16 @@ public class GUIComponentTestbench @SuppressWarnings("unused") // for GUIWires being created public static void createTestbench(ViewModelModifiable model) { - GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "file:components/am2904/GUIAm2904.json"); + GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, + "resource:net.mograsim.logic.model.am2900.Am2900Loader:/components/GUIAm2900.json"); - // guess which pins are outputs and which are inputs - // TODO this code exists four times... but it seems too "hacky" to put it in a helper class List inputPinNames = new ArrayList<>(); List outputPinNames = new ArrayList<>(); - if (comp instanceof SimpleRectangularHardcodedGUIComponent) - { - SimpleRectangularHardcodedGUIComponent compCasted = (SimpleRectangularHardcodedGUIComponent) comp; - for (Pin p : comp.getPins().values()) - if (compCasted.getPinUsage(p) == Usage.INPUT) - inputPinNames.add(p.name); - else - outputPinNames.add(p.name); - } else - for (Pin p : comp.getPins().values()) - if (p.getRelX() < comp.getWidth()) - inputPinNames.add(p.name); - else - outputPinNames.add(p.name); + for (Pin p : comp.getPins().values()) + if (p.usage == PinUsage.INPUT) + inputPinNames.add(p.name); + 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)));