package net.mograsim.logic.model.am2900;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.List;
import net.mograsim.logic.model.SimpleLogicUIStandalone;
comp.moveTo(240, 0);
- GUIManualSwitch enable = new GUIManualSwitch(model);
+ GUIManualSwitch enable = new GUIManualSwitch(model, 1);
WireCrossPoint wcp0 = new WireCrossPoint(model, 1);
GUINotGate not1 = new GUINotGate(model, 1);
GUINotGate not2 = new GUINotGate(model, 1);
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())
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);
WireCrossPoint wcp = new WireCrossPoint(model, 1);
GUIComponent d_ff = IndirectGUIComponentCreator.createComponent(model, "GUIdff");
- GUIManualSwitch sw = new GUIManualSwitch(model);
+ GUIManualSwitch sw = new GUIManualSwitch(model, 1);
tool.connect(last, wcp);
tool.connect(wcp, d_ff, "C");
sw.moveTo(x, y + 7.5);
wcp.moveTo(160, y);
d_ff.moveTo(170, y);
- label.moveTo(x - 25, y + 15);
+ label.moveTo(x - 48, y + 8);
}
for (int i = 0; i < outputPinNames.size(); i++)
{
double x = 300 + 75 * (i % 2);
double y = 10 * i - 2.5;
- GUIBitDisplay bd = new GUIBitDisplay(model);
+ GUIBitDisplay bd = new GUIBitDisplay(model, 1);
bd.moveTo(x, y);
tool.connect(bd.getInputPin(), comp, outputPinNames.get(i));
TextComponent label = new TextComponent(model, outputPinNames.get(i));
- label.moveTo(x + 50, y + 8);
+ label.moveTo(x + 25, y);
}
}
}
\ No newline at end of file