X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fwires%2FWireConnectionPoint.java;h=f095f0d0bbafb356010ce621d8b35bbd7cb0be14;hb=4be7eddcfc45e5e5794bd0dc1e2c2423fa43ec51;hp=8c2df1d518ccb3337458a42eb1123507e53fb16f;hpb=c5217d7f47490bbb053bf13e94e7b5bc697e255c;p=Mograsim.git diff --git a/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java b/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java index 8c2df1d5..f095f0d0 100644 --- a/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java +++ b/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java @@ -1,21 +1,31 @@ package era.mi.gui.wires; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import org.eclipse.swt.graphics.Color; import era.mi.gui.components.BasicGUIComponent; -import era.mi.logic.wires.WireArray; +import era.mi.logic.wires.Wire; +import era.mi.logic.wires.Wire.WireEnd; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; public class WireConnectionPoint implements BasicGUIComponent { - private final WireArray wa; - private final int wiresCrossing; + private final Wire wire; + private final List wireEnds; + private final int wiresCrossing; - public WireConnectionPoint(WireArray wa, int wiresCrossing) + public WireConnectionPoint(Wire wire, int wiresCrossing) { - this.wa = wa; + this.wire = wire; + List wireEndsModifiable = new ArrayList<>(); + for (int i = 0; i < wiresCrossing; i++) + wireEndsModifiable.add(wire.createReadOnlyEnd()); + wireEnds = Collections.unmodifiableList(wireEndsModifiable); this.wiresCrossing = wiresCrossing; } @@ -23,28 +33,32 @@ public class WireConnectionPoint implements BasicGUIComponent public void render(GeneralGC gc) { Color oldBG = gc.getBackground(); - if(wa.length == 1) - gc.setBackground(gc.getDevice().getSystemColor(GUIWire.getSWTColorConstantForBit(wa.getValue()))); + if (wire.length == 1) + gc.setBackground(gc.getDevice().getSystemColor(GUIWire.getSWTColorConstantForBit(wire.getValue()))); gc.fillOval(-1, -1, 2, 2); gc.setBackground(oldBG); } + @Override public Rectangle getBounds() { return new Rectangle(0, 0, 0, 0); } + @Override - public int getConnectedWireArraysCount() + public int getConnectedWireEndsCount() { return wiresCrossing; } + @Override - public WireArray getConnectedWireArray(int connectionIndex) + public WireEnd getConnectedWireEnd(int connectionIndex) { - return wa; + return wireEnds.get(connectionIndex); } + @Override - public Point getWireArrayConnectionPoint(int connectionIndex) + public Point getWireEndConnectionPoint(int connectionIndex) { return new Point(0, 0); }