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.ViewModelModifiable;
+import net.mograsim.preferences.ColorDefinition;
+import net.mograsim.preferences.ColorManager;
/**
* A wire connecting exactly two {@link Pin}s.
*/
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);
}
/**
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
private void callRedrawListeners() {redrawListeners.forEach(l -> l.run());}
// @formatter:on
+ @Override
+ public String toString()
+ {
+ return "GUIWire [" + pin1 + "---" + pin2 + ", value=" + (end == null ? "null" : end.getValues()) + "]";
+ }
}
\ No newline at end of file