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.timeline.Timeline;
9 import era.mi.logic.wires.Wire.ReadEnd;
10 import era.mi.logic.wires.Wire.ReadWriteEnd;
11 import net.haspamelodica.swt.helper.gcs.GeneralGC;
12 import net.haspamelodica.swt.helper.swtobjectwrappers.Font;
13 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
14 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
16 public class GUINotGate extends NotGate implements BasicGUIComponent
18 private static final String LABEL = "\u22651";// >=1
20 private final List<ReadEnd> connectedWireEnds;
21 private final List<Point> WireEndConnectionPoints;
23 public GUINotGate(Timeline timeline, int processTime, ReadEnd in, ReadWriteEnd out)
25 super(timeline, processTime, in, out);
27 List<ReadEnd> connectedWireEndsModifiable = new ArrayList<>();
28 List<Point> WireEndConnectionPointsModifiable = new ArrayList<>();
30 connectedWireEndsModifiable.add(in);
31 WireEndConnectionPointsModifiable.add(new Point(0, 5));
33 connectedWireEndsModifiable.add(out);
34 WireEndConnectionPointsModifiable.add(new Point(20, 5));
36 this.connectedWireEnds = Collections.unmodifiableList(connectedWireEndsModifiable);
37 this.WireEndConnectionPoints = Collections.unmodifiableList(WireEndConnectionPointsModifiable);
41 public Rectangle getBounds()
43 return new Rectangle(0, 0, 20, 10);
47 public void render(GeneralGC gc)
49 gc.drawRectangle(0, 0, 17, 10);
50 Font oldFont = gc.getFont();
51 Font labelFont = new Font(oldFont.getName(), 5, oldFont.getStyle());
52 gc.setFont(labelFont);
53 Point textExtent = gc.textExtent(LABEL);
54 gc.drawText(LABEL, 8.5 - textExtent.x / 2, 5 - textExtent.y / 2, true);
56 gc.drawOval(17, 3.5, 3, 3);
60 public int getConnectedWireEndsCount()
62 return connectedWireEnds.size();
66 public ReadEnd getConnectedWireEnd(int connectionIndex)
68 return connectedWireEnds.get(connectionIndex);
72 public Point getWireEndConnectionPoint(int connectionI)
74 return WireEndConnectionPoints.get(connectionI);