mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-13 06:49:36 -04:00
A data bus is always drawn in the same color, closes #498
This commit is contained in:
parent
8e65c893d9
commit
442ae18355
@ -17,6 +17,7 @@ public class Value {
|
|||||||
private final long value;
|
private final long value;
|
||||||
private final long highZ;
|
private final long highZ;
|
||||||
private final int bits;
|
private final int bits;
|
||||||
|
private final long mask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Value
|
* Creates a new Value
|
||||||
@ -26,7 +27,8 @@ public class Value {
|
|||||||
*/
|
*/
|
||||||
public Value(long value, int bits) {
|
public Value(long value, int bits) {
|
||||||
this.bits = bits;
|
this.bits = bits;
|
||||||
this.value = value & Bits.mask(bits);
|
this.mask = Bits.mask(bits);
|
||||||
|
this.value = value & mask;
|
||||||
this.highZ = 0;
|
this.highZ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,11 +40,12 @@ public class Value {
|
|||||||
*/
|
*/
|
||||||
public Value(InValue value, int bits) {
|
public Value(InValue value, int bits) {
|
||||||
this.bits = bits;
|
this.bits = bits;
|
||||||
|
this.mask = Bits.mask(bits);
|
||||||
if (value.isHighZ()) {
|
if (value.isHighZ()) {
|
||||||
this.value = 0;
|
this.value = 0;
|
||||||
this.highZ = Bits.mask(bits);
|
this.highZ = mask;
|
||||||
} else {
|
} else {
|
||||||
this.value = value.getValue() & Bits.mask(bits);
|
this.value = value.getValue() & mask;
|
||||||
this.highZ = 0;
|
this.highZ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,6 +54,7 @@ public class Value {
|
|||||||
value = observableValue.getValue();
|
value = observableValue.getValue();
|
||||||
highZ = observableValue.getHighZ();
|
highZ = observableValue.getHighZ();
|
||||||
bits = observableValue.getBits();
|
bits = observableValue.getBits();
|
||||||
|
this.mask = Bits.mask(bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,7 +100,7 @@ public class Value {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (highZ != 0)
|
if (highZ != 0)
|
||||||
if (highZ == Bits.mask(bits))
|
if (highZ == mask)
|
||||||
return "Z";
|
return "Z";
|
||||||
else {
|
else {
|
||||||
return zMaskString(value, highZ, bits);
|
return zMaskString(value, highZ, bits);
|
||||||
|
@ -16,7 +16,6 @@ public class ColorStyleHighContrast implements GraphicSVG.ColorStyle {
|
|||||||
if (style == Style.WIRE) return Style.NORMAL.getColor();
|
if (style == Style.WIRE) return Style.NORMAL.getColor();
|
||||||
else if (style == Style.WIRE_OUT) 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_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_PIN) return Style.NORMAL.getColor();
|
||||||
else if (style == Style.SHAPE_SPLITTER) return Style.NORMAL.getColor();
|
else if (style == Style.SHAPE_SPLITTER) return Style.NORMAL.getColor();
|
||||||
else return style.getColor();
|
else return style.getColor();
|
||||||
|
@ -90,11 +90,6 @@ public final class Style {
|
|||||||
*/
|
*/
|
||||||
public static final Style WIRE_OUT = new Builder(WIRE).setColor(ColorKey.WIRE_OUT).build();
|
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
|
* Filled style used to fill the splitter or the dark LEDs
|
||||||
*/
|
*/
|
||||||
@ -242,10 +237,9 @@ public final class Style {
|
|||||||
* @return the style
|
* @return the style
|
||||||
*/
|
*/
|
||||||
public static Style getWireStyle(Value value) {
|
public static Style getWireStyle(Value value) {
|
||||||
if (value == null) return WIRE;
|
if (value == null || value.getBits() > 1) return WIRE;
|
||||||
if (value.isHighZ()) return WIRE_HIGHZ;
|
|
||||||
if (value.getBits() > 1) return WIRE_BUS;
|
|
||||||
|
|
||||||
|
if (value.isHighZ()) return WIRE_HIGHZ;
|
||||||
if (value.getValue() == 1) return WIRE_HIGH;
|
if (value.getValue() == 1) return WIRE_HIGH;
|
||||||
else return WIRE_LOW;
|
else return WIRE_LOW;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user