Created first version of GUI-Design
This commit is contained in:
parent
363a1ad63f
commit
82c157e879
8
out/production/PhotoViewer/note.txt
Normal file
8
out/production/PhotoViewer/note.txt
Normal file
@ -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.");
|
||||
}
|
||||
});
|
BIN
pic/image1.jpg
Normal file
BIN
pic/image1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
pic/image2.jpg
Normal file
BIN
pic/image2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
pic/image3.jpg
Normal file
BIN
pic/image3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
@ -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();
|
||||
}
|
||||
}
|
||||
|
23
src/de/thm/tlf/photoViewer/Picture.java
Normal file
23
src/de/thm/tlf/photoViewer/Picture.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
10
src/de/thm/tlf/photoViewer/PicturePreview.java
Normal file
10
src/de/thm/tlf/photoViewer/PicturePreview.java
Normal file
@ -0,0 +1,10 @@
|
||||
package de.thm.tlf.photoViewer;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class PicturePreview extends Picture{
|
||||
|
||||
public PicturePreview(String fileRef) {
|
||||
super(fileRef);
|
||||
}
|
||||
}
|
8
src/note.txt
Normal file
8
src/note.txt
Normal file
@ -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.");
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user