From: Daniel Kirschten Date: Thu, 16 May 2019 09:06:26 +0000 (+0200) Subject: WireConnectionPoints now have the same color as the wire they belong to X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=ea862e91dc6823307e7a6590d28fd392f50c4a8b;p=Mograsim.git WireConnectionPoints now have the same color as the wire they belong to --- diff --git a/LogicUI/src/era/mi/gui/wires/GUIWire.java b/LogicUI/src/era/mi/gui/wires/GUIWire.java index 391535c2..5d9a174c 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 diff --git a/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java b/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java index e993c93e..c3bbab73 100644 --- a/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java +++ b/LogicUI/src/era/mi/gui/wires/WireConnectionPoint.java @@ -23,8 +23,8 @@ public class WireConnectionPoint implements BasicGUIComponent public void render(GeneralGC gc) { Color oldBG = gc.getBackground(); - Color fg = gc.getForeground(); - gc.setBackground(fg); + if(wa.length == 1) + gc.setBackground(gc.getDevice().getSystemColor(GUIWire.getSWTColorConstantForBit(wa.getValue()))); gc.fillOval(-2, -2, 4, 4); gc.setBackground(oldBG); }