X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Ftypes%2FBitVectorFormatter.java;h=eb4e45ff2f5a516497fa1b0f8546487a45b2391f;hb=218ed3e44595ad3534c33e05b43a55cc1a67e851;hp=a79853197d1ece493c1adca89809b23c4ff49ea3;hpb=ecc651406020231ff0ebc8d1bfc6f916693f69c6;p=Mograsim.git diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVectorFormatter.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVectorFormatter.java index a7985319..eb4e45ff 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVectorFormatter.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVectorFormatter.java @@ -1,53 +1,51 @@ -package net.mograsim.logic.core.types; - -import net.mograsim.logic.core.types.ColorDefinition.BuiltInColor; -import net.mograsim.logic.core.wires.Wire.ReadEnd; - -public class BitVectorFormatter -{ - public static String formatValueAsString(ReadEnd end) - { - return formatAsString(end == null ? null : end.getValues()); - } - - public static String formatAsString(BitVector bitVector) - { - if (bitVector == null) - return "null"; - else - return bitVector.toString(); - } - - public static ColorDefinition formatAsColor(ReadEnd end) - { - return formatAsColor(end == null ? null : end.getValues()); - } - - public static ColorDefinition formatAsColor(BitVector bitVector) - { - // TODO maybe find a color assignment for multiple-bit bit vectors? - if (bitVector == null || bitVector.length() != 1) - return new ColorDefinition(BuiltInColor.COLOR_BLACK); - else - switch (bitVector.getBit(0)) - { - case ONE: - return new ColorDefinition(BuiltInColor.COLOR_GREEN); - case U: - return new ColorDefinition(BuiltInColor.COLOR_CYAN); - case X: - return new ColorDefinition(BuiltInColor.COLOR_RED); - case Z: - return new ColorDefinition(BuiltInColor.COLOR_YELLOW); - case ZERO: - return new ColorDefinition(BuiltInColor.COLOR_GRAY); - default: - throw new IllegalArgumentException("Unknown enum constant: " + bitVector.getBit(0)); - } - } - - private BitVectorFormatter() - { - throw new UnsupportedOperationException("No BitVectorFormatter instances"); - } +package net.mograsim.logic.core.types; + +import net.mograsim.logic.core.types.ColorDefinition.BuiltInColor; +import net.mograsim.logic.core.wires.Wire.ReadEnd; + +public class BitVectorFormatter +{ + public static String formatValueAsString(ReadEnd end) + { + return formatAsString(end == null ? null : end.getValues()); + } + + public static String formatAsString(BitVector bitVector) + { + if (bitVector == null) + return "null"; + return bitVector.toString(); + } + + public static ColorDefinition formatAsColor(ReadEnd end) + { + return formatAsColor(end == null ? null : end.getValues()); + } + + public static ColorDefinition formatAsColor(BitVector bitVector) + { + // TODO maybe find a color assignment for multiple-bit bit vectors? + if (bitVector == null || bitVector.length() != 1) + return new ColorDefinition(BuiltInColor.COLOR_BLACK); + switch (bitVector.getBit(0)) + { + case ONE: + return new ColorDefinition(BuiltInColor.COLOR_GREEN); + case U: + return new ColorDefinition(BuiltInColor.COLOR_CYAN); + case X: + return new ColorDefinition(BuiltInColor.COLOR_RED); + case Z: + return new ColorDefinition(BuiltInColor.COLOR_YELLOW); + case ZERO: + return new ColorDefinition(BuiltInColor.COLOR_GRAY); + default: + throw new IllegalArgumentException("Unknown enum constant: " + bitVector.getBit(0)); + } + } + + private BitVectorFormatter() + { + throw new UnsupportedOperationException("No BitVectorFormatter instances"); + } } \ No newline at end of file