Use a FlowPane fot the PosterMode
This commit is contained in:
parent
7dbe0d46d8
commit
4ff8b7819f
|
@ -77,7 +77,7 @@ public class Main extends Application {
|
|||
primaryStage.setResizable(false);
|
||||
primaryStage.setTitle("Project HomeFlix");
|
||||
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
|
||||
scene = new Scene(pane); // create new scene, append pane to scene
|
||||
|
|
|
@ -75,6 +75,7 @@ import javafx.scene.image.Image;
|
|||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Color;
|
||||
|
@ -159,11 +160,7 @@ public class MainWindowController {
|
|||
|
||||
// poster-mode
|
||||
@FXML private ScrollPane posterModeScrollPane;
|
||||
@FXML private AnchorPane posterModeAnchorPane;
|
||||
|
||||
private int xPos = -200;
|
||||
private int yPos = 17;
|
||||
private int xNextElement = 0;
|
||||
@FXML private FlowPane posterModeFlowPane;
|
||||
|
||||
private DBController dbController;
|
||||
private UpdateController updateController;
|
||||
|
@ -916,39 +913,8 @@ public class MainWindowController {
|
|||
posterEmenents.clear();
|
||||
posterEmenents = dbController.getPosterElementsList(); // returns a list of all PosterElements stored in the database
|
||||
|
||||
posterModeAnchorPane.getChildren().clear(); // remove all GUIElements from the posterModeAnchorPane
|
||||
|
||||
// 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++;
|
||||
}
|
||||
posterModeFlowPane.getChildren().clear(); // remove all GUIElements from the posterModeFlowPane
|
||||
posterModeFlowPane.getChildren().addAll(posterEmenents); // add all films/series as new GUIElements to the posterModeFlowPane
|
||||
}
|
||||
|
||||
// getter and setter
|
||||
|
|
|
@ -60,8 +60,6 @@ public class DBController {
|
|||
|
||||
/**
|
||||
* constructor for DBController
|
||||
* @param main the Main object
|
||||
* @param mainWindowController the MainWindowController object
|
||||
*/
|
||||
public DBController() {
|
||||
// Auto-generated constructor stub
|
||||
|
@ -76,10 +74,8 @@ public class DBController {
|
|||
}
|
||||
|
||||
/**
|
||||
* initialize the {@link DBController}
|
||||
* initialize the database connection
|
||||
* check if there is a need to create a new database
|
||||
* refresh the database
|
||||
* initialize the {@link DBController} with the database connection check if
|
||||
* there is a need to create a new database refresh the database
|
||||
*/
|
||||
public void init() {
|
||||
initDatabaseConnection();
|
||||
|
@ -116,6 +112,7 @@ public class DBController {
|
|||
+ "streamUrl, Title, Year, Rated, Released, Season, Episode ,Runtime, Genre, Director, Writer,"
|
||||
+ " Actors, Plot, Language, Country, Awards, Poster, Metascore, imdbRating, imdbVotes,"
|
||||
+ " imdbID, Type, dvd, BoxOffice, Website, Response)");
|
||||
connection.commit();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error(e);
|
||||
|
@ -151,8 +148,7 @@ public class DBController {
|
|||
}
|
||||
|
||||
/**
|
||||
* load all streams from the database to a ObservableList,
|
||||
* order entries by title
|
||||
* load all streams from the database to a ObservableList, order entries by title
|
||||
* @return a ObservableList that contains all streams from the database
|
||||
*/
|
||||
public ObservableList<FilmTabelDataType> getStreamsList() {
|
||||
|
|
|
@ -89,13 +89,8 @@ public class JFX2BtnCancelAlert {
|
|||
|
||||
JFXButton cancelBtn = new JFXButton();
|
||||
cancelBtn.setText(cancelText);
|
||||
cancelBtn.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
alert.close();
|
||||
System.exit(1);
|
||||
}
|
||||
});
|
||||
cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> alert.close());
|
||||
cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> System.exit(0));
|
||||
cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||
cancelBtn.setPrefHeight(32);
|
||||
cancelBtn.setStyle(btnStyle);
|
||||
|
|
|
@ -26,7 +26,6 @@ import com.jfoenix.controls.JFXButton;
|
|||
import com.jfoenix.controls.JFXDialogLayout;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
|
@ -59,12 +58,7 @@ public class JFXInfoAlert {
|
|||
JFXAlert<Void> alert = new JFXAlert<>(stage);
|
||||
|
||||
JFXButton button = new JFXButton("Okay");
|
||||
button.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
alert.close();
|
||||
}
|
||||
});
|
||||
button.addEventHandler(ActionEvent.ACTION, (e)-> alert.close());
|
||||
button.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||
button.setPrefHeight(32);
|
||||
button.setStyle(btnStyle);
|
||||
|
|
|
@ -18,12 +18,13 @@
|
|||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?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>
|
||||
<AnchorPane fx:id="tableModeAnchorPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0">
|
||||
<children>
|
||||
|
@ -66,11 +67,11 @@
|
|||
</AnchorPane>
|
||||
<ScrollPane fx:id="posterModeScrollPane" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0">
|
||||
<content>
|
||||
<AnchorPane fx:id="posterModeAnchorPane">
|
||||
<FlowPane fx:id="posterModeFlowPane" hgap="3.0" vgap="7.0">
|
||||
<padding>
|
||||
<Insets bottom="17.0" />
|
||||
</padding>
|
||||
</AnchorPane>
|
||||
</FlowPane>
|
||||
</content>
|
||||
</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">
|
||||
|
|
Loading…
Reference in New Issue