X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fwires%2FPin.java;h=aec2df0816f33cf81aa01d6838101e9ac65fcb5b;hb=f14ea37d69488dd51518a36413af7176916b8bd7;hp=f8325a098fbe05ae15703a538572f5dafb8a9338;hpb=04218dc9e67abb384c4d031620ef3f8329ac861e;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/Pin.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/Pin.java index f8325a09..aec2df08 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/Pin.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/Pin.java @@ -5,13 +5,12 @@ import java.util.List; import java.util.function.Consumer; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; -import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.mograsim.logic.ui.model.components.GUIComponent; -//TODO add an ID and/or a name public class Pin { public final GUIComponent component; + public final String name; public final int logicWidth; protected double relX; @@ -20,9 +19,10 @@ public class Pin private final List> pinMovedListeners; private final List redrawListeners; - public Pin(GUIComponent component, int logicWidth, double relX, double relY) + public Pin(GUIComponent component, String name, int logicWidth, double relX, double relY) { this.component = component; + this.name = name; this.logicWidth = logicWidth; this.relX = relX; this.relY = relY; @@ -50,8 +50,7 @@ public class Pin public Point getPos() { - Rectangle componentBounds = component.getBounds(); - return new Point(relX + componentBounds.x, relY + componentBounds.y); + return new Point(relX + component.getPosX(), relY + component.getPosY()); } protected void setRelPos(double relX, double relY) @@ -73,4 +72,9 @@ public class Pin private void callRedrawListeners () {redrawListeners .forEach(l -> l.run ( ));} // @formatter:on + @Override + public String toString() + { + return "Pin [" + name + ", point=" + getPos() + "]"; + } } \ No newline at end of file