Use a FlowPane fot the PosterMode
This commit is contained in:
@ -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,40 +913,9 @@ 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);
|
||||
}
|
||||
|
||||
posterModeFlowPane.getChildren().clear(); // remove all GUIElements from the posterModeFlowPane
|
||||
posterModeFlowPane.getChildren().addAll(posterEmenents); // add all films/series as new GUIElements to the posterModeFlowPane
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
|
@ -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() {
|
||||
|
Reference in New Issue
Block a user