Cleanup and Reformatting

This commit is contained in:
Kai S. K. Engelbart 2020-06-06 15:03:43 +02:00
parent 16ae619f7d
commit 5fd6fc77e1
2 changed files with 26 additions and 74 deletions

View File

@ -1,17 +0,0 @@
package envoy.client;
/**
* Project: <strong>envoy-client</strong><br>
* File: <strong>DeveloperComments.java</strong><br>
* Created: <strong>19 Apr 2020</strong><br>
*
* @author Leon Hofmeister
* @since Envoy Client v0.1-beta
*/
public class DeveloperComments {
// "Schau, es hat sich behindert" - Kai, 2020
// LEON: JFC <===> JAVA FRIED CHICKEN <=/=> Java Foundation Classes
}

View File

@ -27,8 +27,8 @@ import envoy.util.SerializationUtils;
public class Settings {
// Actual settings accessible by the rest of the application
private Map<String, SettingsItem<?>> items;
private Map<String, Theme> themes;
private Map<String, SettingsItem<?>> items;
private Map<String, Theme> themes;
/**
* Settings are stored in this file.
@ -69,10 +69,12 @@ public class Settings {
}
// Load standard themes not defined in the themes file
themes.put("dark", new Theme("dark", Color.black, Color.darkGray, Color.white, new Color(165, 60, 232),
Color.white, Color.orange, Color.blue, Color.white, Color.white));
themes.put("light", new Theme("light", new Color(235, 235, 235), Color.white, Color.white, Color.darkGray,
Color.black, Color.orange, Color.darkGray, Color.black, Color.black));
themes.put("dark",
new Theme("dark", Color.black, Color.darkGray, Color.white, new Color(165, 60, 232), Color.white, Color.orange, Color.blue,
Color.white, Color.white));
themes.put("light",
new Theme("light", new Color(235, 235, 235), Color.white, Color.white, Color.darkGray, Color.black, Color.orange, Color.darkGray,
Color.black, Color.black));
}
/**
@ -81,9 +83,7 @@ public class Settings {
* @return the instance of Settings
* @since Envoy Client v0.2-alpha
*/
public static Settings getInstance() {
return settings;
}
public static Settings getInstance() { return settings; }
/**
* Updates the preferences when the save button is clicked.
@ -101,12 +101,9 @@ public class Settings {
}
private void supplementDefaults() {
items.putIfAbsent("enterToSend",
new SettingsItem<>(true, "Enter to send", "Sends a message by pressing the enter key."));
items.putIfAbsent("onCloseMode",
new SettingsItem<>(true, "Hide on close", "Hides the chat window when it is closed."));
items.putIfAbsent("currentTheme",
new SettingsItem<>("dark", "Current Theme Name", "The name of the currently selected theme."));
items.putIfAbsent("enterToSend", new SettingsItem<>(true, "Enter to send", "Sends a message by pressing the enter key."));
items.putIfAbsent("onCloseMode", new SettingsItem<>(true, "Hide on close", "Hides the chat window when it is closed."));
items.putIfAbsent("currentTheme", new SettingsItem<>("dark", "Current Theme Name", "The name of the currently selected theme."));
}
/**
@ -115,25 +112,19 @@ public class Settings {
* @param theme the {@link Theme} to add
* @since Envoy Client v0.2-alpha
*/
public void addNewThemeToMap(Theme theme) {
getThemes().put(theme.getThemeName(), theme);
}
public void addNewThemeToMap(Theme theme) { getThemes().put(theme.getThemeName(), theme); }
/**
* @return the name of the currently active {@link Theme}
* @since Envoy Client v0.2-alpha
*/
public String getCurrentThemeName() {
return (String) items.get("currentTheme").get();
}
public String getCurrentThemeName() { return (String) items.get("currentTheme").get(); }
/**
* @return the currently active {@link Theme}
* @since Envoy Client v0.1-beta
*/
public Theme getCurrentTheme() {
return getTheme(getCurrentThemeName());
}
public Theme getCurrentTheme() { return getTheme(getCurrentThemeName()); }
/**
* Sets the name of the current {@link Theme}.
@ -141,18 +132,14 @@ public class Settings {
* @param themeName the name to set
* @since Envoy Client v0.2-alpha
*/
public void setCurrentTheme(String themeName) {
((SettingsItem<String>) items.get("currentTheme")).set(themeName);
}
public void setCurrentTheme(String themeName) { ((SettingsItem<String>) items.get("currentTheme")).set(themeName); }
/**
* @return whether the current {@link Theme} is one of the default themes.
* Currently checks for dark and light theme.
* @since Envoy Client v0.1-beta
*/
public boolean isUsingDefaultTheme() {
return getCurrentThemeName().equals("dark") || getCurrentThemeName().equals("light");
}
public boolean isUsingDefaultTheme() { return getCurrentThemeName().equals("dark") || getCurrentThemeName().equals("light"); }
/**
* @return {@code true}, if pressing the {@code Enter} key suffices to send a
@ -160,9 +147,7 @@ public class Settings {
* {@code Control} key.
* @since Envoy Client v0.2-alpha
*/
public Boolean isEnterToSend() {
return (Boolean) items.get("enterToSend").get();
}
public Boolean isEnterToSend() { return (Boolean) items.get("enterToSend").get(); }
/**
* Changes the keystrokes performed by the user to send a message.
@ -172,17 +157,13 @@ public class Settings {
* conjunction with the {@code Control} key.
* @since Envoy Client v0.2-alpha
*/
public void setEnterToSend(boolean enterToSend) {
((SettingsItem<Boolean>) items.get("enterToSend")).set(enterToSend);
}
public void setEnterToSend(boolean enterToSend) { ((SettingsItem<Boolean>) items.get("enterToSend")).set(enterToSend); }
/**
* @return the current on close mode.
* @since Envoy Client v0.3-alpha
*/
public Boolean getCurrentOnCloseMode() {
return (Boolean) items.get("onCloseMode").get();
}
public Boolean getCurrentOnCloseMode() { return (Boolean) items.get("onCloseMode").get(); }
/**
* Sets the current on close mode.
@ -190,31 +171,23 @@ public class Settings {
* @param currentOnCloseMode the on close mode that should be set.
* @since Envoy Client v0.3-alpha
*/
public void setCurrentOnCloseMode(boolean currentOnCloseMode) {
((SettingsItem<Boolean>) items.get("onCloseMode")).set(currentOnCloseMode);
}
public void setCurrentOnCloseMode(boolean currentOnCloseMode) { ((SettingsItem<Boolean>) items.get("onCloseMode")).set(currentOnCloseMode); }
/**
* @return the items
*/
public Map<String, SettingsItem<?>> getItems() {
return items;
}
public Map<String, SettingsItem<?>> getItems() { return items; }
/**
* @param items the items to set
*/
public void setItems(Map<String, SettingsItem<?>> items) {
this.items = items;
}
public void setItems(Map<String, SettingsItem<?>> items) { this.items = items; }
/**
* @return a {@code Map<String, Theme>} of all themes with their names as keys
* @since Envoy Client v0.2-alpha
*/
public Map<String, Theme> getThemes() {
return themes;
}
public Map<String, Theme> getThemes() { return themes; }
/**
* Sets the {@code Map<String, Theme>} of all themes with their names as keys
@ -222,16 +195,12 @@ public class Settings {
* @param themes the theme map to set
* @since Envoy Client v0.2-alpha
*/
public void setThemes(Map<String, Theme> themes) {
this.themes = themes;
}
public void setThemes(Map<String, Theme> themes) { this.themes = themes; }
/**
* @param themeName the name of the {@link Theme} to get
* @return the {@link Theme} with the specified name
* @since Envoy Client v0.3-alpha
*/
public Theme getTheme(String themeName) {
return themes.get(themeName);
}
public Theme getTheme(String themeName) { return themes.get(themeName); }
}