Use a FlowPane fot the PosterMode

This commit is contained in:
Jannik 2019-06-15 11:09:59 +02:00
parent 7dbe0d46d8
commit 4ff8b7819f
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
6 changed files with 18 additions and 66 deletions

View File

@ -77,7 +77,7 @@ public class Main extends Application {
primaryStage.setResizable(false); primaryStage.setResizable(false);
primaryStage.setTitle("Project HomeFlix"); primaryStage.setTitle("Project HomeFlix");
primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/icons/Homeflix_Icon_64x64.png"))); //adds application icon primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/icons/Homeflix_Icon_64x64.png"))); //adds application icon
primaryStage.setOnCloseRequest(event -> System.exit(1)); primaryStage.setOnCloseRequest(event -> System.exit(0));
// generate window // generate window
scene = new Scene(pane); // create new scene, append pane to scene scene = new Scene(pane); // create new scene, append pane to scene

View File

@ -75,6 +75,7 @@ import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
@ -159,11 +160,7 @@ public class MainWindowController {
// poster-mode // poster-mode
@FXML private ScrollPane posterModeScrollPane; @FXML private ScrollPane posterModeScrollPane;
@FXML private AnchorPane posterModeAnchorPane; @FXML private FlowPane posterModeFlowPane;
private int xPos = -200;
private int yPos = 17;
private int xNextElement = 0;
private DBController dbController; private DBController dbController;
private UpdateController updateController; private UpdateController updateController;
@ -916,40 +913,9 @@ public class MainWindowController {
posterEmenents.clear(); posterEmenents.clear();
posterEmenents = dbController.getPosterElementsList(); // returns a list of all PosterElements stored in the database posterEmenents = dbController.getPosterElementsList(); // returns a list of all PosterElements stored in the database
posterModeAnchorPane.getChildren().clear(); // remove all GUIElements from the posterModeAnchorPane posterModeFlowPane.getChildren().clear(); // remove all GUIElements from the posterModeFlowPane
posterModeFlowPane.getChildren().addAll(posterEmenents); // add all films/series as new GUIElements to the posterModeFlowPane
// reset the position
xPos = -200;
yPos = 17;
xNextElement = 0;
// add all films/series as new GUIElements to the posterModeAnchorPane
for(PosterModeElement element : posterEmenents) {
generatePosition();
element.setLayoutX(xPos);
element.setLayoutY(yPos);
posterModeAnchorPane.getChildren().add(element);
}
} }
/**
* xMaxElements based on window width -36
* calculates how many games can be displayed in one row
*/
private void generatePosition() {
int xMaxElements = (int) Math.floor((mainAnchorPane.getWidth() - 36) / 217);
if(xNextElement >= xMaxElements){
// oldXPosHelper = xNextElement; // only needed if window resizing is allowed
xPos = 17;
yPos = yPos + 345;
xNextElement = 1;
}else{
xPos = xPos + 217;
xNextElement++;
}
}
// getter and setter // getter and setter

View File

@ -60,8 +60,6 @@ public class DBController {
/** /**
* constructor for DBController * constructor for DBController
* @param main the Main object
* @param mainWindowController the MainWindowController object
*/ */
public DBController() { public DBController() {
// Auto-generated constructor stub // Auto-generated constructor stub
@ -76,10 +74,8 @@ public class DBController {
} }
/** /**
* initialize the {@link DBController} * initialize the {@link DBController} with the database connection check if
* initialize the database connection * there is a need to create a new database refresh the database
* check if there is a need to create a new database
* refresh the database
*/ */
public void init() { public void init() {
initDatabaseConnection(); initDatabaseConnection();
@ -116,6 +112,7 @@ public class DBController {
+ "streamUrl, Title, Year, Rated, Released, Season, Episode ,Runtime, Genre, Director, Writer," + "streamUrl, Title, Year, Rated, Released, Season, Episode ,Runtime, Genre, Director, Writer,"
+ " Actors, Plot, Language, Country, Awards, Poster, Metascore, imdbRating, imdbVotes," + " Actors, Plot, Language, Country, Awards, Poster, Metascore, imdbRating, imdbVotes,"
+ " imdbID, Type, dvd, BoxOffice, Website, Response)"); + " imdbID, Type, dvd, BoxOffice, Website, Response)");
connection.commit();
stmt.close(); stmt.close();
} catch (SQLException e) { } catch (SQLException e) {
LOGGER.error(e); LOGGER.error(e);
@ -151,8 +148,7 @@ public class DBController {
} }
/** /**
* load all streams from the database to a ObservableList, * load all streams from the database to a ObservableList, order entries by title
* order entries by title
* @return a ObservableList that contains all streams from the database * @return a ObservableList that contains all streams from the database
*/ */
public ObservableList<FilmTabelDataType> getStreamsList() { public ObservableList<FilmTabelDataType> getStreamsList() {

View File

@ -89,13 +89,8 @@ public class JFX2BtnCancelAlert {
JFXButton cancelBtn = new JFXButton(); JFXButton cancelBtn = new JFXButton();
cancelBtn.setText(cancelText); cancelBtn.setText(cancelText);
cancelBtn.setOnAction(new EventHandler<ActionEvent>() { cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> alert.close());
@Override cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> System.exit(0));
public void handle(ActionEvent event) {
alert.close();
System.exit(1);
}
});
cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
cancelBtn.setPrefHeight(32); cancelBtn.setPrefHeight(32);
cancelBtn.setStyle(btnStyle); cancelBtn.setStyle(btnStyle);

View File

@ -26,7 +26,6 @@ import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXDialogLayout; import com.jfoenix.controls.JFXDialogLayout;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -59,12 +58,7 @@ public class JFXInfoAlert {
JFXAlert<Void> alert = new JFXAlert<>(stage); JFXAlert<Void> alert = new JFXAlert<>(stage);
JFXButton button = new JFXButton("Okay"); JFXButton button = new JFXButton("Okay");
button.setOnAction(new EventHandler<ActionEvent>() { button.addEventHandler(ActionEvent.ACTION, (e)-> alert.close());
@Override
public void handle(ActionEvent event) {
alert.close();
}
});
button.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); button.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
button.setPrefHeight(32); button.setPrefHeight(32);
button.setStyle(btnStyle); button.setStyle(btnStyle);

View File

@ -18,12 +18,13 @@
<?import javafx.scene.image.Image?> <?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?> <?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<?import javafx.scene.text.TextFlow?> <?import javafx.scene.text.TextFlow?>
<AnchorPane fx:id="mainAnchorPane" prefHeight="600.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="kellerkinder.HomeFlix.application.MainWindowController"> <AnchorPane fx:id="mainAnchorPane" prefHeight="600.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="kellerkinder.HomeFlix.application.MainWindowController">
<children> <children>
<AnchorPane fx:id="tableModeAnchorPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0"> <AnchorPane fx:id="tableModeAnchorPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0">
<children> <children>
@ -65,13 +66,13 @@
</children> </children>
</AnchorPane> </AnchorPane>
<ScrollPane fx:id="posterModeScrollPane" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0"> <ScrollPane fx:id="posterModeScrollPane" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0">
<content> <content>
<AnchorPane fx:id="posterModeAnchorPane"> <FlowPane fx:id="posterModeFlowPane" hgap="3.0" vgap="7.0">
<padding> <padding>
<Insets bottom="17.0" /> <Insets bottom="17.0" />
</padding> </padding>
</AnchorPane> </FlowPane>
</content> </content>
</ScrollPane> </ScrollPane>
<ScrollPane fx:id="settingsScrollPane" prefHeight="568.0" prefWidth="800.0" style="-fx-background: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0"> <ScrollPane fx:id="settingsScrollPane" prefHeight="568.0" prefWidth="800.0" style="-fx-background: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0">
<content> <content>