smmdb image is now in a scrollpane

* smmdb image is now in a scrollpane, now we can resize the image to the correct height
This commit is contained in:
Jannik 2017-12-11 11:31:39 +01:00
parent e92a43a37e
commit 02d7cb6a3e
2 changed files with 24 additions and 2 deletions

View File

@ -194,6 +194,9 @@ public class MainWindowController {
@FXML
private ScrollPane smmdbScrollPane;
@FXML
private ScrollPane smmdbImageViewScrollPane;
@FXML
private VBox sideMenuVBox;
@ -654,8 +657,23 @@ public class MainWindowController {
for (int i = 0; i < courses.size(); i++) {
if (courses.get(i).getId() == id) {
try {
URL url = new URL("https://smmdb.ddns.net/courseimg/" + id + "_full?v=1");
Image image = new Image(url.toURI().toString());
System.out.println("Bild Höhe: " + image.getHeight() + ",Breite: " + image.getWidth());
System.out.println("Imageview Höhe: " + smmdbImageView.getFitHeight() + ",Breite: " + smmdbImageView.getFitWidth());
// scale image to 148px Height
double scalefactor = 148 / image.getHeight();
System.out.println("Skalierung: " + scalefactor);
int nWidth = (int) Math.rint(scalefactor * image.getWidth());
int nHeight = (int) Math.rint(scalefactor * image.getHeight());
System.out.println("Bild NEU Höhe: " + nHeight + ",Breite: " + nWidth);
smmdbImageView.setFitWidth(image.getWidth()); // set ImageView width to the image width
smmdbImageView.setImage(image);
} catch (MalformedURLException | URISyntaxException e) {
e.printStackTrace();

View File

@ -149,8 +149,7 @@
<children>
<JFXTextField fx:id="courseSearchTextFiled" layoutX="14.0" layoutY="14.0" onAction="#courseSearchTextFiledAction" prefHeight="25.0" prefWidth="405.0" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0" />
<JFXTreeTableView fx:id="courseTreeTable" layoutX="14.0" layoutY="53.0" prefHeight="494.0" prefWidth="405.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="53.0" />
<ImageView fx:id="smmdbImageView" fitHeight="150.0" fitWidth="267.0" layoutX="436.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0" />
<ScrollPane fx:id="smmdbScrollPane" layoutX="436.0" layoutY="181.0" prefHeight="290.0" prefWidth="267.0" AnchorPane.bottomAnchor="91.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0">
<ScrollPane fx:id="smmdbScrollPane" layoutX="436.0" layoutY="181.0" prefHeight="290.0" prefWidth="279.0" AnchorPane.bottomAnchor="91.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="181.0">
<content>
<TextFlow fx:id="smmdbTextFlow" maxWidth="265.0" prefWidth="265.0" />
</content>
@ -165,6 +164,11 @@
<Font size="14.0" />
</font>
</Label>
<ScrollPane fx:id="smmdbImageViewScrollPane" layoutX="436.0" layoutY="14.0" prefHeight="150.0" prefWidth="279.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0">
<content>
<ImageView fx:id="smmdbImageView" fitHeight="148.0" fitWidth="277.0" pickOnBounds="true" preserveRatio="true" />
</content>
</ScrollPane>
</children>
</AnchorPane>
<JFXButton fx:id="playBtn" buttonType="RAISED" layoutX="396.0" maxHeight="28.0" minWidth="100.0" onAction="#playBtnAction" ripplerFill="#00aacc" text="play" textAlignment="CENTER" visible="false" AnchorPane.bottomAnchor="12.0">