A data bus is always drawn in the same color, closes #498

This commit is contained in:
hneemann 2020-07-30 08:21:27 +02:00
parent 8e65c893d9
commit 442ae18355
3 changed files with 10 additions and 13 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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;
}