documentation work

* added a lot of documentation to the code
* log4j 2.10 -> 2.11
This commit is contained in:
Jannik
2018-04-02 18:29:59 +02:00
parent a918b0b1d8
commit 5e4373d70d
12 changed files with 151 additions and 43 deletions

View File

@ -19,7 +19,6 @@
* MA 02110-1301, USA.
*
*/
package kellerkinder.HomeFlix.application;
import java.io.File;
@ -77,6 +76,10 @@ public class Main extends Application {
mainWindow();
}
/**
* initialize the mainWindowController, GUI and load the saved settings or call addFirstSource
* initialize the primaryStage and set the file/directory paths
*/
private void mainWindow(){
try {
FXMLLoader loader = new FXMLLoader();
@ -111,7 +114,7 @@ public class Main extends Application {
// startup checks
if (!configFile.exists()) {
directory.mkdir();
getFirstSource();
addFirstSource();
mainWindowController.setColor("ee3523");
mainWindowController.setSize(FONT_SIZE);
mainWindowController.setAutoUpdate(false);
@ -132,10 +135,10 @@ public class Main extends Application {
}
/**
* TODO add option to add streaming as first source when there i no config.xml
* we need to get the path for the first source from the user
* we need to get the path for the first source from the user and add it to
* sources.json, if the user ends the file-/directory-chooser the program will exit
*/
private void getFirstSource() {
private void addFirstSource() {
switch (System.getProperty("user.language") + "_" + System.getProperty("user.country")) {
case "en_US":
bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US); // us_english
@ -192,6 +195,11 @@ public class Main extends Application {
selectFirstSource.showAndWait();
}
/**
* set the log file location and initialize the logger
* launch the GUI
* @param args arguments given at the start
*/
public static void main(String[] args) {
if (System.getProperty("os.name").equals("Windows")) {
System.setProperty("logFilename", userHome + "/Documents/HomeFlix/app.log");
@ -210,10 +218,6 @@ public class Main extends Application {
return primaryStage;
}
public void setPrimaryStage(Stage primaryStage) {
this.primaryStage = primaryStage;
}
public AnchorPane getPane() {
return pane;
}

View File

@ -19,7 +19,6 @@
* MA 02110-1301, USA.
*
*/
package kellerkinder.HomeFlix.application;
import java.awt.Desktop;
@ -759,18 +758,22 @@ public class MainWindowController {
}
//set color of UI-Elements
/**
* set the color of the GUI-Elements
* if usedColor is less than checkColor set text fill white, else black
*/
private void applyColor() {
String style = "-fx-background-color: #" + getColor() + ";";
String btnStyleBlack = "-fx-button-type: RAISED; -fx-background-color: #" + getColor() + "; -fx-text-fill: BLACK;";
String btnStyleWhite = "-fx-button-type: RAISED; -fx-background-color: #" + getColor() + "; -fx-text-fill: WHITE;";
BigInteger icolor = new BigInteger(getColor(), 16);
BigInteger ccolor = new BigInteger("78909cff", 16);
BigInteger usedColor = new BigInteger(getColor(), 16);
BigInteger checkColor = new BigInteger("78909cff", 16);
sideMenuVBox.setStyle(style);
topHBox.setStyle(style);
searchTextField.setFocusColor(Color.valueOf(getColor()));
if (icolor.compareTo(ccolor) == -1) {
if (usedColor.compareTo(checkColor) == -1) {
dialogBtnStyle = btnStyleWhite;
settingsBtn.setStyle("-fx-text-fill: WHITE;");
aboutBtn.setStyle("-fx-text-fill: WHITE;");
@ -822,6 +825,9 @@ public class MainWindowController {
translateTransition.play();
}
/**
* set the local based on the languageChoisBox selection
*/
void setLocalUI() {
switch (getLocal()) {
case "en_US":
@ -895,7 +901,9 @@ public class MainWindowController {
LOGGER.error("An error occurred", exception);
}
// save settings
/**
* save the configuration to the config.xml file
*/
public void saveSettings() {
LOGGER.info("saving settings ...");
try {
@ -907,14 +915,17 @@ public class MainWindowController {
props.setProperty("ratingSortType", columnFavorite.getSortType().toString());
OutputStream outputStream = new FileOutputStream(main.getConfigFile()); // new output-stream
props.storeToXML(outputStream, "Project HomeFlix settings"); // writes new .xml
props.storeToXML(outputStream, "Project HomeFlix settings"); // write new .xml
outputStream.close();
} catch (IOException e) {
LOGGER.error(errorLoad, e);
}
}
// load settings
/**
* load the configuration from the config.xml file
* and try to load the API keys from apiKeys.json
*/
public void loadSettings() {
LOGGER.info("loading settings ...");