Implemented the RS-Latch-Example
[Mograsim.git] / LogicUI / src / era / mi / wires / gui / WireConnectionPoint.java
1 package era.mi.wires.gui;
2
3 import org.eclipse.swt.graphics.Color;
4
5 import era.mi.components.gui.BasicGUIComponent;
6 import era.mi.logic.wires.WireArray;
7 import net.haspamelodica.swt.helper.gcs.GeneralGC;
8 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
9 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
10
11 public class WireConnectionPoint implements BasicGUIComponent
12 {
13         private final WireArray wa;
14         private final int               wiresCrossing;
15
16         public WireConnectionPoint(WireArray wa, int wiresCrossing)
17         {
18                 this.wa = wa;
19                 this.wiresCrossing = wiresCrossing;
20         }
21
22         @Override
23         public void render(GeneralGC gc)
24         {
25                 Color oldBG = gc.getBackground();
26                 Color fg = gc.getForeground();
27                 gc.setBackground(fg);
28                 gc.fillOval(-2, -2, 4, 4);
29                 gc.setBackground(oldBG);
30         }
31         @Override
32         public Rectangle getBounds()
33         {
34                 return new Rectangle(0, 0, 0, 0);
35         }
36         @Override
37         public int getConnectedWireArraysCount()
38         {
39                 return wiresCrossing;
40         }
41         @Override
42         public WireArray getConnectedWireArray(int connectionIndex)
43         {
44                 return wa;
45         }
46         @Override
47         public Point getWireArrayConnectionPoint(int connectionIndex)
48         {
49                 return new Point(0, 0);
50         }
51 }