Added configurable colors

This commit is contained in:
genuineparts 2024-11-12 18:02:16 +01:00
parent c34ecfebac
commit 0e11dcb3cb
2 changed files with 23 additions and 15 deletions

View file

@ -1,6 +1,14 @@
apiserver { apiserver {
port = 8111 //Port to listen to port = 8111 //Port to listen to
refreshTime = 60 //Refresh Time in Seconds refreshTime = 60 //Refresh Time in Seconds
bgcolor = "black"
bgcolordelay = "red"
labelcolor = "green"
textcolor = "grey"
textcolordelay = "black"
bgcolormain = "black"
textcolormain = "red"
textcolorupdate = "grey"
monitors { monitors {
monitor1 { monitor1 {

View file

@ -95,28 +95,28 @@ public class Main {
text1.put("y",120); text1.put("y",120);
text1.put("text","Abfahrten"); text1.put("text","Abfahrten");
text1.put("font",2); text1.put("font",2);
text1.put("color","red"); text1.put("color",conf.getInt("textcolormain"));
text1.put("background","silver"); text1.put("background",conf.getInt("bgcolormain"));
JSONObject text2 = new JSONObject(); JSONObject text2 = new JSONObject();
text2.put("type","text"); text2.put("type","text");
text2.put("x",120); text2.put("x",120);
text2.put("y",170); text2.put("y",170);
text2.put("text", dateFormat.format(updatetime)); text2.put("text", dateFormat.format(updatetime));
text2.put("color","black"); text2.put("color",conf.getInt("textcolorupdate"));
text2.put("font",2); text2.put("font",2);
text2.put("background","silver"); text2.put("background",conf.getInt("bgcolormain"));
layout.put(text2); layout.put(text2);
layout.put(text1); layout.put(text1);
monitor1.put("data",layout); monitor1.put("data",layout);
monitor1.put("labelColor","red"); monitor1.put("labelColor",conf.getInt("textcolormain"));
monitor1.put("color","red"); monitor1.put("color",conf.getInt("textcolormain"));
monitor1.put("background","silver"); monitor1.put("background",conf.getInt("bgcolormain"));
display.put(monitor1); display.put(monitor1);
JSONObject monitor2 = new JSONObject(); JSONObject monitor2 = new JSONObject();
monitor2.put("label",conf.getString("monitors.monitor1.Title")); monitor2.put("label",conf.getString("monitors.monitor1.Title"));
monitor2.put("labelColor","green"); monitor2.put("labelColor",conf.getInt("labelcolor"));
monitor2.put("fullDraw",true); monitor2.put("fullDraw",true);
int zug1 = data.get(conf.getString("monitors.monitor1.DepartureTime")); int zug1 = data.get(conf.getString("monitors.monitor1.DepartureTime"));
makeLabel(monitor2, zug1); makeLabel(monitor2, zug1);
@ -124,7 +124,7 @@ public class Main {
JSONObject monitor3 = new JSONObject(); JSONObject monitor3 = new JSONObject();
monitor3.put("label",conf.getString("monitors.monitor2.Title")); monitor3.put("label",conf.getString("monitors.monitor2.Title"));
monitor3.put("labelColor","green"); monitor3.put("labelColor",conf.getInt("labelcolor"));
monitor3.put("fullDraw",true); monitor3.put("fullDraw",true);
int zug2 = data.get(conf.getString("monitors.monitor2.DepartureTime")); int zug2 = data.get(conf.getString("monitors.monitor2.DepartureTime"));
makeLabel(monitor3, zug2); makeLabel(monitor3, zug2);
@ -132,7 +132,7 @@ public class Main {
JSONObject monitor4 = new JSONObject(); JSONObject monitor4 = new JSONObject();
monitor4.put("label",conf.getString("monitors.monitor3.Title")); monitor4.put("label",conf.getString("monitors.monitor3.Title"));
monitor4.put("labelColor","green"); monitor4.put("labelColor",conf.getInt("labelcolor"));
monitor4.put("fullDraw",true); monitor4.put("fullDraw",true);
int zug3 = data.get(conf.getString("monitors.monitor3.DepartureTime")); int zug3 = data.get(conf.getString("monitors.monitor3.DepartureTime"));
makeLabel(monitor4, zug3); makeLabel(monitor4, zug3);
@ -140,7 +140,7 @@ public class Main {
JSONObject monitor5 = new JSONObject(); JSONObject monitor5 = new JSONObject();
monitor5.put("label",conf.getString("monitors.monitor4.Title")); monitor5.put("label",conf.getString("monitors.monitor4.Title"));
monitor5.put("labelColor","green"); monitor5.put("labelColor",conf.getInt("labelcolor"));
monitor5.put("fullDraw",true); monitor5.put("fullDraw",true);
int zug4 = data.get(conf.getString("monitors.monitor4.DepartureTime")); int zug4 = data.get(conf.getString("monitors.monitor4.DepartureTime"));
makeLabel(monitor5, zug4); makeLabel(monitor5, zug4);
@ -151,7 +151,7 @@ public class Main {
private static void makeLabel(JSONObject Monitor, int zeit){ private static void makeLabel(JSONObject Monitor, int zeit){
if(zeit != 0){ if(zeit != 0){
Monitor.put("color","red"); Monitor.put("color",conf.getInt("textcolordelay"));
if(zeit > 0 && zeit < 9999){ if(zeit > 0 && zeit < 9999){
Monitor.put("data",zeit); Monitor.put("data",zeit);
}else if(zeit == 9999){ }else if(zeit == 9999){
@ -159,11 +159,11 @@ public class Main {
}else{ }else{
Monitor.put("data","Fehler!"); Monitor.put("data","Fehler!");
} }
Monitor.put("background","yellow"); Monitor.put("background",conf.getInt("bgcolordelay"));
} else { } else {
Monitor.put("color","green"); Monitor.put("color",conf.getInt("textcolor"));
Monitor.put("data","On time"); Monitor.put("data","On time");
Monitor.put("background","silver"); Monitor.put("background",conf.getInt("bgcolor"));
} }
} }
} }