1 package net.mograsim.logic.ui.model.components;
5 import net.haspamelodica.swt.helper.gcs.GeneralGC;
6 import net.haspamelodica.swt.helper.swtobjectwrappers.Font;
7 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
8 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
9 import net.mograsim.logic.ui.model.ViewModel;
10 import net.mograsim.logic.ui.model.wires.Pin;
12 // TODO make a superclass
13 public class Am2901NANDBased extends GUIComponent
15 public final List<String> inputNames;
16 public final List<String> outputNames;
18 public Am2901NANDBased(ViewModel model)
22 this.inputNames = List.of("I8", "I7", "I6", "I5", "I4", "I3", "I2", "I1", "I0", "C", "Cn", "D1", "D2", "D3", "D4", "A0", "A1", "A2",
23 "A3", "B0", "B1", "B2", "B3", "IRAMn", "IRAMn+3", "IQn", "IQn+3");
24 this.outputNames = List.of("Y1", "Y2", "Y3", "Y4", "F=0", "Cn+4", "OVR", "F3_ORAMn+3", "ORAMn", "OQn", "OQn+3");
25 setSize(50, inputNames.size() * 10);
26 for (int i = 0; i < inputNames.size(); i++)
27 addPin(new Pin(this, 1, 0, 5 + 10 * i));
28 for (int i = 0; i < outputNames.size(); i++)
29 addPin(new Pin(this, 1, 50, 5 + 10 * i));
33 public void render(GeneralGC gc, Rectangle visibleRegion)
35 double posX = getBounds().x;
36 double posY = getBounds().y;
38 Font oldFont = gc.getFont();
39 Font labelFont = new Font(oldFont.getName(), 4, oldFont.getStyle());
40 gc.setFont(labelFont);
41 gc.drawRectangle(posX, posY, 50, getBounds().height);
42 for (int i = 0; i < inputNames.size(); i++)
44 Point textExtent = gc.textExtent(inputNames.get(i));
45 gc.drawText(inputNames.get(i), posX, posY + 5 + 10 * i - textExtent.y / 2, true);
47 for (int i = 0; i < outputNames.size(); i++)
49 Point textExtent = gc.textExtent(outputNames.get(i));
50 gc.drawText(outputNames.get(i), posX + 50 - textExtent.x, posY + 5 + 10 * i - textExtent.y / 2, true);