Made formatting uniform - commit for logicui
[Mograsim.git] / LogicUI / src / era / mi / gui / wires / WireConnectionPoint.java
1 package era.mi.gui.wires;
2
3 import org.eclipse.swt.graphics.Color;
4
5 import era.mi.gui.components.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                 if (wa.length == 1)
27                         gc.setBackground(gc.getDevice().getSystemColor(GUIWire.getSWTColorConstantForBit(wa.getValue())));
28                 gc.fillOval(-1, -1, 2, 2);
29                 gc.setBackground(oldBG);
30         }
31
32         @Override
33         public Rectangle getBounds()
34         {
35                 return new Rectangle(0, 0, 0, 0);
36         }
37
38         @Override
39         public int getConnectedWireArraysCount()
40         {
41                 return wiresCrossing;
42         }
43
44         @Override
45         public WireArray getConnectedWireArray(int connectionIndex)
46         {
47                 return wa;
48         }
49
50         @Override
51         public Point getWireArrayConnectionPoint(int connectionIndex)
52         {
53                 return new Point(0, 0);
54         }
55 }