smmdb course images are now correctly scaled
* added a scaling function for smm course images * smm course images are scrollable now
This commit is contained in:
parent
a1bab241b6
commit
3289bb4aed
|
@ -650,33 +650,25 @@ public class MainWindowController {
|
||||||
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) {
|
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) {
|
||||||
selected = courseTreeTable.getSelectionModel().getSelectedIndex(); // get selected item
|
selected = courseTreeTable.getSelectionModel().getSelectedIndex(); // get selected item
|
||||||
|
|
||||||
// FIXME if a item is selected and you change the sorting,you can't select a new
|
// FIXME if a item is selected and you change the sorting,you can't select a new item
|
||||||
// item
|
|
||||||
id = idColumn.getCellData(selected); // get name of selected item
|
id = idColumn.getCellData(selected); // get name of selected item
|
||||||
|
|
||||||
for (int i = 0; i < courses.size(); i++) {
|
for (int i = 0; i < courses.size(); i++) {
|
||||||
if (courses.get(i).getId() == id) {
|
if (courses.get(i).getId() == id) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
URL url = new URL("https://smmdb.ddns.net/courseimg/" + id + "_full?v=1");
|
URL url = new URL("https://smmdb.ddns.net/courseimg/" + id + "_full?v=1");
|
||||||
Image image = new Image(url.toURI().toString());
|
Image sourceImage = new Image(url.toURI().toString());
|
||||||
|
|
||||||
System.out.println("Bild Höhe: " + image.getHeight() + ",Breite: " + image.getWidth());
|
// scale image to 142px
|
||||||
System.out.println("Imageview Höhe: " + smmdbImageView.getFitHeight() + ",Breite: " + smmdbImageView.getFitWidth());
|
double scalefactor = 142 / sourceImage.getHeight(); // calculate scaling factor
|
||||||
|
int nWidth = (int) Math.rint(scalefactor * sourceImage.getWidth());
|
||||||
|
int nHeight = (int) Math.rint(scalefactor * sourceImage.getHeight());
|
||||||
|
Image scaledImage = new Image(url.toURI().toString(), nWidth, nHeight, false, true); // generate a scaled image
|
||||||
|
|
||||||
// scale image to 148px Height
|
smmdbImageView.setFitWidth(scaledImage.getWidth()); // set ImageView width to the image width
|
||||||
double scalefactor = 148 / image.getHeight();
|
smmdbImageView.setImage(scaledImage); // set imageview to image
|
||||||
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) {
|
} catch (MalformedURLException | URISyntaxException e) {
|
||||||
e.printStackTrace();
|
LOGGER.warn("There was either a problem or no image!", e);
|
||||||
smmdbImageView.setImage(close_black);
|
smmdbImageView.setImage(close_black);
|
||||||
}
|
}
|
||||||
addCourseDescription(courses.get(i));
|
addCourseDescription(courses.get(i));
|
||||||
|
@ -689,11 +681,17 @@ public class MainWindowController {
|
||||||
@Override
|
@Override
|
||||||
public void handle(MouseEvent mouseEvent) {
|
public void handle(MouseEvent mouseEvent) {
|
||||||
if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
|
if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
|
||||||
try {
|
Thread thread = new Thread(new Runnable() {
|
||||||
Desktop.getDesktop().browse(new URI("https://github.com/Seil0/cemu_UI/issues/3"));
|
@Override
|
||||||
} catch (IOException | URISyntaxException e) {
|
public void run() {
|
||||||
e.printStackTrace();
|
try {
|
||||||
}
|
Desktop.getDesktop().browse(new URI("https://github.com/Seil0/cemu_UI/issues/3"));
|
||||||
|
} catch (IOException | URISyntaxException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
thread.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -183,7 +183,7 @@
|
||||||
<children>
|
<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" />
|
<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" />
|
<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" />
|
||||||
<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">
|
<ScrollPane fx:id="smmdbScrollPane" layoutX="436.0" layoutY="190.0" prefHeight="281.0" prefWidth="279.0" AnchorPane.bottomAnchor="91.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="190.0">
|
||||||
<content>
|
<content>
|
||||||
<TextFlow fx:id="smmdbTextFlow" maxWidth="265.0" prefWidth="265.0" />
|
<TextFlow fx:id="smmdbTextFlow" maxWidth="265.0" prefWidth="265.0" />
|
||||||
</content>
|
</content>
|
||||||
|
@ -198,9 +198,9 @@
|
||||||
<Font size="14.0" />
|
<Font size="14.0" />
|
||||||
</font>
|
</font>
|
||||||
</Label>
|
</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">
|
<ScrollPane fx:id="smmdbImageViewScrollPane" layoutX="436.0" layoutY="14.0" prefHeight="160.0" prefWidth="279.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0">
|
||||||
<content>
|
<content>
|
||||||
<ImageView fx:id="smmdbImageView" fitHeight="148.0" fitWidth="277.0" pickOnBounds="true" preserveRatio="true" />
|
<ImageView fx:id="smmdbImageView" fitHeight="158.0" fitWidth="277.0" pickOnBounds="true" preserveRatio="true" />
|
||||||
</content>
|
</content>
|
||||||
</ScrollPane>
|
</ScrollPane>
|
||||||
</children>
|
</children>
|
||||||
|
|
Loading…
Reference in New Issue