Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.

Commit

Permalink
Color changes and updates will now managed in own class TaiChiColors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoghuman committed Sep 2, 2018
1 parent 33475c3 commit fc944d8
Show file tree
Hide file tree
Showing 13 changed files with 336 additions and 218 deletions.
2 changes: 2 additions & 0 deletions concept/Features_v0.5.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ OptionsDialog
- Tab 'Language' shows options to choose different languages.
- Tab 'Extras' shows additional options like 'always on top'.

Color changes and updates will now managed in own class TaiChiColors.

--------------------------------------------------------------------------------


Expand Down
1 change: 1 addition & 0 deletions release/Release_v0.5.0_2018-09-dd_HH-mm.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ aso..
#### Summary
* With v0.5.0 now 50 Yin-Yang terms are available.
* ApplicationMenu color is now the opposite from the ApplicationInfo color.
* Color changes and updates will now managed in own class TaiChiColors.



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.github.naoghuman.yin.yang.configuration.PreferencesConfiguration;
import com.github.naoghuman.yin.yang.i18n.I18nProperty;
import com.github.naoghuman.yin.yang.i18n.I18nProvider;
import com.github.naoghuman.yin.yang.taichi.TaiChiColors;
import java.util.Optional;
import javafx.animation.Animation;
import javafx.animation.PauseTransition;
Expand Down Expand Up @@ -111,9 +112,11 @@ public void start(Stage primaryStage) throws Exception {
+ I18nProvider.getDefault().getI18nApplication().getProperty(I18N_KEY__APPLICATION__VERSION));
stage.setScene(scene);

this.onActionSetApplicationPosition();
this.onActionUpdateApplicationPosition();

stage.show();

TaiChiColors.getDefault().initialize();
}

private void onActionChangeAlwaysOnTop(final boolean alwaysOnTop) {
Expand Down Expand Up @@ -168,8 +171,8 @@ private void onActionSavePositionToPreferences() {
ptSavePositionToPreferences.playFromStart();
}

private void onActionSetApplicationPosition() {
LoggerFacade.getDefault().debug(this.getClass(), "StartApplication.onActionSetApplicationPosition()"); // NOI18N
private void onActionUpdateApplicationPosition() {
LoggerFacade.getDefault().debug(this.getClass(), "StartApplication.onActionUpdateApplicationPosition()"); // NOI18N

// X
final double x = PreferencesFacade.getDefault().getDouble(PREF__APPLICATION__POSITION_X, PREF__APPLICATION__POSITION_X_DEFAULT_VALUE);
Expand Down Expand Up @@ -210,6 +213,8 @@ public void register() {
this.registerOnActionMinimizeApplication();
this.registerOnMouseDragged();
this.registerOnMousePressed();

TaiChiColors.getDefault().register();
}

private void registerOnActionChangeAlwaysOnTop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.github.naoghuman.yin.yang.configuration.TaiChiConfiguration;
import com.github.naoghuman.yin.yang.i18n.I18nProvider;
import com.github.naoghuman.yin.yang.options.OptionsView;
import com.github.naoghuman.yin.yang.taichi.TaiChiColors;
import com.github.naoghuman.yin.yang.taichi.TaiChiTerms;
import com.github.naoghuman.yin.yang.taichi.TaiChiSymbol;
import java.net.URL;
Expand Down Expand Up @@ -95,6 +96,11 @@ public void initialize(URL location, ResourceBundle resources) {
TaiChiSymbol.getDefault().configure(spApplication);
TaiChiSymbol.getDefault().onActionStartTaiChiRotation();

TaiChiColors.getDefault().register(lYangTerm, TaiChiColors.Type.STYLE, ON_ACTION__CHOOSE__SINGLE_YANG_COLOR);
TaiChiColors.getDefault().register(lYangTerm, TaiChiColors.Type.TEXTFILL, ON_ACTION__CHOOSE__SINGLE_YIN_COLOR);
TaiChiColors.getDefault().register(lYinTerm, TaiChiColors.Type.STYLE, ON_ACTION__CHOOSE__SINGLE_YIN_COLOR);
TaiChiColors.getDefault().register(lYinTerm, TaiChiColors.Type.TEXTFILL, ON_ACTION__CHOOSE__SINGLE_YANG_COLOR);

TaiChiTerms.getDefault().configure(hbTaiChiTerms, lYinTerm, lYangTerm);
TaiChiTerms.getDefault().onActionShowTaiChiTerms();

Expand All @@ -116,62 +122,41 @@ private void initializeInfos() {
vbInfos.setPrefWidth(diameterTheOne / 2.0d);

// Infos have oposite color from menu
final LocalDate now = LocalDate.now();
final boolean oddDay = now.getDayOfMonth() % 2 != 0;
final String yinSelectedColor = PreferencesFacade.getDefault().get(PREF__TAICHI_SYMBOL__YIN_COLOR, PREF__TAICHI_SYMBOL__YIN_COLOR_DEFAULT_VALUE);
final String yangSelectedColor = PreferencesFacade.getDefault().get(PREF__TAICHI_SYMBOL__YANG_COLOR, PREF__TAICHI_SYMBOL__YANG_COLOR_DEFAULT_VALUE);
// final LocalDate now = LocalDate.now();
// final boolean oddDay = now.getDayOfMonth() % 2 != 0;
// final String yinSelectedColor = PreferencesFacade.getDefault().get(PREF__TAICHI_SYMBOL__YIN_COLOR, PREF__TAICHI_SYMBOL__YIN_COLOR_DEFAULT_VALUE);
// final String yangSelectedColor = PreferencesFacade.getDefault().get(PREF__TAICHI_SYMBOL__YANG_COLOR, PREF__TAICHI_SYMBOL__YANG_COLOR_DEFAULT_VALUE);

vbInfos.setStyle(String.format(
STYLE__BACKGROUND_COLOR_RADIUS,
ColorConverter.convertToBrighter(
(!oddDay ? yangSelectedColor : yinSelectedColor),
0.8d)));
// vbInfos.setStyle(String.format(// TODO
// STYLE__BACKGROUND_COLOR_RADIUS,
// ColorConverter.convertToBrighter(
// (!oddDay ? yangSelectedColor : yinSelectedColor),
// 0.8d)));
TaiChiColors.getDefault().register(vbInfos, ON_ACTION__CHOOSE__SINGLE_YIN_COLOR);

lInfoTitle.setText(String.format(
I18nProvider.getDefault().getI18nOptions().getProperty(I18N_KEY__OPTION_DIALOG__TAB_ABOUT__TITLE),
I18nProvider.getDefault().getI18nApplication().getProperty(I18N_KEY__APPLICATION__TITLE)));
lInfoTitle.setTextFill(Color.web(String.format(PATTERN__RGB_COLOR, (oddDay ? yangSelectedColor : yinSelectedColor))));

// lInfoTitle.setTextFill(Color.web(String.format(PATTERN__RGB_COLOR, (oddDay ? yangSelectedColor : yinSelectedColor))));
TaiChiColors.getDefault().register(lInfoTitle, TaiChiColors.Type.TEXTFILL, ON_ACTION__CHOOSE__SINGLE_YANG_COLOR);
// TODO
lInfoVersion.setText(String.format(
I18nProvider.getDefault().getI18nOptions().getProperty(I18N_KEY__OPTION_DIALOG__TAB_ABOUT__VERSION),
I18nProvider.getDefault().getI18nApplication().getProperty(I18N_KEY__APPLICATION__VERSION)));
lInfoVersion.setTextFill(Color.web(String.format(PATTERN__RGB_COLOR, (oddDay ? yangSelectedColor : yinSelectedColor))));

// lInfoVersion.setTextFill(Color.web(String.format(PATTERN__RGB_COLOR, (oddDay ? yangSelectedColor : yinSelectedColor))));
TaiChiColors.getDefault().register(lInfoVersion, TaiChiColors.Type.TEXTFILL, ON_ACTION__CHOOSE__SINGLE_YANG_COLOR);
// TODO
lInfoByName.setText(I18nProvider.getDefault().getI18nOptions().getProperty(I18N_KEY__OPTION_DIALOG__TAB_ABOUT__BYNAME));
lInfoByName.setTextFill(Color.web(String.format(PATTERN__RGB_COLOR, (oddDay ? yangSelectedColor : yinSelectedColor))));
// lInfoByName.setTextFill(Color.web(String.format(PATTERN__RGB_COLOR, (oddDay ? yangSelectedColor : yinSelectedColor))));
TaiChiColors.getDefault().register(lInfoByName, TaiChiColors.Type.TEXTFILL, ON_ACTION__CHOOSE__SINGLE_YANG_COLOR);
}

private void initializeMenu() {
LoggerFacade.getDefault().info(this.getClass(), "ApplicationPresenter.initializeMenu()"); // NOI18N

// Menu background
hbMenuButtons.setPrefWidth(diameterTheOne / 2.0d);

// Buttons
final LocalDate now = LocalDate.now();
final boolean oddDay = now.getDayOfMonth() % 2 != 0;

String selectedColor = oddDay
? PREF__TAICHI_SYMBOL__YANG_COLOR_DEFAULT_VALUE
: PREF__TAICHI_SYMBOL__YIN_COLOR_DEFAULT_VALUE;
if (oddDay) {
// odd == yang == top
hbMenuButtons.getChildren().clear();
hbMenuButtons.getChildren().addAll(bCloseApplication, bMinimizeApplication, bShowOptionDialog);

selectedColor = PreferencesFacade.getDefault().get(PREF__TAICHI_SYMBOL__YANG_COLOR, PREF__TAICHI_SYMBOL__YANG_COLOR_DEFAULT_VALUE);
}
else {
// even == yin == bottom
hbMenuButtons.getChildren().clear();
hbMenuButtons.getChildren().addAll(bShowOptionDialog, bMinimizeApplication, bCloseApplication);

selectedColor = PreferencesFacade.getDefault().get(PREF__TAICHI_SYMBOL__YIN_COLOR, PREF__TAICHI_SYMBOL__YIN_COLOR_DEFAULT_VALUE);
}

hbMenuButtons.setStyle(String.format(
STYLE__BACKGROUND_COLOR_RADIUS,
ColorConverter.convertToBrighter(selectedColor, 0.8d)));
TaiChiColors.getDefault().register(hbMenuButtons, ON_ACTION__CHOOSE__SINGLE_YANG_COLOR);
}

public void configure(final Window owner) {
Expand Down Expand Up @@ -263,13 +248,7 @@ private void onActionUpdateColorInApplicationOptions() {
final boolean oddDay = now.getDayOfMonth() % 2 != 0;
final String yinSelectedColor = PreferencesFacade.getDefault().get(PREF__TAICHI_SYMBOL__YIN_COLOR, PREF__TAICHI_SYMBOL__YIN_COLOR_DEFAULT_VALUE);
final String yangSelectedColor = PreferencesFacade.getDefault().get(PREF__TAICHI_SYMBOL__YANG_COLOR, PREF__TAICHI_SYMBOL__YANG_COLOR_DEFAULT_VALUE);

hbMenuButtons.setStyle(String.format(
STYLE__BACKGROUND_COLOR_RADIUS,
ColorConverter.convertToBrighter(
oddDay ? yangSelectedColor : yinSelectedColor,
0.8d)));


// Option info
vbInfos.setStyle(String.format(
STYLE__BACKGROUND_COLOR_RADIUS,
Expand All @@ -284,14 +263,14 @@ private void onActionUpdateColorInApplicationOptions() {

@Override
public void register() {
LoggerFacade.getDefault().debug(this.getClass(), "ApplicationPresenter.register()"); // NOI18N
LoggerFacade.getDefault().info(this.getClass(), "ApplicationPresenter.register()"); // NOI18N

this.registerOnActionShowOptionMenu();
this.registerOnActionUpdateColorInApplicationOptions();
}

private void registerOnActionShowOptionMenu() {
LoggerFacade.getDefault().debug(this.getClass(), "ApplicationPresenter.registerOnActionShowOptionMenu()"); // NOI18N
LoggerFacade.getDefault().info(this.getClass(), "ApplicationPresenter.registerOnActionShowOptionMenu()"); // NOI18N

ActionHandlerFacade.getDefault().register(
ON_ACTION__SHOW_OPTIONS,
Expand All @@ -309,7 +288,7 @@ private void registerOnActionShowOptionMenu() {
}

private void registerOnActionUpdateColorInApplicationOptions() {
LoggerFacade.getDefault().debug(this.getClass(), "ApplicationPresenter.registerOnActionUpdateColorInApplicationOptions()"); // NOI18N
LoggerFacade.getDefault().info(this.getClass(), "ApplicationPresenter.registerOnActionUpdateColorInApplicationOptions()"); // NOI18N

ActionHandlerFacade.getDefault().register(
ON_ACTION__UPDATE__COLOR_IN_APPLICATION_OPTIONS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.github.naoghuman.lib.action.core.TransferDataBuilder;
import com.github.naoghuman.lib.logger.core.LoggerFacade;
import com.github.naoghuman.yin.yang.configuration.EventConfiguration;
import static com.github.naoghuman.yin.yang.configuration.EventConfiguration.ON_ACTION__UPDATE__COLOR_IN_TERMS;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
Expand Down Expand Up @@ -177,12 +176,7 @@ public final class ColorComboBox implements EventConfiguration {
);

public ColorComboBox() {
this.initialize();
}

private void initialize() {
LoggerFacade.getDefault().info(this.getClass(), "ColorComboBox.initialize()"); // NOI18N


}

public void configure(final ComboBox<String> comboBox, final Type type, final String selectedColor) {
Expand Down Expand Up @@ -255,8 +249,9 @@ public void changed(ObservableValue<? extends String> observable, String oldValu
// Update yin, yang color
String actionId = ON_ACTION__UNKNOWN_ACTION;
switch(type) {
case YANG_SYMBOL: { actionId = ON_ACTION__UPDATE__COLOR_IN_YANG_SYMBOL; break; }
case YIN_SYMBOL: { actionId = ON_ACTION__UPDATE__COLOR_IN_YIN_SYMBOL; break;}
// TODO better is not enum.type, instead use actionId from configure(...) here
case YANG_SYMBOL: { actionId = ON_ACTION__CHOOSE__SINGLE_YANG_COLOR; break; }
case YIN_SYMBOL: { actionId = ON_ACTION__CHOOSE__SINGLE_YIN_COLOR; break; }
}

ActionHandlerFacade.getDefault()
Expand All @@ -266,8 +261,8 @@ public void changed(ObservableValue<? extends String> observable, String oldValu
.build());

// Update colors
ActionHandlerFacade.getDefault().handle(ON_ACTION__UPDATE__COLOR_IN_APPLICATION_OPTIONS);
ActionHandlerFacade.getDefault().handle(ON_ACTION__UPDATE__COLOR_IN_TERMS);
// ActionHandlerFacade.getDefault().handle(ON_ACTION__UPDATE__COLOR_IN_APPLICATION_OPTIONS);
// ActionHandlerFacade.getDefault().handle(ON_ACTION__UPDATE__COLOR_IN_TERMS);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* @since 0.1.0
*/
public interface EventConfiguration {

public static final String ON_ACTION__CHOOSE__SINGLE_YANG_COLOR = "ON_ACTION__CHOOSE__SINGLE_YANG_COLOR"; // NOI18N
public static final String ON_ACTION__CHOOSE__SINGLE_YIN_COLOR = "ON_ACTION__CHOOSE__SINGLE_YIN_COLOR"; // NOI18N

public static final String ON_ACTION__CHANGE__ALWAYS_ON_TOP = "ON_ACTION__CHANGE_COLOR__YANG_SYMBOL"; // NOI18N
public static final String ON_ACTION__CLOSE_APPLICATION = "ON_ACTION__CLOSE_APPLICATION"; // NOI18N
Expand All @@ -30,8 +33,6 @@ public interface EventConfiguration {
public static final String ON_ACTION__SHOW_OPTIONS = "ON_ACTION__SHOW_OPTIONS"; // NOI18N
public static final String ON_ACTION__UNKNOWN_ACTION = "ON_ACTION__UNKNOWN_ACTION"; // NOI18N
public static final String ON_ACTION__UPDATE__COLOR_IN_APPLICATION_OPTIONS = "ON_ACTION__UPDATE__COLOR_IN_APPLICATION_OPTIONS"; // NOI18N
public static final String ON_ACTION__UPDATE__COLOR_IN_YANG_SYMBOL = "ON_ACTION__UPDATE__COLOR_IN_YANG_SYMBOL"; // NOI18N
public static final String ON_ACTION__UPDATE__COLOR_IN_YIN_SYMBOL = "ON_ACTION__UPDATE__COLOR_IN_YIN_SYMBOL"; // NOI18N
public static final String ON_ACTION__UPDATE__COLOR_IN_TERMS = "ON_ACTION__UPDATE__COLOR_IN_TERMS"; // NOI18N
public static final String ON_ACTION__UPDATE__LANGUAGE_IN_OPTIONDIALOG = "ON_ACTION__UPDATE__LANGUAGE_IN_OPTIONDIALOG"; // NOI18N
public static final String ON_ACTION__UPDATE__LANGUAGE_IN_TAICHI_TERMS = "ON_ACTION__UPDATE__LANGUAGE_IN_TAICHI_TERMS"; // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public static final I18nApplication getDefault() {
}

private I18nApplication() {
this.initialize();
}

private void initialize() {
LoggerFacade.getDefault().info(this.getClass(), "I18nApplication.initialize()"); // NOI18N

}

Expand All @@ -50,7 +45,7 @@ public String getProperty(final String key) {

@Override
public void register() {
LoggerFacade.getDefault().debug(this.getClass(), "I18nApplication.register()"); // NOI18N
LoggerFacade.getDefault().info(this.getClass(), "I18nApplication.register()"); // NOI18N

PropertiesFacade.getDefault().register(I18N__RESOURCE_BUNDLE__APPLICATION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public static final I18nOptions getDefault() {
private Locale language = Locale.ENGLISH;

private I18nOptions() {
this.initialize();
}

private void initialize() {
LoggerFacade.getDefault().info(this.getClass(), "I18nOptions.initialize()"); // NOI18N

}

Expand All @@ -57,7 +52,7 @@ public String getProperty(final String key) {

@Override
public void register() {
LoggerFacade.getDefault().debug(this.getClass(), "I18nOptions.register()"); // NOI18N
LoggerFacade.getDefault().info(this.getClass(), "I18nOptions.register()"); // NOI18N

PropertiesFacade.getDefault().register(I18N__RESOURCE_BUNDLE__OPTIONS_DE);
PropertiesFacade.getDefault().register(I18N__RESOURCE_BUNDLE__OPTIONS_EN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ public static final I18nProvider getDefault() {
}

private I18nProvider() {
this.initialize();
}

private void initialize() {
LoggerFacade.getDefault().info(this.getClass(), "I18nProvider.initialize()"); // NOI18N

}

public I18nApplication getI18nApplication() {
Expand Down Expand Up @@ -81,7 +77,7 @@ private void onActionLoadLanguageFromProperties() {

@Override
public void register() {
LoggerFacade.getDefault().debug(this.getClass(), "I18nProvider.register()"); // NOI18N
LoggerFacade.getDefault().info(this.getClass(), "I18nProvider.register()"); // NOI18N

I18nApplication.getDefault().register();
I18nOptions.getDefault().register();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public static final I18nTaiChi getDefault() {
private Locale language = Locale.ENGLISH;

private I18nTaiChi() {
this.initialize();
}

private void initialize() {
LoggerFacade.getDefault().info(this.getClass(), "I18nTaiChi.initialize()"); // NOI18N

}

Expand All @@ -57,7 +52,7 @@ public String getProperty(String key) {

@Override
public void register() {
LoggerFacade.getDefault().debug(this.getClass(), "I18nTaiChi.register()"); // NOI18N
LoggerFacade.getDefault().info(this.getClass(), "I18nTaiChi.register()"); // NOI18N

PropertiesFacade.getDefault().register(I18N__RESOURCE_BUNDLE__TAICHI_DE);
PropertiesFacade.getDefault().register(I18N__RESOURCE_BUNDLE__TAICHI_EN);
Expand Down

0 comments on commit fc944d8

Please sign in to comment.