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