1 package era.mi.components.gui;
\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
13 public class GUINotGate extends NotGate implements BasicGUIComponent
\r
15 private static final String LABEL = "\u22651";//>=1
\r
17 private final List<WireArray> connectedWireArrays;
\r
18 private final List<Point> wireArrayConnectionPoints;
\r
20 public GUINotGate(int processTime, WireArray in, WireArray out)
\r
22 super(processTime, in, out);
\r
24 List<WireArray> connectedWireArraysModifiable = new ArrayList<>();
\r
25 List<Point> wireArrayConnectionPointsModifiable = new ArrayList<>();
\r
27 connectedWireArraysModifiable.add(in);
\r
28 wireArrayConnectionPointsModifiable.add(new Point(0, 5));
\r
30 connectedWireArraysModifiable.add(out);
\r
31 wireArrayConnectionPointsModifiable.add(new Point(20, 5));
\r
33 this.connectedWireArrays = Collections.unmodifiableList(connectedWireArraysModifiable);
\r
34 this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable);
\r
38 public void render(GeneralGC gc)
\r
40 gc.drawRectangle(0, 0, 17, 10);
\r
41 Font oldFont = gc.getFont();
\r
42 Font labelFont = new Font(oldFont.getName(), 5, oldFont.getStyle());
\r
43 gc.setFont(labelFont);
\r
44 Point textExtent = gc.textExtent(LABEL);
\r
45 gc.drawText(LABEL, 10 - textExtent.x / 2, 5 - textExtent.y / 2, true);
\r
46 gc.setFont(oldFont);
\r
47 gc.drawOval(17, 3.5, 3, 3);
\r
51 public int getConnectedWireArraysCount()
\r
53 return connectedWireArrays.size();
\r
56 public WireArray getConnectedWireArray(int connectionIndex)
\r
58 return connectedWireArrays.get(connectionIndex);
\r
61 public Point getWireArrayConnectionPoint(int connectionI)
\r
63 return wireArrayConnectionPoints.get(connectionI);
\r