From 9456b6305b2ece34b50aaa97e23276771647c150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Tue, 5 Jun 2012 01:58:22 +0200 Subject: [PATCH] made timer change color when time is up --- src/de/ctdo/crashtest/gui/MainGui.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/de/ctdo/crashtest/gui/MainGui.java b/src/de/ctdo/crashtest/gui/MainGui.java index 74ea890..389f000 100644 --- a/src/de/ctdo/crashtest/gui/MainGui.java +++ b/src/de/ctdo/crashtest/gui/MainGui.java @@ -50,6 +50,29 @@ public class MainGui extends JFrame implements IGuiControl { int secs = tseconds % 600 / 10 ; int tsecs = tseconds % 9; countDown.setText(" " + mins + ":" + secs + "." + tsecs); + + if(tseconds < 400) { + double percentile = ((tseconds-100.0)/300.0); + double red = 255.0 - percentile * 255.0; + double green = 255.0 - red; + double blue = percentile * 100.0; + +// System.out.println("red= " + red + " green=" + green + " blue="+blue); + + if(red > 255) red = 255; + if(red < 0) red = 0; + if(green > 255) green = 255; + if(green < 0) green = 0; + if(blue > 255) blue = 255; + if(blue < 0) blue = 0; + + Color fColor = new Color((int)red,(int)green, (int)blue); + countDown.setForeground(fColor); + } + else { + countDown.setForeground(new Color(0x00, 190, 100)); + } + } private void initGui() {