display image file name in row

This commit is contained in:
Denis-Cosmin NUTIU 2024-04-06 13:02:30 +03:00
parent 526e6dc2b9
commit cfaa292179
2 changed files with 14 additions and 3 deletions

View file

@ -1,6 +1,8 @@
package dev.nuculabs.imagetagger.ui.controls
import javafx.fxml.FXML
import javafx.fxml.FXMLLoader
import javafx.scene.control.Label
import javafx.scene.control.TextArea
import javafx.scene.image.Image
import javafx.scene.image.ImageView
@ -29,6 +31,12 @@ class ImageTagsEntryControl
@FXML
private lateinit var predictedImageTags: TextArea
/**
* The file name label.
*/
@FXML
private lateinit var fileNameLabel: Label
init {
val resource = ImageTagsEntryControl::class.java.getResource("image-tags-entry.fxml")
logger.fine("Using resource URL: $resource")
@ -45,21 +53,23 @@ class ImageTagsEntryControl
}
/**
* Getter for the image view.
* Setter for predicted tags text.
*
* @param predictions The prediction list.
*/
fun setText(predictions: List<String>) {
predictedImageTags.text = predictions.joinToString { it }
predictedImageTags.text = predictions.joinToString { it }
}
/**
* Setter for setting the image.
*/
fun setImage(imagePath: String) {
File(imagePath).inputStream().use {
val file = File(imagePath)
file.inputStream().use {
imageView.image = Image(it, 244.0, 244.0, true, true)
imageView.isCache = true
}
fileNameLabel.text = "File: ${file.name}"
}
}

View file

@ -17,6 +17,7 @@
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</padding>
<Label fx:id="fileNameLabel" />
<Label text="Predicted tags:"/>
<TextArea fx:id="predictedImageTags" editable="false" wrapText="true" prefColumnCount="20"/>
</VBox>