From 442ae18355a19e100c018496c0c98200b44f9ba5 Mon Sep 17 00:00:00 2001 From: hneemann Date: Thu, 30 Jul 2020 08:21:27 +0200 Subject: [PATCH] A data bus is always drawn in the same color, closes #498 --- src/main/java/de/neemann/digital/core/Value.java | 12 ++++++++---- .../draw/graphics/ColorStyleHighContrast.java | 1 - .../java/de/neemann/digital/draw/graphics/Style.java | 10 ++-------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/neemann/digital/core/Value.java b/src/main/java/de/neemann/digital/core/Value.java index 9dbedca1c..260c52f12 100644 --- a/src/main/java/de/neemann/digital/core/Value.java +++ b/src/main/java/de/neemann/digital/core/Value.java @@ -17,6 +17,7 @@ public class Value { private final long value; private final long highZ; private final int bits; + private final long mask; /** * Creates a new Value @@ -26,7 +27,8 @@ public class Value { */ public Value(long value, int bits) { this.bits = bits; - this.value = value & Bits.mask(bits); + this.mask = Bits.mask(bits); + this.value = value & mask; this.highZ = 0; } @@ -38,11 +40,12 @@ public class Value { */ public Value(InValue value, int bits) { this.bits = bits; + this.mask = Bits.mask(bits); if (value.isHighZ()) { this.value = 0; - this.highZ = Bits.mask(bits); + this.highZ = mask; } else { - this.value = value.getValue() & Bits.mask(bits); + this.value = value.getValue() & mask; this.highZ = 0; } } @@ -51,6 +54,7 @@ public class Value { value = observableValue.getValue(); highZ = observableValue.getHighZ(); bits = observableValue.getBits(); + this.mask = Bits.mask(bits); } /** @@ -96,7 +100,7 @@ public class Value { @Override public String toString() { if (highZ != 0) - if (highZ == Bits.mask(bits)) + if (highZ == mask) return "Z"; else { return zMaskString(value, highZ, bits); diff --git a/src/main/java/de/neemann/digital/draw/graphics/ColorStyleHighContrast.java b/src/main/java/de/neemann/digital/draw/graphics/ColorStyleHighContrast.java index 771a742b6..440a9b3cb 100644 --- a/src/main/java/de/neemann/digital/draw/graphics/ColorStyleHighContrast.java +++ b/src/main/java/de/neemann/digital/draw/graphics/ColorStyleHighContrast.java @@ -16,7 +16,6 @@ public class ColorStyleHighContrast implements GraphicSVG.ColorStyle { if (style == Style.WIRE) return Style.NORMAL.getColor(); else if (style == Style.WIRE_OUT) return Style.NORMAL.getColor(); else if (style == Style.WIRE_BITS) return Style.NORMAL.getColor(); - else if (style == Style.WIRE_BUS) return Style.NORMAL.getColor(); else if (style == Style.SHAPE_PIN) return Style.NORMAL.getColor(); else if (style == Style.SHAPE_SPLITTER) return Style.NORMAL.getColor(); else return style.getColor(); diff --git a/src/main/java/de/neemann/digital/draw/graphics/Style.java b/src/main/java/de/neemann/digital/draw/graphics/Style.java index efc7130ab..376b8f5e8 100644 --- a/src/main/java/de/neemann/digital/draw/graphics/Style.java +++ b/src/main/java/de/neemann/digital/draw/graphics/Style.java @@ -90,11 +90,6 @@ public final class Style { */ public static final Style WIRE_OUT = new Builder(WIRE).setColor(ColorKey.WIRE_OUT).build(); - /** - * used to draw the bus wires - */ - public static final Style WIRE_BUS = WIRE; - /** * Filled style used to fill the splitter or the dark LEDs */ @@ -242,10 +237,9 @@ public final class Style { * @return the style */ public static Style getWireStyle(Value value) { - if (value == null) return WIRE; - if (value.isHighZ()) return WIRE_HIGHZ; - if (value.getBits() > 1) return WIRE_BUS; + if (value == null || value.getBits() > 1) return WIRE; + if (value.isHighZ()) return WIRE_HIGHZ; if (value.getValue() == 1) return WIRE_HIGH; else return WIRE_LOW; }