|
@@ -7,6 +7,7 @@ import javafx.geometry.Pos;
|
|
|
import javafx.geometry.VPos;
|
|
|
import javafx.scene.control.*;
|
|
|
import javafx.scene.image.ImageView;
|
|
|
+import javafx.scene.image.Image;
|
|
|
import javafx.scene.input.MouseEvent;
|
|
|
import javafx.scene.layout.AnchorPane;
|
|
|
import javafx.scene.layout.FlowPane;
|
|
@@ -41,7 +42,8 @@ public class BrowserController extends Controller {
|
|
|
@FXML
|
|
|
TextFlow detailsContent;
|
|
|
@FXML
|
|
|
- AnchorPane detailsPicPane;
|
|
|
+ //AnchorPane detailsPicPane;
|
|
|
+ ImageView detailsPicPane;
|
|
|
@FXML
|
|
|
AnchorPane filterPane;
|
|
|
@FXML
|
|
@@ -166,14 +168,16 @@ public class BrowserController extends Controller {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private int detailsViewingNow;
|
|
|
public void openDetails(Label e)
|
|
|
{
|
|
|
- if (detailsPane.getMinWidth() < 1) {
|
|
|
+ if (detailsPane.getMinWidth() < 1 || detailsViewingNow != map.get(e).id()) {
|
|
|
//detailsInfoPane = new AnchorPane();
|
|
|
//detailsPicPane.getChildren().clear();
|
|
|
|
|
|
detailsPane.setMinWidth(300);
|
|
|
my_movie = map.get(e);
|
|
|
+ detailsViewingNow = my_movie.id();
|
|
|
//my_movie= my_connector.getMovieInfo(1);
|
|
|
|
|
|
//detailsContent.Text(my_movie.name() + "\n" + my_movie.year() + "\n" + my_movie.duration() + "\n" + my_movie.genre() + "\n" + my_movie.description());
|
|
@@ -186,7 +190,7 @@ public class BrowserController extends Controller {
|
|
|
detailsContent.getChildren().clear();
|
|
|
detailsContent.getChildren().add(info);
|
|
|
|
|
|
- detailsPicPane.getChildren().clear();
|
|
|
+ detailsPicPane.setImage(null);
|
|
|
//detailsPane.setMaxWidth(300);
|
|
|
//Label movie = e;
|
|
|
ImageView detailsImage = new ImageView();
|
|
@@ -196,11 +200,34 @@ public class BrowserController extends Controller {
|
|
|
image.setFitHeight(222);
|
|
|
image.setFitWidth(150);
|
|
|
|
|
|
- detailsImage = ((ImageView) image);
|
|
|
- detailsImage.setX((detailsPane.getWidth() - detailsImage.getFitWidth()) / 2 + 100);
|
|
|
- detailsImage.setY(0);
|
|
|
- //movie.
|
|
|
- detailsPicPane.getChildren().add(detailsImage);
|
|
|
+ //movie.
|
|
|
+
|
|
|
+
|
|
|
+ detailsPicPane.setImage(my_movie.cover());
|
|
|
+
|
|
|
+ Image img = detailsPicPane.getImage();
|
|
|
+ if (img != null) {
|
|
|
+ double w = 0;
|
|
|
+ double h = 0;
|
|
|
+
|
|
|
+ double ratioX = detailsPicPane.getFitWidth() / img.getWidth();
|
|
|
+ double ratioY = detailsPicPane.getFitHeight() / img.getHeight();
|
|
|
+
|
|
|
+ double reducCoeff = 0;
|
|
|
+ if(ratioX >= ratioY) {
|
|
|
+ reducCoeff = ratioY;
|
|
|
+ } else {
|
|
|
+ reducCoeff = ratioX;
|
|
|
+ }
|
|
|
+
|
|
|
+ w = img.getWidth() * reducCoeff;
|
|
|
+ h = img.getHeight() * reducCoeff;
|
|
|
+
|
|
|
+ detailsPicPane.setX((detailsPicPane.getFitWidth() - w) / 2);
|
|
|
+ detailsPicPane.setY((detailsPicPane.getFitHeight() - h) / 2);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 300px is details window width
|
|
|
//scrollPane.setPrefWidth(browserPane.getWidth()-300);
|
|
|
//scrollPane.setPrefHeight(browserPane.getHeight());
|
|
@@ -240,7 +267,7 @@ public class BrowserController extends Controller {
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- detailsPicPane.getChildren().clear();
|
|
|
+ //detailsPicPane.getChildren().clear();
|
|
|
detailsPane.setMinWidth(0);
|
|
|
detailsPane.setPrefWidth(0);
|
|
|
detailsPane.setMaxWidth(0);
|
|
@@ -257,7 +284,7 @@ public class BrowserController extends Controller {
|
|
|
|
|
|
public void closeDetails()
|
|
|
{
|
|
|
- detailsPicPane.getChildren().clear();
|
|
|
+ //detailsPicPane.getChildren().clear();
|
|
|
detailsPane.setMinWidth(1);
|
|
|
detailsPane.setPrefWidth(1);
|
|
|
}
|