use of org.vesalainen.navi.SolarWatch.DayPhase in project NMEAParser by tvesalainen.
the class ViewerService method bindBackgroundColors.
public StringBinding bindBackgroundColors() {
ObjectBinding<DayPhase> autoPhaseProperty = propertyStore.dayPhaseProperty();
Binding<DayPhase> forcedPhaseProperty = preferences.getBinding("dayPhase");
Binding<Boolean> solarAutomation = preferences.getBinding("solarAutomation");
Binding<DayPhase> dayPhaseProperty = new When((ObservableBooleanValue) solarAutomation).then(autoPhaseProperty).otherwise((ObservableObjectValue) forcedPhaseProperty);
StringBinding colorBinding = Bindings.createStringBinding(() -> {
switch(dayPhaseProperty.getValue()) {
case DAY:
return colorToString(dayBackgroundColorBinding.getValue());
case NIGHT:
return colorToString(nightBackgroundColorBinding.getValue());
case TWILIGHT:
return colorToString(twilightBackgroundColorBinding.getValue());
default:
throw new UnsupportedOperationException(autoPhaseProperty.getValue() + " not supported");
}
}, solarAutomation, autoPhaseProperty, forcedPhaseProperty, dayBackgroundColorBinding, nightBackgroundColorBinding, twilightBackgroundColorBinding);
return colorBinding;
}
Aggregations