X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fwires%2FWireConnectionPoint.java;h=f095f0d0bbafb356010ce621d8b35bbd7cb0be14;hb=d51bf9c3df364fa37f80730a02a67009edf729e4;hp=9c1aae1480ac72b1bd83618bf8adfc79fee47db4;hpb=d3a382377768fdb1434d5baebf73c9413e61e46f;p=Mograsim.git diff --git a/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java b/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java index 9c1aae14..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(); - Color fg = gc.getForeground(); - gc.setBackground(fg); - gc.fillOval(-2, -2, 4, 4); + 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); }