From 0cfea6ef89dea8a797708ff685aa2ef9aefd85b9 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Thu, 16 May 2019 00:55:36 +0200 Subject: [PATCH] Made GUIWires more colorful --- LogicUI/src/era/mi/wires/gui/GUIWire.java | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/LogicUI/src/era/mi/wires/gui/GUIWire.java b/LogicUI/src/era/mi/wires/gui/GUIWire.java index 50c28dfb..65f82c7e 100644 --- a/LogicUI/src/era/mi/wires/gui/GUIWire.java +++ b/LogicUI/src/era/mi/wires/gui/GUIWire.java @@ -2,6 +2,9 @@ package era.mi.wires.gui; import java.util.Objects; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; + import era.mi.components.gui.BasicGUIComponent; import era.mi.logic.wires.WireArray; import net.haspamelodica.swt.helper.gcs.GeneralGC; @@ -35,6 +38,29 @@ public class GUIWire public void render(GeneralGC gc) { + 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.drawPolyline(path); + gc.setForeground(oldFG); } } \ No newline at end of file -- 2.17.1