Example #1
0
  /**
   * Make sure we have a theme set. Try to read a default value from the 'theme' property or use the
   * fallback.
   */
  public static void initialize() {

    if (ShadeConfig.theme.isSet()) return;

    MyTheme theme = null;
    if (System.getProperty("theme") == null) theme = FALLBACK;
    else {
      try {
        theme = valueOf(System.getProperty("theme").trim().toUpperCase(java.util.Locale.ENGLISH));
      } catch (IllegalArgumentException ignored) {
        /* No theme by the name given in the property 'theme'. */
      }

      if (theme == null) {
        Color customColor = null;
        try {
          customColor = Color.decode(System.getProperty("theme").trim());
        } catch (NumberFormatException e) {
          if (System.getProperty("theme").trim().length() > 0)
            Logger.get(MyTheme.class)
                .err(e, "err.invalidDefaultTheme", System.getProperty("theme").trim());
        }

        if (customColor != null) {
          MyTheme.CUSTOM.getLookAndFeel().setBase(customColor);
          theme = CUSTOM;
        } else theme = FALLBACK;
      }
    }

    ShadeConfig.theme.set(theme.getLookAndFeel());
  }
Example #2
0
  /**
   * Find the theme that is currently used to provide colors for the look and feel.
   *
   * @return Guess.
   */
  public static MyTheme activeTheme() {

    for (MyTheme theme : values())
      if (theme.getLookAndFeel().equals(ShadeConfig.theme.get())) return theme;

    return CUSTOM;
  }