Improved graphics if an input is in high-z state and used as an output.

This commit is contained in:
hneemann 2018-03-11 13:40:06 +01:00
parent 4ee6e14a98
commit faffb650a9

View File

@ -40,6 +40,7 @@ public class InputShape implements Shape {
private IOState ioState;
private SingleValueDialog dialog;
private Value value;
private Value inValue;
private final boolean isHighZ;
/**
@ -111,8 +112,11 @@ public class InputShape implements Shape {
@Override
public void readObservableValues() {
if (ioState != null)
if (ioState != null) {
value = ioState.getOutput(0).getCopy();
if (ioState.inputCount() == 1)
inValue = ioState.getInput(0).getCopy();
}
}
@Override
@ -124,17 +128,22 @@ public class InputShape implements Shape {
graphic.drawText(textPos, textPos.add(1, 0), label, Orientation.RIGHTCENTER, Style.INOUT);
} else {
Style style = Style.NORMAL;
final Polygon box = new Polygon(true).add(-SIZE * 2 - 1, -SIZE).add(-1, -SIZE).add(-1, SIZE).add(-SIZE * 2 - 1, SIZE);
if (value != null) {
style = Style.getWireStyle(value);
if (value.getBits() > 1) {
Vector textPos = new Vector(-1 - SIZE, -4 - SIZE);
graphic.drawText(textPos, textPos.add(1, 0), format.formatToView(value), Orientation.CENTERBOTTOM, Style.NORMAL);
} else {
if (inValue != null && !inValue.isEqual(value))
graphic.drawPolygon(box, Style.getWireStyle(inValue));
}
}
graphic.drawPolygon(box, Style.NORMAL);
Vector center = new Vector(-1 - SIZE, 0);
graphic.drawCircle(center.sub(RAD), center.add(RAD), style);
graphic.drawPolygon(new Polygon(true).add(-SIZE * 2 - 1, -SIZE).add(-1, -SIZE).add(-1, SIZE).add(-SIZE * 2 - 1, SIZE), Style.NORMAL);
Vector textPos = new Vector(-SIZE * 3, 0);
graphic.drawText(textPos, textPos.add(1, 0), label, Orientation.RIGHTCENTER, Style.INOUT);