1 package era.mi.gui.components;
3 import java.util.ArrayList;
4 import java.util.Collections;
7 import era.mi.logic.components.gates.NotGate;
8 import era.mi.logic.wires.Wire.WireEnd;
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<WireEnd> connectedWireEnds;
19 private final List<Point> WireEndConnectionPoints;
21 public GUINotGate(int processTime, WireEnd in, WireEnd out)
23 super(processTime, in, out);
25 List<WireEnd> connectedWireEndsModifiable = new ArrayList<>();
26 List<Point> WireEndConnectionPointsModifiable = new ArrayList<>();
28 connectedWireEndsModifiable.add(in);
29 WireEndConnectionPointsModifiable.add(new Point(0, 5));
31 connectedWireEndsModifiable.add(out);
32 WireEndConnectionPointsModifiable.add(new Point(20, 5));
34 this.connectedWireEnds = Collections.unmodifiableList(connectedWireEndsModifiable);
35 this.WireEndConnectionPoints = Collections.unmodifiableList(WireEndConnectionPointsModifiable);
39 public Rectangle getBounds()
41 return new Rectangle(0, 0, 20, 10);
45 public void render(GeneralGC gc)
47 gc.drawRectangle(0, 0, 17, 10);
48 Font oldFont = gc.getFont();
49 Font labelFont = new Font(oldFont.getName(), 5, oldFont.getStyle());
50 gc.setFont(labelFont);
51 Point textExtent = gc.textExtent(LABEL);
52 gc.drawText(LABEL, 8.5 - textExtent.x / 2, 5 - textExtent.y / 2, true);
54 gc.drawOval(17, 3.5, 3, 3);
58 public int getConnectedWireEndsCount()
60 return connectedWireEnds.size();
64 public WireEnd getConnectedWireEnd(int connectionIndex)
66 return connectedWireEnds.get(connectionIndex);
70 public Point getWireEndConnectionPoint(int connectionI)
72 return WireEndConnectionPoints.get(connectionI);