Browse Source
Working on some cleanup. Moved setup logic for the image tile into it's own class. Reduced the logic in the factory. Need to work on context menus and selectable items in the pane next. Might have to be done with a custom TilePane that allows selection.
master
Working on some cleanup. Moved setup logic for the image tile into it's own class. Reduced the logic in the factory. Need to work on context menus and selectable items in the pane next. Might have to be done with a custom TilePane that allows selection.
master
Drew Short
10 years ago
10 changed files with 88 additions and 80 deletions
-
1cli/pom.xml
-
1engine/pom.xml
-
4engine/src/main/scala/com/sothr/imagetools/engine/ConcurrentEngine.scala
-
3engine/src/main/scala/com/sothr/imagetools/engine/hash/AHash.scala
-
3engine/src/main/scala/com/sothr/imagetools/engine/hash/PHash.scala
-
1gui/pom.xml
-
5gui/src/main/resources/fxml/mainapp/MainApp.fxml
-
68gui/src/main/scala/com/sothr/imagetools/ui/component/ImageTile.scala
-
62gui/src/main/scala/com/sothr/imagetools/ui/component/ImageTileFactory.scala
-
20gui/src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala
@ -1,22 +1,76 @@ |
|||
package com.sothr.imagetools.ui.component |
|||
|
|||
import java.io.FileInputStream |
|||
import javafx.event.EventHandler |
|||
import javafx.geometry.Pos |
|||
import javafx.scene.control.{Tooltip, Label} |
|||
import javafx.scene.image.{ImageView} |
|||
import javafx.scene.input.MouseEvent |
|||
import javafx.scene.layout.VBox |
|||
|
|||
import com.sothr.imagetools.engine.image.Image |
|||
import grizzled.slf4j.Logging |
|||
import resource._ |
|||
|
|||
/** |
|||
* ImageTile class that is a special VBox |
|||
* |
|||
* Created by drew on 8/22/14. |
|||
*/ |
|||
class ImageTile extends VBox { |
|||
var imageData: Image = null |
|||
class ImageTile(thumbnailWidth: Integer, image: com.sothr.imagetools.engine.image.Image) extends VBox with Logging { |
|||
val imageData: com.sothr.imagetools.engine.image.Image = image |
|||
val preferedTileSize = (thumbnailWidth + 32).toDouble |
|||
//set tile size |
|||
this.setPrefSize(preferedTileSize, preferedTileSize) |
|||
this.setMinSize(preferedTileSize, preferedTileSize) |
|||
this.setMaxSize(preferedTileSize, preferedTileSize) |
|||
|
|||
def getImageData: Image = { |
|||
imageData |
|||
this.setAlignment(Pos.TOP_CENTER) |
|||
this.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler[MouseEvent] { |
|||
override def handle(event: MouseEvent): Unit = { |
|||
if (event.isPrimaryButtonDown) { |
|||
//double click |
|||
if (event.getClickCount == 2) { |
|||
// Look into http://stackoverflow.com/questions/228477/how-do-i-programmatically-determine-operating-system-in-java |
|||
// for proper multi-platform opening support |
|||
//Desktop.getDesktop.open(new File(image.getImagePath)) |
|||
} else { |
|||
|
|||
} |
|||
} else if (event.isSecondaryButtonDown) { |
|||
//right click context menu |
|||
} |
|||
} |
|||
}) |
|||
|
|||
def setImageData(image: Image) = { |
|||
this.imageData = image |
|||
// Image |
|||
val genImageView = new ImageView() |
|||
debug(s"Getting thumbnail from: ${image.getThumbnailPath}") |
|||
managed(new FileInputStream(image.getThumbnailPath)) acquireAndGet { |
|||
thumbSource => |
|||
val thumbnail = new javafx.scene.image.Image(thumbSource) |
|||
genImageView.setImage(thumbnail) |
|||
if (thumbnail.getHeight > thumbnail.getWidth) { |
|||
genImageView.setFitHeight(128.0) |
|||
} else { |
|||
genImageView.setFitWidth(128.0) |
|||
} |
|||
} |
|||
genImageView.setPreserveRatio(true) |
|||
|
|||
this.getChildren.add(genImageView) |
|||
|
|||
//Label |
|||
val imageLabel = new Label() |
|||
imageLabel.setText(s"${image.getHeight}x${image.getWidth}") |
|||
imageLabel.setWrapText(true) |
|||
|
|||
//Tooltip |
|||
val tooltip = new Tooltip() |
|||
tooltip.setText(s"${image.getName}") |
|||
imageLabel.setTooltip(tooltip) |
|||
this.getChildren.add(imageLabel) |
|||
|
|||
def getImageData: com.sothr.imagetools.engine.image.Image = { |
|||
imageData |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue