|
@@ -14,6 +14,7 @@ import javafx.scene.layout.FlowPane;
|
|
|
import javafx.scene.layout.GridPane;
|
|
|
import javafx.scene.control.Alert.AlertType;
|
|
|
|
|
|
+import javafx.scene.shape.Polyline;
|
|
|
import javafx.scene.text.Text;
|
|
|
import javafx.scene.text.TextFlow;
|
|
|
|
|
@@ -70,6 +71,8 @@ public class BrowserController extends Controller {
|
|
|
TextFlow errorTextBox;
|
|
|
@FXML
|
|
|
Label userLabel;
|
|
|
+ @FXML
|
|
|
+ Polyline resizerPoly;
|
|
|
|
|
|
Map<Label, Movie> map;
|
|
|
Label[] labelsMovies;
|
|
@@ -81,6 +84,15 @@ public class BrowserController extends Controller {
|
|
|
double xOffset;
|
|
|
double yOffset;
|
|
|
|
|
|
+ int imageWidth = 150;
|
|
|
+ int imageHeight = 222;
|
|
|
+
|
|
|
+ int hGap = 75;
|
|
|
+ int vGap = 25;
|
|
|
+
|
|
|
+ int detailsWidth = 300;
|
|
|
+ int filterWidth = 300;
|
|
|
+
|
|
|
public void initialize(Stage primaryStage){
|
|
|
prepare();
|
|
|
stage = primaryStage;
|
|
@@ -101,6 +113,23 @@ public class BrowserController extends Controller {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ resizerPoly.setOnMousePressed(new EventHandler<javafx.scene.input.MouseEvent>() {
|
|
|
+ @Override
|
|
|
+ public void handle(MouseEvent event) {
|
|
|
+ xOffset = primaryStage.getWidth() - event.getScreenX();
|
|
|
+ yOffset = primaryStage.getHeight() - event.getScreenY();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ resizerPoly.setOnMouseDragged(new EventHandler<MouseEvent>() {
|
|
|
+ @Override
|
|
|
+ public void handle(MouseEvent event) {
|
|
|
+
|
|
|
+ primaryStage.setWidth(event.getScreenX() + xOffset);
|
|
|
+ primaryStage.setHeight(event.getScreenY() + yOffset);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
workParams = new ConnectionParams("connection.properties");
|
|
|
if (!workParams.initilized())
|
|
@@ -135,10 +164,10 @@ public class BrowserController extends Controller {
|
|
|
|
|
|
map.put(labelsMovies[i], movies[i]);
|
|
|
|
|
|
- image.setFitHeight(222);
|
|
|
- image.setFitWidth(150);
|
|
|
+ image.setFitHeight(imageHeight);
|
|
|
+ image.setFitWidth(imageWidth);
|
|
|
labelsMovies[i].setGraphic(image);
|
|
|
- GridPane.setValignment(labelsMovies[i], VPos.CENTER);
|
|
|
+ GridPane.setValignment(labelsMovies[i], VPos.TOP);
|
|
|
GridPane.setHalignment(labelsMovies[i], HPos.CENTER);
|
|
|
Label movie = labelsMovies[i];
|
|
|
labelsMovies[i].setOnMouseClicked(e -> {
|
|
@@ -174,8 +203,11 @@ public class BrowserController extends Controller {
|
|
|
if (detailsPane.getMinWidth() < 1 || detailsViewingNow != map.get(e).id()) {
|
|
|
//detailsInfoPane = new AnchorPane();
|
|
|
//detailsPicPane.getChildren().clear();
|
|
|
+ boolean isOpen = false;
|
|
|
+ if (detailsPane.getMinWidth() > 0)
|
|
|
+ isOpen = true;
|
|
|
|
|
|
- detailsPane.setMinWidth(300);
|
|
|
+ detailsPane.setMinWidth(detailsWidth);
|
|
|
my_movie = map.get(e);
|
|
|
detailsViewingNow = my_movie.id();
|
|
|
//my_movie= my_connector.getMovieInfo(1);
|
|
@@ -197,8 +229,8 @@ public class BrowserController extends Controller {
|
|
|
|
|
|
|
|
|
ImageView image = new ImageView((my_movie.cover()));
|
|
|
- image.setFitHeight(222);
|
|
|
- image.setFitWidth(150);
|
|
|
+ image.setFitHeight(imageHeight);
|
|
|
+ image.setFitWidth(imageWidth);
|
|
|
|
|
|
//movie.
|
|
|
|
|
@@ -260,14 +292,17 @@ public class BrowserController extends Controller {
|
|
|
editMovieButton.setOnMouseClicked(null);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- gridResize();
|
|
|
+ if (isOpen)
|
|
|
+ gridResize(scrollPane.getWidth() , detailsPane.getMinWidth());
|
|
|
+ else
|
|
|
+ gridResize((scrollPane.getWidth() - detailsPane.getMinWidth()), detailsPane.getMinWidth());
|
|
|
//button.setText(Double.toString(browserPane.getWidth()));
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//detailsPicPane.getChildren().clear();
|
|
|
+ double oldDetailsWidth = detailsPane.getMinWidth();
|
|
|
detailsPane.setMinWidth(0);
|
|
|
detailsPane.setPrefWidth(0);
|
|
|
detailsPane.setMaxWidth(0);
|
|
@@ -277,7 +312,7 @@ public class BrowserController extends Controller {
|
|
|
//moviesGrid.setPrefWidth(scrollPane.getWidth()+300);
|
|
|
//moviesGrid.setPrefHeight(browserPane.getHeight());
|
|
|
//browserPane.setPrefWidth(browserPane.getWidth()+300);
|
|
|
- gridResize();
|
|
|
+ gridResize(scrollPane.getWidth() + oldDetailsWidth, oldDetailsWidth);
|
|
|
//button.setText(Double.toString(browserPane.getWidth()));
|
|
|
}
|
|
|
}
|
|
@@ -294,19 +329,21 @@ public class BrowserController extends Controller {
|
|
|
if (filterPane.getWidth() < 1)
|
|
|
{
|
|
|
//filterPane.maxWidth(300);
|
|
|
- filterPane.setMinWidth(300);
|
|
|
- filterPane.setPrefWidth(300);
|
|
|
- filterPane.setMaxWidth(300);
|
|
|
+ filterPane.setMinWidth(filterWidth);
|
|
|
+ filterPane.setPrefWidth(filterWidth);
|
|
|
+ filterPane.setMaxWidth(filterWidth);
|
|
|
//loadPosters();
|
|
|
// 300px is filter window width
|
|
|
//scrollPane.setPrefWidth(browserPane.getWidth()-300);
|
|
|
//scrollPane.setPrefHeight(browserPane.getHeight());
|
|
|
//moviesGrid.setPrefWidth(browserPane.getWidth() -300);
|
|
|
//moviesGrid.setPrefHeight(browserPane.getHeight());
|
|
|
+ gridResize(scrollPane.getWidth() - filterPane.getWidth(), filterPane.getWidth());
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ double oldFilterWidth = filterPane.getWidth();
|
|
|
filterPane.setMinWidth(0);
|
|
|
filterPane.setPrefWidth(0);
|
|
|
filterPane.setMaxWidth(0);
|
|
@@ -316,42 +353,106 @@ public class BrowserController extends Controller {
|
|
|
//scrollPane.setPrefHeight(browserPane.getHeight());
|
|
|
//moviesGrid.setPrefWidth(scrollPane.getWidth()+300);
|
|
|
//moviesGrid.setPrefHeight(browserPane.getHeight());
|
|
|
+ gridResize(scrollPane.getWidth() + oldFilterWidth, oldFilterWidth);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void gridResize(double scrollWidth, double influencePaneWidth)
|
|
|
+ {
|
|
|
+ if (!Objects.isNull(movies)) {
|
|
|
+
|
|
|
+ moviesGrid.setAlignment(Pos.TOP_CENTER);
|
|
|
+ moviesGrid.setHgap(hGap);
|
|
|
+ moviesGrid.setVgap(vGap);
|
|
|
+
|
|
|
+ int cols = (((int) scrollWidth) + (int) moviesGrid.getHgap()) / (imageWidth + (int) moviesGrid.getHgap());
|
|
|
+
|
|
|
+ int rows;
|
|
|
+ try {
|
|
|
+ rows = movies.length / cols;
|
|
|
+ }
|
|
|
+ catch (ArithmeticException ex)
|
|
|
+ {
|
|
|
+ cols = (((int) (scrollWidth + influencePaneWidth)) + (int) moviesGrid.getHgap()) / (imageWidth + (int) moviesGrid.getHgap());
|
|
|
+ rows = movies.length / cols;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (movies.length % cols != 0)
|
|
|
+ rows++;
|
|
|
+
|
|
|
+ if (imageHeight * rows + (moviesGrid.getVgap()*(rows - 1)) < scrollPane.getHeight())
|
|
|
+ moviesGrid.setMinHeight(scrollPane.getHeight());
|
|
|
+ else
|
|
|
+ moviesGrid.setMinHeight(imageHeight * rows + (moviesGrid.getVgap()*(rows - 1)));
|
|
|
+
|
|
|
+ System.out.println("grid height:" + moviesGrid.getHeight() );
|
|
|
+ System.out.println("scroll width:" + scrollWidth );
|
|
|
+ System.out.println("cols: " + cols);
|
|
|
+ System.out.println("rows: " + rows);
|
|
|
+
|
|
|
+ //System.out.println("flow height:" + moviesGrid.getHeight() );
|
|
|
+ moviesGrid.setMaxWidth(scrollWidth);
|
|
|
+ moviesGrid.setPrefWidth(scrollWidth);
|
|
|
+
|
|
|
+ moviesGrid.getChildren().clear();
|
|
|
+ int k = 0;
|
|
|
+ for (int i = 0; i < movies.length; i++) {
|
|
|
+
|
|
|
+ moviesGrid.getChildren().add(labelsMovies[i]);
|
|
|
+
|
|
|
+ }
|
|
|
+ moviesGrid.autosize();
|
|
|
+
|
|
|
}
|
|
|
- gridResize();
|
|
|
}
|
|
|
|
|
|
- public void gridResize()
|
|
|
+ public void gridResize( )
|
|
|
{
|
|
|
if (!Objects.isNull(movies)) {
|
|
|
- int colsAdd = ((int) scrollPane.getWidth()) / 200 - 2;
|
|
|
- int cols = colsAdd + 2;
|
|
|
|
|
|
- int rows = movies.length / cols + 1;
|
|
|
- if (242 * rows < scrollPane.getHeight())
|
|
|
+ moviesGrid.setAlignment(Pos.TOP_CENTER);
|
|
|
+ moviesGrid.setHgap(hGap);
|
|
|
+ moviesGrid.setVgap(vGap);
|
|
|
+
|
|
|
+ int cols = (((int) scrollPane.getWidth()) + (int) moviesGrid.getHgap()) / (imageWidth + (int) moviesGrid.getHgap());
|
|
|
+
|
|
|
+ int rows;
|
|
|
+ try {
|
|
|
+ rows = movies.length / cols;
|
|
|
+ }
|
|
|
+ catch (ArithmeticException ex)
|
|
|
+ {
|
|
|
+ //this is unreachable
|
|
|
+ cols = (((int) scrollPane.getWidth() + 300) + (int) moviesGrid.getHgap()) / (imageWidth + (int) moviesGrid.getHgap());
|
|
|
+ rows = movies.length / cols;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (movies.length % cols != 0)
|
|
|
+ rows++;
|
|
|
+
|
|
|
+ if (imageHeight * rows + (moviesGrid.getVgap()*(rows - 1)) < scrollPane.getHeight())
|
|
|
moviesGrid.setMinHeight(scrollPane.getHeight());
|
|
|
else
|
|
|
- moviesGrid.setMinHeight(242 * rows);
|
|
|
+ moviesGrid.setMinHeight(imageHeight * rows + (moviesGrid.getVgap()*(rows - 1)));
|
|
|
+
|
|
|
+ //System.out.println("scroll width:" + scrollWidth );
|
|
|
+ System.out.println("cols: " + cols);
|
|
|
+ System.out.println("rows: " + rows);
|
|
|
+
|
|
|
+ //System.out.println("flow height:" + moviesGrid.getHeight() );
|
|
|
moviesGrid.setMaxWidth(scrollPane.getWidth());
|
|
|
moviesGrid.setPrefWidth(scrollPane.getWidth());
|
|
|
|
|
|
- moviesGrid.setAlignment(Pos.CENTER);
|
|
|
- moviesGrid.setHgap(75);
|
|
|
- moviesGrid.setVgap(25);
|
|
|
-
|
|
|
moviesGrid.getChildren().clear();
|
|
|
int k = 0;
|
|
|
- for (int i = 0; i < rows; i++) {
|
|
|
- for (int j = 0; j < cols; j++) {
|
|
|
- try {
|
|
|
- moviesGrid.getChildren().add(labelsMovies[k]);
|
|
|
- } catch (Exception err) {
|
|
|
- k++;
|
|
|
- }
|
|
|
- if (k == movies.length - 1)
|
|
|
- break;
|
|
|
- k++;
|
|
|
- }
|
|
|
+ for (int i = 0; i < movies.length; i++) {
|
|
|
+
|
|
|
+ moviesGrid.getChildren().add(labelsMovies[i]);
|
|
|
+
|
|
|
}
|
|
|
+ moviesGrid.autosize();
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -380,7 +481,7 @@ public class BrowserController extends Controller {
|
|
|
Parent root = loader.load();
|
|
|
addWindow = loader.getController();
|
|
|
addWindow.stage = new Stage();
|
|
|
- addWindow.stage.setScene(new Scene(root, 377, 635));
|
|
|
+ addWindow.stage.setScene(new Scene(root, 610, 540));
|
|
|
addWindow.stage.setUserData(loader);
|
|
|
addWindow.open(this);
|
|
|
|