1 package era.mi.components.gui;
3 import java.util.ArrayList;
4 import java.util.Collections;
7 import era.mi.logic.components.gates.NotGate;
8 import era.mi.logic.wires.WireArray;
9 import net.haspamelodica.swt.helper.gcs.GeneralGC;
10 import net.haspamelodica.swt.helper.swtobjectwrappers.Font;
11 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
12 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
14 public class GUINotGate extends NotGate implements BasicGUIComponent
16 private static final String LABEL = "\u22651";//>=1
18 private final List<WireArray> connectedWireArrays;
19 private final List<Point> wireArrayConnectionPoints;
21 public GUINotGate(int processTime, WireArray in, WireArray out)
23 super(processTime, in, out);
25 List<WireArray> connectedWireArraysModifiable = new ArrayList<>();
26 List<Point> wireArrayConnectionPointsModifiable = new ArrayList<>();
28 connectedWireArraysModifiable.add(in);
29 wireArrayConnectionPointsModifiable.add(new Point(0, 5));
31 connectedWireArraysModifiable.add(out);
32 wireArrayConnectionPointsModifiable.add(new Point(20, 5));
34 this.connectedWireArrays = Collections.unmodifiableList(connectedWireArraysModifiable);
35 this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable);
39 public Rectangle getBounds()
41 return new Rectangle(0, 0, 20, 10);
44 public void render(GeneralGC gc)
46 gc.drawRectangle(0, 0, 17, 10);
47 Font oldFont = gc.getFont();
48 Font labelFont = new Font(oldFont.getName(), 5, oldFont.getStyle());
49 gc.setFont(labelFont);
50 Point textExtent = gc.textExtent(LABEL);
51 gc.drawText(LABEL, 8.5 - textExtent.x / 2, 5 - textExtent.y / 2, true);
53 gc.drawOval(17, 3.5, 3, 3);
57 public int getConnectedWireArraysCount()
59 return connectedWireArrays.size();
62 public WireArray getConnectedWireArray(int connectionIndex)
64 return connectedWireArrays.get(connectionIndex);
67 public Point getWireArrayConnectionPoint(int connectionI)
69 return wireArrayConnectionPoints.get(connectionI);