Added getters for pin1 and pin2 in GUIWire
[Mograsim.git] / LogicUI / src / era / mi / gui / model / wires / GUIWire.java
index 0f7ff08..6bcbd1c 100644 (file)
@@ -14,6 +14,7 @@ import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
 public class GUIWire
 {
        private final ViewModel model;
+       public final int logicWidth;
        private Pin pin1;
        private Pin pin2;
        private double[] path;
@@ -25,6 +26,9 @@ public class GUIWire
        public GUIWire(ViewModel model, Pin pin1, Pin pin2, Point... path)
        {
                this.model = model;
+               this.logicWidth = pin1.logicWidth;
+               if (pin2.logicWidth != pin1.logicWidth)
+                       throw new IllegalArgumentException("Can't connect pins of different logic width");
                this.path = new double[path.length * 2 + 4];
                for (int srcI = 0, dstI = 2; srcI < path.length; srcI++, dstI += 2)
                {
@@ -75,6 +79,16 @@ public class GUIWire
                end.addObserver((i, o) -> callWireLookChangedListeners());
        }
 
+       public Pin getPin1()
+       {
+               return pin1;
+       }
+
+       public Pin getPin2()
+       {
+               return pin2;
+       }
+
        // @formatter:off
        public void addWireLookChangedListener   (Consumer<? super GUIWire> listener) {wireLookChangedListeners.add   (listener);}