Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Commit

Permalink
Added logging options
Browse files Browse the repository at this point in the history
  • Loading branch information
psidex committed Feb 3, 2018
1 parent af7e857 commit b84cebd
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 102 deletions.
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified settings/settings.clean.ser
Binary file not shown.
Binary file modified settings/settings.ser
Binary file not shown.
27 changes: 22 additions & 5 deletions src/main/resources/fxml/mainUI.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>

<?import javafx.scene.control.CheckBox?>
<StackPane minHeight="700" minWidth="900" prefHeight="700" prefWidth="900" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.view.MainController">

<VBox fx:id="setupVBox" alignment="CENTER" spacing="25">
<VBox fx:id="setupVBox" alignment="CENTER" spacing="20">
<VBox alignment="CENTER">
<Label styleClass="title" text="GarlicGUI" textAlignment="CENTER"/>
<Hyperlink fx:id="helpLink" text="help" textAlignment="CENTER" onAction="#openHelp"/>
<!-- Place these 2 closer together -->
<Label styleClass="title" text="GarlicGUI" textAlignment="CENTER" />
<Hyperlink fx:id="helpLink" text="help" textAlignment="CENTER" onAction="#openHelp" />
</VBox>
<ImageView fx:id="garlicImg" fitHeight="227" fitWidth="227" preserveRatio="true">
<Image url="@../images/garlicoin.png" />
Expand Down Expand Up @@ -53,10 +55,13 @@
<TextField fx:id="minerFlagsTextField" maxWidth="140" minWidth="140" promptText="e.g. --timeout=100" />
</VBox>
</HBox>
<Button fx:id="goButton" onAction="#loadMiner" text="Start Mining" />
<HBox alignment="CENTER" spacing="10">
<Button fx:id="configLogsButton" onAction="#openLogConfig" text="Configure Logging" />
<Button fx:id="goButton" onAction="#loadMiner" text="Start Mining" />
</HBox>
</VBox>

<VBox fx:id="miningVBox" alignment="CENTER" opacity="0" spacing="30" visible="false">
<VBox fx:id="miningVBox" alignment="CENTER" opacity="0" spacing="30">
<Label styleClass="title" text="GarlicGUI" textAlignment="CENTER" />
<ImageView fitHeight="227" fitWidth="227" preserveRatio="true">
<Image url="@../images/garlicoin.png" />
Expand Down Expand Up @@ -91,6 +96,18 @@
<Button onAction="#stopMiner" text="Stop Mining" />
</VBox>

<VBox fx:id="loggingConfigVBox" alignment="CENTER" opacity="0" spacing="30">
<HBox alignment="CENTER" minWidth="900" spacing="10">
<Label text="Write GarlicGUI output to file" />
<CheckBox fx:id="GarlicGUILoggingCheckBox" />
</HBox>
<HBox alignment="CENTER" minWidth="900" spacing="10">
<Label text="Write miner output to file" />
<CheckBox fx:id="minerLoggingCheckBox" />
</HBox>
<Button onAction="#backToSetup" text="Back to setup" />
</VBox>

<stylesheets>
<URL value="@../stylesheets/main.css" />
</stylesheets>
Expand Down
34 changes: 19 additions & 15 deletions src/main/view/CMDThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,26 @@ public class CMDThread implements Runnable {
private String cmdString;
private String exeName;
private PrintWriter logWriter;

CMDThread(String to_execute, String minerExecutable, String logFileName) {

try {
logWriter = new PrintWriter(logFileName, "UTF-8");
} catch (IOException e) {
StacktraceAlert.create(
"Log file error",
"Cannot create new PrintWriter to " + logFileName,
"CMDThread.logWriter threw IOException",
e
);
private boolean loggingEnabled;

CMDThread(String toExecute, String minerExecutable, String logFileName, boolean loggingEnabledParam) {

if (loggingEnabledParam) {
try {
logWriter = new PrintWriter(logFileName, "UTF-8");
} catch (IOException e) {
StacktraceAlert.create(
"Log file error",
"Cannot create new PrintWriter to " + logFileName,
"CMDThread.logWriter threw IOException",
e
);
}
}

cmdString = to_execute;
cmdString = toExecute;
exeName = minerExecutable;
loggingEnabled = loggingEnabledParam;

}

Expand All @@ -48,7 +52,7 @@ public void run(){
// Do nothing
}
// Finally, close log file
logWriter.close();
if (loggingEnabled) logWriter.close();
}));

BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
Expand All @@ -58,7 +62,7 @@ public void run(){
String line = r.readLine();
if (line == null) break;
// Don't log API info (no point, will just create massive file)
if (!line.contains("API: ") && !line.trim().equals("") && !line.trim().equals("'")) logWriter.println(line);
if (!line.contains("API: ") && !line.trim().equals("") && !line.trim().equals("'") && loggingEnabled) logWriter.println(line);
}

}
Expand Down
75 changes: 75 additions & 0 deletions src/main/view/Fade.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package main.view;

import javafx.animation.FadeTransition;
import javafx.animation.ParallelTransition;
import javafx.animation.TranslateTransition;
import javafx.scene.layout.VBox;
import javafx.util.Duration;

public class Fade {

private static Integer transitionDuration = 1000;

public static ParallelTransition createFadeOutLeft(VBox VBoxToFade) {
// Will become more opaque and translate from the centre towards the left side
FadeTransition newFadeTrans = new FadeTransition(Duration.millis(transitionDuration), VBoxToFade);
newFadeTrans.setFromValue(1.0);
newFadeTrans.setToValue(0.0);
TranslateTransition newTranslateTrans = new TranslateTransition(Duration.millis(transitionDuration), VBoxToFade);
newTranslateTrans.setFromX(0);
newTranslateTrans.setToX(-300);
ParallelTransition returnPT = new ParallelTransition();
returnPT.getChildren().addAll(
newFadeTrans,
newTranslateTrans
);
return returnPT;
}

public static ParallelTransition createFadeOutRight(VBox VBoxToFade) {
FadeTransition newFadeTrans = new FadeTransition(Duration.millis(transitionDuration), VBoxToFade);
newFadeTrans.setFromValue(1.0);
newFadeTrans.setToValue(0.0);
TranslateTransition newTranslateTrans = new TranslateTransition(Duration.millis(transitionDuration), VBoxToFade);
newTranslateTrans.setFromX(0);
newTranslateTrans.setToX(300);
ParallelTransition returnPT = new ParallelTransition();
returnPT.getChildren().addAll(
newFadeTrans,
newTranslateTrans
);
return returnPT;
}

public static ParallelTransition createFadeInRight(VBox VBoxToFade) {
// Will become less opaque and translate towards the centre from the right side
FadeTransition newFadeTrans = new FadeTransition(Duration.millis(transitionDuration), VBoxToFade);
newFadeTrans.setFromValue(0.0);
newFadeTrans.setToValue(1.0);
TranslateTransition newTranslateTrans = new TranslateTransition(Duration.millis(transitionDuration), VBoxToFade);
newTranslateTrans.setFromX(300);
newTranslateTrans.setToX(0);
ParallelTransition returnPT = new ParallelTransition();
returnPT.getChildren().addAll(
newFadeTrans,
newTranslateTrans
);
return returnPT;
}

public static ParallelTransition createFadeInLeft(VBox VBoxToFade) {
FadeTransition newFadeTrans = new FadeTransition(Duration.millis(transitionDuration), VBoxToFade);
newFadeTrans.setFromValue(0.0);
newFadeTrans.setToValue(1.0);
TranslateTransition newTranslateTrans = new TranslateTransition(Duration.millis(transitionDuration), VBoxToFade);
newTranslateTrans.setFromX(-300);
newTranslateTrans.setToX(0);
ParallelTransition returnPT = new ParallelTransition();
returnPT.getChildren().addAll(
newFadeTrans,
newTranslateTrans
);
return returnPT;
}

}
Loading

0 comments on commit b84cebd

Please sign in to comment.