X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fwires%2FGUIWire.java;h=cae2cfd7e08afea744cd897156ad5547a13a5531;hb=16322f272d5a7e16980ede3481f2a1c9d271e5df;hp=3b04fae8501c6df6a05c5236dd6b6348c3042e09;hpb=d3a382377768fdb1434d5baebf73c9413e61e46f;p=Mograsim.git diff --git a/LogicUI/src/era/mi/gui/wires/GUIWire.java b/LogicUI/src/era/mi/gui/wires/GUIWire.java index 3b04fae8..cae2cfd7 100644 --- a/LogicUI/src/era/mi/gui/wires/GUIWire.java +++ b/LogicUI/src/era/mi/gui/wires/GUIWire.java @@ -6,6 +6,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import era.mi.gui.components.BasicGUIComponent; +import era.mi.logic.Bit; import era.mi.logic.wires.WireArray; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; @@ -40,27 +41,26 @@ public class GUIWire { Color oldFG = gc.getForeground(); if(wa.length == 1) - { - int fgColorConstant; - switch(wa.getValue()) - { - case ONE: - fgColorConstant = SWT.COLOR_GREEN; - break; - case ZERO: - fgColorConstant = SWT.COLOR_BLUE; - break; - case U: - case X: - case Z: - fgColorConstant = SWT.COLOR_RED; - break; - default: - throw new IllegalArgumentException("Unknown enum constant: " + wa.getValue()); - } - gc.setForeground(gc.getDevice().getSystemColor(fgColorConstant)); - } + gc.setForeground(gc.getDevice().getSystemColor(getSWTColorConstantForBit(wa.getValue()))); gc.drawPolyline(path); gc.setForeground(oldFG); } + + public static int getSWTColorConstantForBit(Bit bit) + { + switch(bit) + { + case ONE: + return SWT.COLOR_GREEN; + case ZERO: + return SWT.COLOR_BLUE; + case Z: + return SWT.COLOR_BLACK; + case U: + case X: + return SWT.COLOR_RED; + default: + throw new IllegalArgumentException("Unknown enum constant: " + bit); + } + } } \ No newline at end of file