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.ReadEnd;
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<ReadEnd> wireEnds;
+ private final int wiresCrossing;
- public WireConnectionPoint(WireArray wa, int wiresCrossing)
+ public WireConnectionPoint(Wire wire, int wiresCrossing)
{
- this.wa = wa;
+ this.wire = wire;
+ List<ReadEnd> wireEndsModifiable = new ArrayList<>();
+ for (int i = 0; i < wiresCrossing; i++)
+ wireEndsModifiable.add(wire.createReadOnlyEnd());
+ wireEnds = Collections.unmodifiableList(wireEndsModifiable);
this.wiresCrossing = wiresCrossing;
}
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 ReadEnd 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);
}