diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index e67a35e..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -ImageTagger-Solution \ No newline at end of file diff --git a/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/MainPageController.kt b/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/MainPageController.kt index a3c8cf4..8a12028 100644 --- a/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/MainPageController.kt +++ b/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/MainPageController.kt @@ -1,6 +1,7 @@ package dev.nuculabs.imagetagger.ui import dev.nuculabs.imagetagger.core.AnalyzedImage +import dev.nuculabs.imagetagger.ui.controls.ImageTagsDisplayMode import dev.nuculabs.imagetagger.ui.controls.ImageTagsEntryControl import dev.nuculabs.imagetagger.ui.controls.ImageTagsSessionHeader import javafx.application.Platform @@ -58,6 +59,8 @@ class MainPageController { */ private var isCurrentTagsOperationCancelled: Boolean = false + private var predictedImages: MutableList = ArrayList() + @FXML private lateinit var progressBar: ProgressBar @@ -148,7 +151,11 @@ class MainPageController { fun addNewImagePredictionEntry( analyzedImage: AnalyzedImage, ) { - verticalBox.children.add(ImageTagsEntryControl(analyzedImage)) + val control = ImageTagsEntryControl(analyzedImage) + // TODO add default tag mode + control.setTagsDisplayMode(ImageTagsDisplayMode.CommaSeparated) + verticalBox.children.add(control) + predictedImages.add(control) verticalBox.children.add(Separator()) } diff --git a/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/controls/ImageTagsDisplayMode.kt b/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/controls/ImageTagsDisplayMode.kt new file mode 100644 index 0000000..e341477 --- /dev/null +++ b/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/controls/ImageTagsDisplayMode.kt @@ -0,0 +1,9 @@ +package dev.nuculabs.imagetagger.ui.controls + +/** + * Determines how tags are displayed + */ +enum class ImageTagsDisplayMode { + CommaSeparated, + HashTags +} \ No newline at end of file diff --git a/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/controls/ImageTagsEntryControl.kt b/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/controls/ImageTagsEntryControl.kt index e35dca8..dc59402 100644 --- a/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/controls/ImageTagsEntryControl.kt +++ b/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/controls/ImageTagsEntryControl.kt @@ -40,6 +40,16 @@ class ImageTagsEntryControl(private val image: AnalyzedImage) : HBox() { @FXML private lateinit var predictedImageTags: TextArea + /** + * Holds the tags. + */ + private var tags: List = ArrayList(); + + /** + * Sets the default image tags display mode. + */ + private var tagsDisplayMode: ImageTagsDisplayMode = ImageTagsDisplayMode.CommaSeparated + /** * The file name label. */ @@ -122,8 +132,35 @@ class ImageTagsEntryControl(private val image: AnalyzedImage) : HBox() { * * @param predictions The prediction list. */ - private fun setTags(predictions: List) { - predictedImageTags.text = predictions.joinToString { it } + fun setTags(predictions: List) { + tags = predictions + updateTags() + } + + /** + * Sets the tags display mode. + * + * @param mode The image tags display mode. + */ + fun setTagsDisplayMode(mode: ImageTagsDisplayMode) { + tagsDisplayMode = mode + updateTags() + } + + /** + * Updates the tags text. + */ + private fun updateTags() { + predictedImageTags.text = when (tagsDisplayMode) { + ImageTagsDisplayMode.CommaSeparated -> { + tags.joinToString { it } + } + ImageTagsDisplayMode.HashTags -> { + tags.joinToString(separator = " ") { + "#${it}" + } + } + } } /**