X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fwires%2FGUIWire.java;h=7b641ff3484c05bf8e92cb87b73b408775b2381b;hb=a2eef1d1616d03af5b464f347f6176ea9d2cc75e;hp=e92044444891da1aecbe1081c31b31ce30cef6e4;hpb=f14ea37d69488dd51518a36413af7176916b8bd7;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java index e9204444..7b641ff3 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java @@ -10,19 +10,20 @@ import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.mograsim.logic.core.LogicObserver; +import net.mograsim.logic.core.types.BitVector; import net.mograsim.logic.core.types.BitVectorFormatter; +import net.mograsim.logic.core.wires.Wire; import net.mograsim.logic.core.wires.Wire.ReadEnd; -import net.mograsim.logic.ui.ColorHelper; -import net.mograsim.logic.ui.model.ModelVisitor; import net.mograsim.logic.ui.model.ViewModelModifiable; -import net.mograsim.logic.ui.model.Visitable; +import net.mograsim.preferences.ColorDefinition; +import net.mograsim.preferences.ColorManager; /** * A wire connecting exactly two {@link Pin}s. * * @author Daniel Kirschten */ -public class GUIWire implements Visitable +public class GUIWire { /** * The model this wire is a part of. @@ -276,7 +277,10 @@ public class GUIWire implements Visitable */ public void render(GeneralGC gc) { - ColorHelper.executeWithDifferentForeground(gc, BitVectorFormatter.formatAsColor(end), () -> gc.drawPolyline(effectivePath)); + ColorDefinition wireColor = BitVectorFormatter.formatAsColor(end); + if (wireColor != null) + gc.setForeground(ColorManager.current().toColor(wireColor)); + gc.drawPolyline(effectivePath); } /** @@ -310,6 +314,38 @@ public class GUIWire implements Visitable end.registerObserver(logicObs); } + /** + * Returns whether this {@link GUIWire} has a logic model binding or not. + * + * @author Daniel Kirschten + */ + public boolean hasLogicModelBinding() + { + return end != null; + } + + /** + * If this {@link GUIWire} has a logic model binding, delegates to {@link Wire#forceValues(BitVector)} for the {@link Wire} + * corresponding to this {@link GUIWire}. + * + * @author Daniel Kirschten + */ + public void forceWireValues(BitVector values) + { + end.getWire().forceValues(values); + } + + /** + * If this {@link GUIWire} has a logic model binding, delegates to {@link ReadEnd#getValues()} for the {@link ReadEnd} corresponding to + * this {@link GUIWire}. + * + * @author Daniel Kirschten + */ + public BitVector getWireValues() + { + return end.getValues(); + } + // listeners // @formatter:off @@ -325,10 +361,4 @@ public class GUIWire implements Visitable { return "GUIWire [" + pin1 + "---" + pin2 + ", value=" + (end == null ? "null" : end.getValues()) + "]"; } - - @Override - public void accept(ModelVisitor mv) - { - mv.visit(this); - } } \ No newline at end of file