Browse Source

Use a FlowPane fot the PosterMode

pull/12/head
Jannik 3 years ago
parent
commit
4ff8b7819f
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 2
      src/main/java/kellerkinder/HomeFlix/application/Main.java
  2. 42
      src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java
  3. 12
      src/main/java/kellerkinder/HomeFlix/controller/DBController.java
  4. 9
      src/main/java/org/kellerkinder/Alerts/JFX2BtnCancelAlert.java
  5. 8
      src/main/java/org/kellerkinder/Alerts/JFXInfoAlert.java
  6. 11
      src/main/resources/fxml/MainWindow.fxml

2
src/main/java/kellerkinder/HomeFlix/application/Main.java

@ -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

42
src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java

@ -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

12
src/main/java/kellerkinder/HomeFlix/controller/DBController.java

@ -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() {

9
src/main/java/org/kellerkinder/Alerts/JFX2BtnCancelAlert.java

@ -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);

8
src/main/java/org/kellerkinder/Alerts/JFXInfoAlert.java

@ -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);

11
src/main/resources/fxml/MainWindow.fxml

@ -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>
@ -65,13 +66,13 @@
</children>
</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">
<content>
<FlowPane fx:id="posterModeFlowPane" hgap="3.0" vgap="7.0">
<padding>
<Insets bottom="17.0" />
</padding>
</AnchorPane>
</content>
</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">
<content>

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close