Rolled back toString change in BitVector, moved it into ModelBitDisplay
authorFabian Stemmler <stemmler@in.tum.de>
Sat, 12 Oct 2019 12:13:53 +0000 (14:13 +0200)
committerFabian Stemmler <stemmler@in.tum.de>
Sat, 12 Oct 2019 12:14:17 +0000 (14:14 +0200)
plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelBitDisplay.java

index ec6d12d..4b10292 100644 (file)
@@ -414,8 +414,6 @@ public final class BitVector implements StrictLogicType<BitVector>, Iterable<Bit
        @Override
        public String toString()
        {
-               if (isHighImpedance())
-                       return "-";
                StringBuilder sb = new StringBuilder(bits.length);
                for (Bit bit : bits)
                        sb.append(bit);
index 1a01e14..5be3e22 100644 (file)
@@ -8,6 +8,7 @@ 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.components.CoreBitDisplay;
+import net.mograsim.logic.core.types.BitVector;
 import net.mograsim.logic.core.types.BitVectorFormatter;
 import net.mograsim.logic.model.model.LogicModelModifiable;
 import net.mograsim.logic.model.model.components.ModelComponent;
@@ -55,8 +56,15 @@ public class ModelBitDisplay extends ModelComponent
                if (foreground != null)
                        gc.setForeground(foreground);
                gc.drawRectangle(getBounds());
-               String label = bitDisplay == null ? BitVectorFormatter.formatAsString(null)
-                               : BitVectorFormatter.formatAsString(bitDisplay.getDisplayedValue());
+               String label;
+               if (bitDisplay == null)
+                       label = BitVectorFormatter.formatAsString(null);
+               else
+               {
+                       BitVector toDisplay = bitDisplay.getDisplayedValue();
+                       label = toDisplay != null && toDisplay.isHighImpedance() ? "-"
+                                       : BitVectorFormatter.formatAsString(bitDisplay.getDisplayedValue());
+               }
                Font oldFont = gc.getFont();
                Font labelFont = new Font(oldFont.getName(), fontHeight, oldFont.getStyle());
                gc.setFont(labelFont);