Started restructuring LogicUI
[Mograsim.git] / LogicUI / src / era / mi / gui / model / wires / Pin.java
1 package era.mi.gui.model.wires;
2
3 import era.mi.gui.model.components.GUIComponent;
4 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
5 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
6
7 public class Pin
8 {
9         public final GUIComponent component;
10         protected double relX;
11         protected double relY;
12
13         public Pin(GUIComponent component, double relX, double relY)
14         {
15                 this.component = component;
16                 this.relX = relX;
17                 this.relY = relY;
18         }
19
20         public double getRelX()
21         {
22                 return relX;
23         }
24
25         public double getRelY()
26         {
27                 return relY;
28         }
29
30         public Point getRelPos()
31         {
32                 return new Point(relX, relY);
33         }
34
35         public Point getPos()
36         {
37                 Rectangle componentBounds = component.getBounds();
38                 return new Point(relX + componentBounds.x, relY + componentBounds.y);
39         }
40
41         protected void setRelPos(double relX, double relY)
42         {
43                 this.relX = relX;
44                 this.relY = relY;
45         }
46 }