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.ViewModelModifiable;
10 import net.mograsim.logic.ui.model.wires.Pin;
12 public class AtomicAm2901NANDBased extends GUIComponent
14 public final List<String> inputNames;
15 public final List<String> outputNames;
17 public AtomicAm2901NANDBased(ViewModelModifiable model)
21 this.inputNames = List.of("I8", "I7", "I6", "I5", "I4", "I3", "I2", "I1", "I0", "C", "Cn", "D1", "D2", "D3", "D4", "A0", "A1", "A2",
22 "A3", "B0", "B1", "B2", "B3", "IRAMn", "IRAMn+3", "IQn", "IQn+3");
23 this.outputNames = List.of("Y1", "Y2", "Y3", "Y4", "F=0", "Cn+4", "OVR", "F3_ORAMn+3", "ORAMn", "OQn", "OQn+3");
24 setSize(50, inputNames.size() * 10);
25 for (int i = 0; i < inputNames.size(); i++)
26 addPin(new Pin(this, "Input pin #" + i, 1, 0, 5 + 10 * i));
27 for (int i = 0; i < outputNames.size(); i++)
28 addPin(new Pin(this, "Output pin #" + i, 1, 50, 5 + 10 * i));
32 public void render(GeneralGC gc, Rectangle visibleRegion)
34 double posX = getBounds().x;
35 double posY = getBounds().y;
37 gc.drawRectangle(getBounds());
38 Font oldFont = gc.getFont();
39 Font labelFont = new Font(oldFont.getName(), 4, oldFont.getStyle());
40 gc.setFont(labelFont);
41 for (int i = 0; i < inputNames.size(); i++)
43 Point textExtent = gc.textExtent(inputNames.get(i));
44 gc.drawText(inputNames.get(i), posX, posY + 5 + 10 * i - textExtent.y / 2, true);
46 for (int i = 0; i < outputNames.size(); i++)
48 Point textExtent = gc.textExtent(outputNames.get(i));
49 gc.drawText(outputNames.get(i), posX + 50 - textExtent.x, posY + 5 + 10 * i - textExtent.y / 2, true);