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