diff --git a/out/production/PhotoViewer/note.txt b/out/production/PhotoViewer/note.txt new file mode 100644 index 0000000..27fe7ad --- /dev/null +++ b/out/production/PhotoViewer/note.txt @@ -0,0 +1,8 @@ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle("File not found"); + alert.setContentText("File could not be located"); + alert.showAndWait().ifPresent(rs -> { + if (rs == ButtonType.OK) { + System.out.println("Pressed OK."); + } + }); \ No newline at end of file diff --git a/pic/image1.jpg b/pic/image1.jpg new file mode 100644 index 0000000..c5d92e4 Binary files /dev/null and b/pic/image1.jpg differ diff --git a/pic/image2.jpg b/pic/image2.jpg new file mode 100644 index 0000000..f8bb0f4 Binary files /dev/null and b/pic/image2.jpg differ diff --git a/pic/image3.jpg b/pic/image3.jpg new file mode 100644 index 0000000..bad5c81 Binary files /dev/null and b/pic/image3.jpg differ diff --git a/src/de/thm/tlf/photoViewer/Controller.java b/src/de/thm/tlf/photoViewer/Controller.java index 97f0b4b..d4c1695 100644 --- a/src/de/thm/tlf/photoViewer/Controller.java +++ b/src/de/thm/tlf/photoViewer/Controller.java @@ -1,10 +1,20 @@ package de.thm.tlf.photoViewer; import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.geometry.Pos; import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.BorderPane; import javafx.scene.layout.GridPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; import javafx.stage.Stage; +import java.io.*; + /** * Controller Class for Image-viewer. * Holds controls for the GUI elements. @@ -13,15 +23,127 @@ import javafx.stage.Stage; */ public class Controller extends Application { + private PicturePreview[] previews = new PicturePreview[]{ + new PicturePreview("pic/image1.jpg"), + new PicturePreview("pic/image2.jpg"), + new PicturePreview("pic/image3.jpg") + }; + public static void main(String[] args) { launch(args); } @Override - public void start(Stage primaryStage) throws Exception{ - GridPane mainPane = new GridPane(); - primaryStage.setTitle("Hello World"); - primaryStage.setScene(new Scene(mainPane, 300, 275)); + public void start(Stage primaryStage) { + /* ############################## + * #### MAIN PANE #### + * ############################## + */ + BorderPane mainPane = new BorderPane(); + // #### END MAIN PANE #### + + /* ############################## + * #### TOP PANEL #### + * ############################## + */ + VBox menu = new VBox(); + // File Menu + Menu fileMenu = new Menu("File"); + MenuItem openFiles = new MenuItem("Open"); + MenuItem startDiashow = new MenuItem("Start Diashow"); + MenuItem exitViewer = new Menu("Exit"); + SeparatorMenuItem sep = new SeparatorMenuItem(); + fileMenu.getItems().addAll(openFiles, sep, startDiashow, exitViewer); + // About Menu + Menu aboutMenu = new Menu("About"); + MenuItem showInfo = new Menu("Information"); + aboutMenu.getItems().addAll(showInfo); + // Menu bare + MenuBar menuBar = new MenuBar(); + menuBar.getMenus().addAll(fileMenu, aboutMenu); + // Adding Menus to Top Panel + menu.getChildren().addAll(menuBar); + // Adding Top Panel to Main Pane + mainPane.setTop(menu); + // #### END TOP PANEL #### + + /* ############################## + * #### LEFT PANEL #### + * ############################## + */ + VBox selectionPane = new VBox(); + selectionPane.setPadding(new Insets(5,5,5,5)); + selectionPane.setSpacing(5); + + // Add all previews to the + for(PicturePreview pp: previews){ + ImageView iv = new ImageView(pp.getImage()); + iv.setFitWidth(150); + iv.setSmooth(true); + iv.setPreserveRatio(true); + selectionPane.getChildren().add(iv); + } + + ScrollPane pictureSelector = new ScrollPane(); + pictureSelector.setContent(selectionPane); + + mainPane.setLeft(pictureSelector); + + // #### END LEFT PANEL #### + + /* ############################## + * #### CENTER PANEL #### + * ############################## + */ + Picture testPic = new Picture("pic/image3.jpg"); + ScrollPane currentViewSP = new ScrollPane(); + Image image = testPic.getImage(); + //Creating the image view + ImageView imageView = new ImageView(); + //Setting image to the image view + imageView.setImage(image); + //Setting the image view parameters + imageView.setX(10); + imageView.setY(10); + imageView.setPreserveRatio(true); + currentViewSP.setContent(imageView); + mainPane.setCenter(currentViewSP); + // #### END CENTER PANEL #### + + + /* ############################## + * #### BOTTOM PANEL #### + * ############################## + */ + BorderPane bottom = new BorderPane(); + bottom.setPadding(new Insets(5,5,5,5)); + + HBox bottomLeft = new HBox(); + Slider zoomSlider = new Slider(0, 100, 15); + zoomSlider.setShowTickMarks(true); + bottomLeft.getChildren().add(zoomSlider); + bottom.setLeft(bottomLeft); + + HBox bottomMid = new HBox(); + bottomMid.setAlignment(Pos.CENTER); + bottomMid.setSpacing(5); + Button prevPicBtn = new Button("<-"); + Button nextPicBtn = new Button("->"); + Button diashowBtn = new Button("Diashow"); + bottomMid.getChildren().addAll(prevPicBtn, diashowBtn, nextPicBtn); + bottom.setCenter(bottomMid); + + HBox bottomRight = new HBox(); + Button fullScreenBtn = new Button("Fullscreen"); + bottomRight.getChildren().add(fullScreenBtn); + bottom.setRight(bottomRight); + + mainPane.setBottom(bottom); + + // #### END BOTTOM PANEL #### + + primaryStage.setTitle("Photo Viewer"); + primaryStage.setScene(new Scene(mainPane, 1200, 600)); primaryStage.show(); } } diff --git a/src/de/thm/tlf/photoViewer/Picture.java b/src/de/thm/tlf/photoViewer/Picture.java new file mode 100644 index 0000000..99ad329 --- /dev/null +++ b/src/de/thm/tlf/photoViewer/Picture.java @@ -0,0 +1,23 @@ +package de.thm.tlf.photoViewer; + +import javafx.scene.image.Image; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +public class Picture { + private Image image; + + public Picture (String fileRef) { + try { + image = new Image(new FileInputStream(fileRef)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + public Image getImage() { + return image; + } +} diff --git a/src/de/thm/tlf/photoViewer/PicturePreview.java b/src/de/thm/tlf/photoViewer/PicturePreview.java new file mode 100644 index 0000000..3211b90 --- /dev/null +++ b/src/de/thm/tlf/photoViewer/PicturePreview.java @@ -0,0 +1,10 @@ +package de.thm.tlf.photoViewer; + +import java.io.FileInputStream; + +public class PicturePreview extends Picture{ + + public PicturePreview(String fileRef) { + super(fileRef); + } +} diff --git a/src/note.txt b/src/note.txt new file mode 100644 index 0000000..27fe7ad --- /dev/null +++ b/src/note.txt @@ -0,0 +1,8 @@ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle("File not found"); + alert.setContentText("File could not be located"); + alert.showAndWait().ifPresent(rs -> { + if (rs == ButtonType.OK) { + System.out.println("Pressed OK."); + } + }); \ No newline at end of file