|
|
@ -3,10 +3,9 @@ package de.thm.tlf.photoViewer;
|
|
|
|
import de.thm.tlf.photoViewer.data.PicturePreview;
|
|
|
|
import de.thm.tlf.photoViewer.data.PicturePreview;
|
|
|
|
import javafx.application.Application;
|
|
|
|
import javafx.application.Application;
|
|
|
|
import javafx.application.Platform;
|
|
|
|
import javafx.application.Platform;
|
|
|
|
|
|
|
|
import javafx.beans.binding.Bindings;
|
|
|
|
import javafx.beans.property.DoubleProperty;
|
|
|
|
import javafx.beans.property.DoubleProperty;
|
|
|
|
import javafx.beans.property.SimpleDoubleProperty;
|
|
|
|
import javafx.beans.property.SimpleDoubleProperty;
|
|
|
|
//import javafx.beans.value.ChangeListener;
|
|
|
|
|
|
|
|
//import javafx.beans.value.ObservableValue;
|
|
|
|
|
|
|
|
import javafx.concurrent.Task;
|
|
|
|
import javafx.concurrent.Task;
|
|
|
|
import javafx.event.ActionEvent;
|
|
|
|
import javafx.event.ActionEvent;
|
|
|
|
import javafx.event.EventHandler;
|
|
|
|
import javafx.event.EventHandler;
|
|
|
@ -16,6 +15,9 @@ import javafx.scene.Node;
|
|
|
|
import javafx.scene.Scene;
|
|
|
|
import javafx.scene.Scene;
|
|
|
|
import javafx.scene.control.*;
|
|
|
|
import javafx.scene.control.*;
|
|
|
|
import javafx.scene.image.ImageView;
|
|
|
|
import javafx.scene.image.ImageView;
|
|
|
|
|
|
|
|
import javafx.scene.input.KeyCode;
|
|
|
|
|
|
|
|
import javafx.scene.input.KeyCodeCombination;
|
|
|
|
|
|
|
|
import javafx.scene.input.KeyCombination;
|
|
|
|
import javafx.scene.layout.*;
|
|
|
|
import javafx.scene.layout.*;
|
|
|
|
import javafx.stage.FileChooser;
|
|
|
|
import javafx.stage.FileChooser;
|
|
|
|
import javafx.stage.Stage;
|
|
|
|
import javafx.stage.Stage;
|
|
|
@ -28,38 +30,42 @@ import java.util.List;
|
|
|
|
* Holds GUI elements as well as the handling of any user input.
|
|
|
|
* Holds GUI elements as well as the handling of any user input.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Tim Lukas Förster
|
|
|
|
* @author Tim Lukas Förster
|
|
|
|
* @version 0.1
|
|
|
|
* @version 1.0
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class Controller extends Application {
|
|
|
|
public class Controller extends Application {
|
|
|
|
|
|
|
|
////////////////////////////
|
|
|
|
//------ Attributes ------//
|
|
|
|
//------ Attributes ------//
|
|
|
|
|
|
|
|
////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
// CENTER //
|
|
|
|
// CENTER //
|
|
|
|
private final DoubleProperty zoomProperty = new SimpleDoubleProperty(200);
|
|
|
|
|
|
|
|
private final ScrollPane currentViewSP = new ScrollPane();
|
|
|
|
private final ScrollPane currentViewSP = new ScrollPane();
|
|
|
|
private final ImageView centerImageView = new ImageView();
|
|
|
|
private final ImageView centerImageView = new ImageView();
|
|
|
|
|
|
|
|
|
|
|
|
// LEFT //
|
|
|
|
|
|
|
|
private final VBox leftPane = new VBox();
|
|
|
|
|
|
|
|
private final VBox selectionPane = new VBox();
|
|
|
|
|
|
|
|
private final ScrollPane pictureSelector = new ScrollPane();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TOP //
|
|
|
|
// TOP //
|
|
|
|
private final VBox menu = new VBox();
|
|
|
|
private final VBox menu = new VBox();
|
|
|
|
private final MenuBar menuBar = new MenuBar();
|
|
|
|
private final MenuBar menuBar = new MenuBar();
|
|
|
|
private final Menu fileMenu = new Menu("File");
|
|
|
|
private final Menu fileMenu = new Menu("File");
|
|
|
|
private final Menu aboutMenu = new Menu("About");
|
|
|
|
private final Menu aboutMenu = new Menu("About");
|
|
|
|
private final MenuItem openFiles = new MenuItem("Open");
|
|
|
|
private final MenuItem openFiles = new MenuItem("Open");
|
|
|
|
|
|
|
|
private final MenuItem clearViewer = new Menu("Close all");
|
|
|
|
private final MenuItem startSlideShow = new MenuItem("Start Slide Show");
|
|
|
|
private final MenuItem startSlideShow = new MenuItem("Start Slide Show");
|
|
|
|
private final MenuItem exitViewer = new Menu("Exit");
|
|
|
|
private final MenuItem exitViewer = new Menu("Exit");
|
|
|
|
private final MenuItem showInfo = new Menu("Information");
|
|
|
|
private final MenuItem showInfo = new Menu("Information");
|
|
|
|
|
|
|
|
|
|
|
|
// BOTTOM //
|
|
|
|
// BOTTOM //
|
|
|
|
private final BorderPane bottomPanel = new BorderPane();
|
|
|
|
private final VBox bottomPanel = new VBox();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final HBox selectionPane = new HBox();
|
|
|
|
|
|
|
|
private final ScrollPane pictureSelector = new ScrollPane();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final BorderPane bottomLowerPanel = new BorderPane();
|
|
|
|
private final HBox bottomLeft = new HBox();
|
|
|
|
private final HBox bottomLeft = new HBox();
|
|
|
|
private final HBox bottomMid = new HBox();
|
|
|
|
private final HBox bottomMid = new HBox();
|
|
|
|
private final HBox bottomRight = new HBox();
|
|
|
|
private final HBox bottomRight = new HBox();
|
|
|
|
|
|
|
|
|
|
|
|
private final Button openFilesButton = new Button("Open Pictures");
|
|
|
|
private final Button openFilesButton = new Button("Open Pictures");
|
|
|
|
private Slider zoomSlider;
|
|
|
|
private Slider zoomSlider;
|
|
|
|
|
|
|
|
private Slider slideShowSpeedSlider;
|
|
|
|
|
|
|
|
|
|
|
|
private final Button prevPicBtn = new Button("<-");
|
|
|
|
private final Button prevPicBtn = new Button("<-");
|
|
|
|
private final Button nextPicBtn = new Button("->");
|
|
|
|
private final Button nextPicBtn = new Button("->");
|
|
|
@ -73,51 +79,123 @@ public class Controller extends Application {
|
|
|
|
// Etc. //
|
|
|
|
// Etc. //
|
|
|
|
private boolean bIsFullScreen = false;
|
|
|
|
private boolean bIsFullScreen = false;
|
|
|
|
private boolean bSlideShowActive = false;
|
|
|
|
private boolean bSlideShowActive = false;
|
|
|
|
//------ End Attributes ------//
|
|
|
|
private final DoubleProperty slideShowSpeed = new SimpleDoubleProperty(4);
|
|
|
|
|
|
|
|
private final DoubleProperty zoomProperty = new SimpleDoubleProperty(200);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final KeyCombination keyCrtlQ = new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_ANY);
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
//------ End Attributes ------//
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////
|
|
|
|
//------ Methods ------//
|
|
|
|
//------ Methods ------//
|
|
|
|
|
|
|
|
/////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Entrypoint to program
|
|
|
|
|
|
|
|
* @param args String-Array supplied when starting the application
|
|
|
|
|
|
|
|
*/
|
|
|
|
public static void main(String[] args) {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
launch(args);
|
|
|
|
launch(args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Method initializing GUI
|
|
|
|
|
|
|
|
* @param primaryStage Default stage supplied when GUI is created
|
|
|
|
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void start(Stage primaryStage) {
|
|
|
|
public void start(Stage primaryStage) {
|
|
|
|
picHandler = PictureHandler.getInstance();
|
|
|
|
picHandler = PictureHandler.getInstance();
|
|
|
|
|
|
|
|
|
|
|
|
BorderPane root = new BorderPane();
|
|
|
|
BorderPane root = new BorderPane();
|
|
|
|
root.setLeft(createLeft());
|
|
|
|
|
|
|
|
root.setCenter(createCenter());
|
|
|
|
root.setCenter(createCenter());
|
|
|
|
root.setTop(createTop());
|
|
|
|
root.setTop(createTop());
|
|
|
|
root.setBottom(createBottom());
|
|
|
|
root.setBottom(createBottom());
|
|
|
|
Scene mainScene = new Scene(root, 1200, 800);
|
|
|
|
Scene mainScene = new Scene(root, 1200, 800);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create all Actions //
|
|
|
|
|
|
|
|
createSliderActions();
|
|
|
|
|
|
|
|
createMenuActions(primaryStage);
|
|
|
|
|
|
|
|
createButtonActions(primaryStage);
|
|
|
|
|
|
|
|
|
|
|
|
// Keypress Actions //
|
|
|
|
// Keypress Actions //
|
|
|
|
mainScene.setOnKeyPressed(event -> {
|
|
|
|
mainScene.setOnKeyPressed(event -> {
|
|
|
|
switch (event.getCode()) {
|
|
|
|
|
|
|
|
case RIGHT:
|
|
|
|
if (keyCrtlQ.match(event)) {
|
|
|
|
try{
|
|
|
|
Platform.exit();
|
|
|
|
centerImageView.setImage(picHandler.getPrevPicture().getImage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
catch (NoPicturesLoadedException npl) { showNoPicturesLoadedWarning(); }
|
|
|
|
switch (event.getCode()) {
|
|
|
|
break;
|
|
|
|
case RIGHT:
|
|
|
|
case LEFT:
|
|
|
|
case A:
|
|
|
|
try{
|
|
|
|
try {
|
|
|
|
centerImageView.setImage(picHandler.getNextPicture().getImage());
|
|
|
|
centerImageView.setImage(picHandler.getPrevPicture().getImage());
|
|
|
|
}
|
|
|
|
} catch (NoPicturesLoadedException npl) {
|
|
|
|
catch (NoPicturesLoadedException npl) { showNoPicturesLoadedWarning(); }
|
|
|
|
showNoPicturesLoadedWarning();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LEFT:
|
|
|
|
|
|
|
|
case D:
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
centerImageView.setImage(picHandler.getNextPicture().getImage());
|
|
|
|
|
|
|
|
} catch (NoPicturesLoadedException npl) {
|
|
|
|
|
|
|
|
showNoPicturesLoadedWarning();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// End Keypress Actions //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Center Zoom Action //
|
|
|
|
primaryStage.setTitle("Photo Viewer");
|
|
|
|
|
|
|
|
primaryStage.setScene(mainScene);
|
|
|
|
|
|
|
|
primaryStage.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Task used to run the slideshow in separate Threat.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
|
|
|
|
|
Task slideShowTask = new Task<Void>(){
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@SuppressWarnings("BusyWait")
|
|
|
|
|
|
|
|
protected Void call() throws Exception {
|
|
|
|
|
|
|
|
while(bSlideShowActive) {
|
|
|
|
|
|
|
|
Thread.sleep((long)(slideShowSpeed.get()*1000));
|
|
|
|
|
|
|
|
centerImageView.setImage(picHandler.getNextPicture().getImage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Even wrapper for openFileDialogEvent
|
|
|
|
|
|
|
|
* @param stage the primary stage, used to display the file-open-dialog
|
|
|
|
|
|
|
|
* @return EventHandler for dialog handling
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private EventHandler<ActionEvent> openFileDialogEvent(Stage stage) {
|
|
|
|
|
|
|
|
return e -> openFileDialog(stage);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Event wrapper for clear function
|
|
|
|
|
|
|
|
* @return EventHandle executing the clear function
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private EventHandler<ActionEvent> clearPreviewViewEvent(){
|
|
|
|
|
|
|
|
return e -> clearPreviewView();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
//------ Helper-Methods ------//
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Helper method for handling sliders
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void createSliderActions() {
|
|
|
|
|
|
|
|
// Zoom Action //
|
|
|
|
zoomProperty.addListener(observable -> {
|
|
|
|
zoomProperty.addListener(observable -> {
|
|
|
|
centerImageView.setFitWidth(zoomProperty.get());
|
|
|
|
|
|
|
|
centerImageView.setFitHeight(zoomProperty.get());
|
|
|
|
|
|
|
|
/* Previously used values
|
|
|
|
|
|
|
|
centerImageView.setFitWidth(zoomProperty.get() * 4);
|
|
|
|
centerImageView.setFitWidth(zoomProperty.get() * 4);
|
|
|
|
centerImageView.setFitHeight(zoomProperty.get() * 3);
|
|
|
|
centerImageView.setFitHeight(zoomProperty.get() * 3);
|
|
|
|
*/
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
zoomSlider.valueProperty().addListener((observableValue, oldVal, newVal) -> {
|
|
|
|
zoomSlider.valueProperty().addListener((observableValue, oldVal, newVal) -> {
|
|
|
@ -129,26 +207,27 @@ public class Controller extends Application {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/* Currently not used. A method that allow scrolling with the mouse wheel when inside the center
|
|
|
|
// SlideShowSpeed Action //
|
|
|
|
currentViewSP.addEventFilter(ScrollEvent.ANY, scrollEvent -> {
|
|
|
|
slideShowSpeed.addListener(observable -> {});
|
|
|
|
|
|
|
|
slideShowSpeedSlider.valueProperty().addListener((observableValue, oldVal, newVal) -> slideShowSpeed.set((double)newVal));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (scrollEvent.getDeltaY() > 0) {
|
|
|
|
/**
|
|
|
|
zoomProperty.set(zoomProperty.get() * 1.1);
|
|
|
|
* Helper method for handling menus and -entries
|
|
|
|
} else if (scrollEvent.getDeltaY() < 0) {
|
|
|
|
* @param stage the primary stage, used to display the file-open-dialog
|
|
|
|
zoomProperty.set(zoomProperty.get() / 1.1);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
private void createMenuActions(Stage stage) {
|
|
|
|
});
|
|
|
|
openFiles.setOnAction(openFileDialogEvent(stage));
|
|
|
|
/**/
|
|
|
|
|
|
|
|
// End Center Zoom Action //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Menu Actions //
|
|
|
|
|
|
|
|
openFiles.setOnAction(openFileDialog(primaryStage));
|
|
|
|
|
|
|
|
exitViewer.setOnAction( e -> Platform.exit());
|
|
|
|
exitViewer.setOnAction( e -> Platform.exit());
|
|
|
|
// End Menu Actions //
|
|
|
|
clearViewer.setOnAction(clearPreviewViewEvent());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
// Button Actions //
|
|
|
|
* Helper method for handling button interaction
|
|
|
|
openFilesButton.setOnAction(openFileDialog(primaryStage));
|
|
|
|
* @param stage the primary stage, used to display the file-open-dialog and control fullscreen functions
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void createButtonActions(Stage stage) {
|
|
|
|
|
|
|
|
openFilesButton.setOnAction(openFileDialogEvent(stage));
|
|
|
|
|
|
|
|
|
|
|
|
prevPicBtn.setOnAction(e -> {
|
|
|
|
prevPicBtn.setOnAction(e -> {
|
|
|
|
try{
|
|
|
|
try{
|
|
|
@ -165,7 +244,7 @@ public class Controller extends Application {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
fullScreenBtn.setOnAction(e -> {
|
|
|
|
fullScreenBtn.setOnAction(e -> {
|
|
|
|
primaryStage.setFullScreen(!bIsFullScreen);
|
|
|
|
stage.setFullScreen(!bIsFullScreen);
|
|
|
|
bIsFullScreen ^= true;
|
|
|
|
bIsFullScreen ^= true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -175,10 +254,9 @@ public class Controller extends Application {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void handle(ActionEvent actionEvent) {
|
|
|
|
public void handle(ActionEvent actionEvent) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// This statement is to catch any errors regarding no images loaded
|
|
|
|
|
|
|
|
centerImageView.setImage(picHandler.getNextPicture().getImage());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!bSlideShowActive) {
|
|
|
|
if (!bSlideShowActive) {
|
|
|
|
|
|
|
|
// This statement is to catch any errors regarding no images loaded
|
|
|
|
|
|
|
|
centerImageView.setImage(picHandler.getNextPicture().getImage());
|
|
|
|
bSlideShowActive = true;
|
|
|
|
bSlideShowActive = true;
|
|
|
|
slideShowBtn.setText("Stop Slide Show");
|
|
|
|
slideShowBtn.setText("Stop Slide Show");
|
|
|
|
th = new Thread(slideShowTask);
|
|
|
|
th = new Thread(slideShowTask);
|
|
|
@ -193,55 +271,36 @@ public class Controller extends Application {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// End Button Actions //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
primaryStage.setTitle("Photo Viewer");
|
|
|
|
|
|
|
|
primaryStage.setScene(mainScene);
|
|
|
|
|
|
|
|
primaryStage.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
|
|
|
|
|
Task slideShowTask = new Task<Void>(){
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@SuppressWarnings("BusyWait")
|
|
|
|
|
|
|
|
protected Void call() throws Exception {
|
|
|
|
|
|
|
|
while(bSlideShowActive) {
|
|
|
|
|
|
|
|
Thread.sleep(3000);
|
|
|
|
|
|
|
|
centerImageView.setImage(picHandler.getNextPicture().getImage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------ Helper-Methods ------//
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Open file-dialog allowing to select multiple pictures (via filter),
|
|
|
|
* Open file-dialog allowing to select multiple pictures (via filter),
|
|
|
|
* adds them to the PictureHandler and updates the picture preview
|
|
|
|
* adds them to the PictureHandler and updates the picture preview
|
|
|
|
* @param stage the primary stage, used to display the file-open-dialog
|
|
|
|
* @param stage the primary stage, used to display the file-open-dialog
|
|
|
|
* @return EventHandler for dialog handling
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private EventHandler<ActionEvent> openFileDialog(Stage stage) {
|
|
|
|
private void openFileDialog(Stage stage) {
|
|
|
|
return e -> {
|
|
|
|
FileChooser fileChooser = new FileChooser();
|
|
|
|
FileChooser fileChooser = new FileChooser();
|
|
|
|
fileChooser.setTitle("Open Pictures");
|
|
|
|
fileChooser.setTitle("Open Pictures");
|
|
|
|
fileChooser.getExtensionFilters().addAll(
|
|
|
|
fileChooser.getExtensionFilters().addAll(
|
|
|
|
new FileChooser.ExtensionFilter("Image Files", "*.png", "*.jpg", "*.gif"));
|
|
|
|
new FileChooser.ExtensionFilter("Image Files", "*.png", "*.jpg", "*.gif"));
|
|
|
|
List<File> selectedPictures = fileChooser.showOpenMultipleDialog(stage);
|
|
|
|
List<File> selectedPictures = fileChooser.showOpenMultipleDialog(stage);
|
|
|
|
if (selectedPictures != null) {
|
|
|
|
if (selectedPictures != null) {
|
|
|
|
try {
|
|
|
|
try{
|
|
|
|
picHandler.loadPictures(selectedPictures);
|
|
|
|
picHandler.loadPictures(selectedPictures);
|
|
|
|
Controller.this.updatePreviewView();
|
|
|
|
Controller.this.updatePreviewView();
|
|
|
|
centerImageView.setImage(picHandler.getNextPicture().getImage());
|
|
|
|
centerImageView.setImage(picHandler.getNextPicture().getImage());
|
|
|
|
} catch (NoPicturesLoadedException npl) {
|
|
|
|
}
|
|
|
|
showNoPicturesLoadedWarning();
|
|
|
|
catch (NoPicturesLoadedException npl){ showNoPicturesLoadedWarning();}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Method that updates the preview Pane with all PreviewPictures provided by the Picture Handler
|
|
|
|
* Method that updates the preview Pane with all PreviewPictures provided by the Picture Handler
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void updatePreviewView(){
|
|
|
|
private void updatePreviewView(){
|
|
|
|
|
|
|
|
clearPreviewView();
|
|
|
|
|
|
|
|
selectionPane.setPadding(new Insets(5,5,5,5));
|
|
|
|
for(PicturePreview pp: picHandler.getPreviews()){
|
|
|
|
for(PicturePreview pp: picHandler.getPreviews()){
|
|
|
|
ImageView iv = new ImageView(pp.getImage());
|
|
|
|
ImageView iv = new ImageView(pp.getImage());
|
|
|
|
iv.setFitWidth(150);
|
|
|
|
iv.setFitWidth(150);
|
|
|
@ -252,15 +311,12 @@ public class Controller extends Application {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Method that handles the settings and layout of the Left Panel
|
|
|
|
* Used to clear the preview and center panel when the viewer is cleared
|
|
|
|
* @return Node, set up for displaying on the left of a GridPane
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private Node createLeft(){
|
|
|
|
private void clearPreviewView(){
|
|
|
|
selectionPane.setPadding(new Insets(5,5,5,5));
|
|
|
|
selectionPane.getChildren().clear();
|
|
|
|
selectionPane.setSpacing(5);
|
|
|
|
selectionPane.setPadding(new Insets(5,155,5,5));
|
|
|
|
pictureSelector.setContent(selectionPane);
|
|
|
|
centerImageView.setImage(null);
|
|
|
|
leftPane.getChildren().addAll(pictureSelector);
|
|
|
|
|
|
|
|
return leftPane;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -269,11 +325,11 @@ public class Controller extends Application {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private Node createTop(){
|
|
|
|
private Node createTop(){
|
|
|
|
SeparatorMenuItem sep = new SeparatorMenuItem();
|
|
|
|
SeparatorMenuItem sep = new SeparatorMenuItem();
|
|
|
|
fileMenu.getItems().addAll(openFiles, sep, startSlideShow, exitViewer);
|
|
|
|
// File Menu
|
|
|
|
|
|
|
|
fileMenu.getItems().addAll(openFiles, clearViewer, sep, startSlideShow, exitViewer);
|
|
|
|
// About Menu
|
|
|
|
// About Menu
|
|
|
|
|
|
|
|
|
|
|
|
aboutMenu.getItems().addAll(showInfo);
|
|
|
|
aboutMenu.getItems().addAll(showInfo);
|
|
|
|
// Menu bare
|
|
|
|
// Menu bar
|
|
|
|
menuBar.getMenus().addAll(fileMenu, aboutMenu);
|
|
|
|
menuBar.getMenus().addAll(fileMenu, aboutMenu);
|
|
|
|
// Adding Menus to Top Panel
|
|
|
|
// Adding Menus to Top Panel
|
|
|
|
menu.getChildren().addAll(menuBar);
|
|
|
|
menu.getChildren().addAll(menuBar);
|
|
|
@ -285,10 +341,22 @@ public class Controller extends Application {
|
|
|
|
* @return Node, set up for displaying on the center of a GridPane
|
|
|
|
* @return Node, set up for displaying on the center of a GridPane
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private Node createCenter(){
|
|
|
|
private Node createCenter(){
|
|
|
|
|
|
|
|
// Use stack pane and magic to center the image on screen
|
|
|
|
|
|
|
|
StackPane imageHolder = new StackPane(centerImageView);
|
|
|
|
|
|
|
|
GridPane grid = new GridPane();
|
|
|
|
|
|
|
|
currentViewSP.setContent(imageHolder);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
imageHolder.minWidthProperty().bind(Bindings.createDoubleBinding(() ->
|
|
|
|
|
|
|
|
currentViewSP.getViewportBounds().getWidth(), currentViewSP.viewportBoundsProperty()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
imageHolder.minHeightProperty().bind(Bindings.createDoubleBinding(() ->
|
|
|
|
|
|
|
|
currentViewSP.getViewportBounds().getHeight(), currentViewSP.viewportBoundsProperty()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
grid.getChildren().add(imageHolder);
|
|
|
|
|
|
|
|
|
|
|
|
centerImageView.setX(10);
|
|
|
|
centerImageView.setX(10);
|
|
|
|
centerImageView.setY(10);
|
|
|
|
centerImageView.setY(10);
|
|
|
|
centerImageView.setPreserveRatio(true);
|
|
|
|
centerImageView.setPreserveRatio(true);
|
|
|
|
currentViewSP.setContent(centerImageView);
|
|
|
|
|
|
|
|
return currentViewSP;
|
|
|
|
return currentViewSP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -297,23 +365,39 @@ public class Controller extends Application {
|
|
|
|
* @return Node, set up for displaying on the bottom of a GridPane
|
|
|
|
* @return Node, set up for displaying on the bottom of a GridPane
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private Node createBottom() {
|
|
|
|
private Node createBottom() {
|
|
|
|
bottomPanel.setPadding(new Insets(5, 5, 5, 5));
|
|
|
|
bottomLowerPanel.setPadding(new Insets(5, 5, 5, 5));
|
|
|
|
|
|
|
|
|
|
|
|
// Left Bottom Part
|
|
|
|
// Left Bottom Part
|
|
|
|
zoomSlider = new Slider(0, 100, 25);
|
|
|
|
zoomSlider = new Slider(0, 100, 25);
|
|
|
|
zoomSlider.setShowTickMarks(true);
|
|
|
|
zoomSlider.setShowTickMarks(true);
|
|
|
|
bottomLeft.getChildren().addAll(openFilesButton, zoomSlider);
|
|
|
|
Label zoomLabel = new Label("Zoom:");
|
|
|
|
bottomPanel.setLeft(bottomLeft);
|
|
|
|
bottomLeft.getChildren().addAll(openFilesButton, zoomLabel, zoomSlider);
|
|
|
|
|
|
|
|
//bottomLeft.getChildren().addAll(zoomLabel, zoomSlider);
|
|
|
|
|
|
|
|
bottomLeft.setSpacing(5);
|
|
|
|
|
|
|
|
bottomLowerPanel.setLeft(bottomLeft);
|
|
|
|
|
|
|
|
|
|
|
|
// Middle Bottom Part
|
|
|
|
// Middle Bottom Part
|
|
|
|
bottomMid.setAlignment(Pos.CENTER);
|
|
|
|
bottomMid.setAlignment(Pos.CENTER);
|
|
|
|
bottomMid.setSpacing(5);
|
|
|
|
bottomMid.setSpacing(5);
|
|
|
|
bottomMid.getChildren().addAll(prevPicBtn, slideShowBtn, nextPicBtn);
|
|
|
|
bottomMid.getChildren().addAll(prevPicBtn, slideShowBtn, nextPicBtn);
|
|
|
|
bottomPanel.setCenter(bottomMid);
|
|
|
|
bottomLowerPanel.setCenter(bottomMid);
|
|
|
|
|
|
|
|
|
|
|
|
// Right Bottom Part
|
|
|
|
// Right Bottom Part
|
|
|
|
bottomRight.getChildren().add(fullScreenBtn);
|
|
|
|
slideShowSpeedSlider = new Slider(0.5, 15, 4);
|
|
|
|
bottomPanel.setRight(bottomRight);
|
|
|
|
slideShowSpeedSlider.setShowTickMarks(true);
|
|
|
|
|
|
|
|
slideShowSpeedSlider.setShowTickLabels(true);
|
|
|
|
|
|
|
|
Label sssLabel = new Label("Speed:");
|
|
|
|
|
|
|
|
bottomRight.getChildren().addAll(sssLabel,slideShowSpeedSlider, fullScreenBtn);
|
|
|
|
|
|
|
|
bottomLowerPanel.setRight(bottomRight);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Bottom upper Part -> Picture preview
|
|
|
|
|
|
|
|
selectionPane.setPadding(new Insets(5,5,155,5));
|
|
|
|
|
|
|
|
selectionPane.autosize();
|
|
|
|
|
|
|
|
selectionPane.setSpacing(5);
|
|
|
|
|
|
|
|
pictureSelector.setContent(selectionPane);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bottomPanel.getChildren().addAll(pictureSelector, bottomLowerPanel);
|
|
|
|
|
|
|
|
|
|
|
|
return (bottomPanel);
|
|
|
|
return (bottomPanel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -329,6 +413,11 @@ public class Controller extends Application {
|
|
|
|
alert.showAndWait().ifPresent(rs -> {
|
|
|
|
alert.showAndWait().ifPresent(rs -> {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////
|
|
|
|
//------ End Helper-Methods ------//
|
|
|
|
//------ End Helper-Methods ------//
|
|
|
|
|
|
|
|
////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////
|
|
|
|
//------ End Methods ------//
|
|
|
|
//------ End Methods ------//
|
|
|
|
|
|
|
|
/////////////////////////////
|
|
|
|
}
|
|
|
|
}
|
|
|
|