Skip to content

Commit

Permalink
Added font increase/decrease buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Arxa committed Oct 20, 2017
1 parent 11000e4 commit 9b386ae
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
5 changes: 0 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,8 @@ dependencies {
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.6'

// testCompile group: "org.loadui", name: "testFx", version: "3.1.2"
// testCompile 'org.testfx:testfx-core:4.0.1-alpha'
// testRuntime 'org.testfx:openjfx-monocle:1.8.0_20'
testCompile group: 'org.loadui', name: 'testFx', version: '3.1.2'

testCompile group: 'org.testfx', name: 'testfx-core', version: '4.0.8-alpha'

}
test {
testLogging.showStandardStreams = true
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void start(Stage stage) throws Exception
FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("Views/main.fxml"));
Parent root = loader.load();
stage.setTitle("VideoText Extractor");
stage.setScene(new Scene(root, 680, 450));
stage.setScene(new Scene(root, 680, 390));
stage.setResizable(false);
stage.show();
stage.setOnCloseRequest(e -> Platform.exit());
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/Processors/FileProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import javafx.scene.Node;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -39,6 +41,7 @@ public class FileProcessor
*/
public static void validateVideoFile(File videoFile)
{
if (videoFile == null) return;
Alert alert;
if (!FileProcessor.validateVideoFileName(videoFile)){
alert = new Alert(Alert.AlertType.WARNING, "ERROR on loading file\n"+
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/Processors/VideoProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import javafx.concurrent.Task;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import org.bytedeco.javacpp.BytePointer;
import org.bytedeco.javacpp.lept;
import org.bytedeco.javacpp.tesseract;
Expand Down
26 changes: 23 additions & 3 deletions src/main/java/ViewControllers/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
import javafx.scene.input.TransferMode;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import org.apache.commons.io.FilenameUtils;
import org.jetbrains.annotations.Contract;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Timer;
import java.util.TimerTask;
Expand All @@ -41,6 +44,8 @@ public class MainController
public MenuItem settingsMenuItem;
public ProgressBar progressBar;
public MenuItem logMenuItem;
public Button increaseFont_button;
public Button decreaseFont_button;

private static File currentVideoFile;
private static Stage mainStage;
Expand All @@ -57,6 +62,14 @@ public void initialize()
videoIcon.setCursor(Cursor.HAND);
extractButton.setCursor(Cursor.HAND);

increaseFont_button.setOnMouseClicked(event -> {
textArea.setFont(Font.font("Verdana", FontWeight.NORMAL, textArea.getFont().getSize()+2));
});

decreaseFont_button.setOnMouseClicked(event -> {
textArea.setFont(Font.font("Verdana", FontWeight.NORMAL, textArea.getFont().getSize()-2));
});

// When dragging something, allow it to be copied/moved only if it's a mp4 file
videoPane.setOnDragOver(event -> {
if (event.getDragboard().getFiles().get(0).isFile()){
Expand Down Expand Up @@ -149,12 +162,19 @@ public void initialize()
});

playDetected.setOnAction(event -> {
File videoFile = Paths.get(ApplicationPaths.RESOURCES_OUTPUTS, ApplicationPaths.UNIQUE_FOLDER_NAME,
"Video", "video.mp4").toFile();
if (videoFile.exists()){
String videoFilePath = null;
try {
videoFilePath = Paths.get(ApplicationPaths.RESOURCES_OUTPUTS, ApplicationPaths.UNIQUE_FOLDER_NAME,
"Video", "video.mp4").toAbsolutePath().toString();
} catch (Exception e) {
return;
}
File videoFile = new File(videoFilePath);
if (videoFile.exists() && videoFile.isFile()){
Player.playVideo(videoFile);
}
});

}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/Views/main.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>

<AnchorPane fx:id="anchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="450.0" prefWidth="1200.0" stylesheets="/CSS/RootLayout.css" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ViewControllers.MainController">
<AnchorPane fx:id="anchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="415.0" prefWidth="1200.0" stylesheets="/CSS/RootLayout.css" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ViewControllers.MainController">
<children>
<Pane fx:id="videoPane" layoutX="-4.0" layoutY="25.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="379.0" prefWidth="667.0" AnchorPane.leftAnchor="-4.0">
<children>
Expand Down Expand Up @@ -45,9 +45,11 @@
</Menu>
</menus>
</MenuBar>
<TextArea fx:id="textArea" editable="false" layoutX="715.0" layoutY="151.0" opacity="0.39" prefHeight="200.0" prefWidth="369.0" visible="false" wrapText="true" />
<TextArea fx:id="textArea" editable="false" layoutX="696.0" layoutY="151.0" opacity="0.39" prefHeight="247.0" prefWidth="388.0" visible="false" wrapText="true" />
<ProgressIndicator fx:id="progressIndicator" layoutX="838.0" layoutY="25.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="75.0" prefWidth="136.0" progress="0.0" visible="false" />
<Button fx:id="extractButton" layoutX="829.0" layoutY="52.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="168.0" text="Extract Text" visible="false" />
<ProgressBar fx:id="progressBar" layoutX="715.0" layoutY="126.0" prefHeight="8.0" prefWidth="369.0" progress="0.0" visible="false" />
<ProgressBar fx:id="progressBar" layoutX="696.0" layoutY="126.0" prefHeight="8.0" prefWidth="369.0" progress="0.0" visible="false" />
<Button fx:id="increaseFont_button" layoutX="1095.0" layoutY="151.0" mnemonicParsing="false" prefWidth="25.0" text="+" />
<Button fx:id="decreaseFont_button" layoutX="1095.0" layoutY="190.0" mnemonicParsing="false" prefWidth="25.0" text="-" />
</children>
</AnchorPane>
2 changes: 0 additions & 2 deletions src/test/java/MainTests/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ protected Parent getRootNode() {
@BeforeClass
public static void beforeTests() {



}

@AfterClass
Expand Down

0 comments on commit 9b386ae

Please sign in to comment.