Browse Source

Working on getting directory browsing working.

master
Drew Short 10 years ago
parent
commit
4cecab8f63
  1. 22
      pom.xml
  2. 38
      src/main/resources/fxml/mainapp/MainApp.fxml
  3. 19
      src/main/scala/com/sothr/imagetools/ui/component/ImageTile.scala
  4. 18
      src/main/scala/com/sothr/imagetools/ui/component/ImageTileFactory.scala
  5. 22
      src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala

22
pom.xml

@ -28,13 +28,13 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.8</jdk.version>
<lib.junit.version>3.8.1</lib.junit.version>
<lib.scalatest.version>2.0</lib.scalatest.version>
<lib.logback.version>1.0.13</lib.logback.version>
<lib.slf4j.version>1.7.5</lib.slf4j.version>
<lib.grizzled-slf4j.version>1.0.1</lib.grizzled-slf4j.version>
<lib.scala-library.version>2.10.3</lib.scala-library.version>
<lib.akka.version>2.2.3</lib.akka.version>
<lib.junit.version>4.11</lib.junit.version>
<lib.scalatest.version>2.2.1</lib.scalatest.version>
<lib.logback.version>1.1.2</lib.logback.version>
<lib.slf4j.version>1.7.7</lib.slf4j.version>
<lib.grizzled-slf4j.version>1.0.2</lib.grizzled-slf4j.version>
<lib.scala-library.version>2.11.2</lib.scala-library.version>
<lib.akka.version>2.3.5</lib.akka.version>
<lib.jta.version>1.1</lib.jta.version>
<lib.ehcache.version>2.8.0</lib.ehcache.version>
<lib.commons-cli.version>1.2</lib.commons-cli.version>
@ -57,7 +57,7 @@
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10</artifactId>
<artifactId>scalatest_2.11</artifactId>
<version>${lib.scalatest.version}</version>
<scope>test</scope>
</dependency>
@ -83,7 +83,7 @@
</dependency>
<dependency>
<groupId>org.clapper</groupId>
<artifactId>grizzled-slf4j_2.10</artifactId>
<artifactId>grizzled-slf4j_2.11</artifactId>
<version>${lib.grizzled-slf4j.version}</version>
</dependency>
<dependency>
@ -128,12 +128,12 @@
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.10</artifactId>
<artifactId>akka-actor_2.11</artifactId>
<version>${lib.akka.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-slf4j_2.10</artifactId>
<artifactId>akka-slf4j_2.11</artifactId>
<version>${lib.akka.version}</version>
</dependency>
<dependency>

38
src/main/resources/fxml/mainapp/MainApp.fxml

@ -6,7 +6,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane minHeight="600.0" minWidth="1024.0" prefHeight="600.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sothr.imagetools.ui.controller.AppController">
<AnchorPane fx:id="rootPane" minHeight="600.0" minWidth="1024.0" prefHeight="600.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sothr.imagetools.ui.controller.AppController">
<children>
<MenuBar fx:id="rootMenuBar" minWidth="-Infinity" prefHeight="30.0" prefWidth="600.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<menus>
@ -36,19 +36,41 @@
<tabs>
<Tab closable="false" text="Folders">
<content>
<AnchorPane prefHeight="200.0" prefWidth="200.0">
<BorderPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="200.0" prefWidth="200.0">
<top>
<Button maxWidth="1.7976931348623157E308" minWidth="200.0" mnemonicParsing="false" onAction="#browseFolders" text="Browse" BorderPane.alignment="CENTER" />
</top>
<center>
<FlowPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<Label layoutX="14.0" layoutY="14.0" text="Selected Folder:" />
<Label layoutX="14.0" layoutY="30.0" text="&lt;SELECTED&gt;">
<Label maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="210.0" text="Selected Folder:">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
<Label fx:id="selectedDirectoryLabel" alignment="TOP_LEFT" lineSpacing="2.0" maxHeight="1.7976931348623157E308" maxWidth="210.0" minWidth="210.0" prefWidth="210.0" text="&lt;SELECTED&gt;" wrapText="true">
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
<Button layoutX="14.0" layoutY="66.0" mnemonicParsing="false" text="Browse" />
<Button layoutX="14.0" layoutY="102.0" mnemonicParsing="false" text="Show Similar Images" />
<Button layoutX="14.0" layoutY="138.0" mnemonicParsing="false" text="Show All Images" />
</children>
</AnchorPane>
</FlowPane>
</center>
<bottom>
<FlowPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="60.0" prefWidth="220.0" BorderPane.alignment="CENTER">
<children>
<Button maxWidth="1.7976931348623157E308" minWidth="220.0" mnemonicParsing="false" text="Show All Images" />
<Button maxWidth="200.0" minWidth="220.0" mnemonicParsing="false" text="Show Similar Images" />
</children>
</FlowPane>
</bottom>
<padding>
<Insets bottom="5.0" top="5.0" />
</padding>
</BorderPane>
</content>
</Tab>
<Tab text="Tags">

19
src/main/scala/com/sothr/imagetools/ui/component/ImageTile.scala

@ -0,0 +1,19 @@
package com.sothr.imagetools.ui.component
import javafx.scene.layout.VBox
import com.sothr.imagetools.image.Image
/**
* Created by drew on 8/22/14.
*/
class ImageTile extends VBox{
var imageData: Image = null
def getImageData:Image = {
imageData
}
def setImageData(image:Image) = {
this.imageData = image
}
}

18
src/main/scala/com/sothr/imagetools/ui/component/ImageTileFactory.scala

@ -1,9 +1,13 @@
package com.sothr.imagetools.ui.component
import javafx.event.EventHandler
import javafx.geometry.Pos
import javafx.scene.Node
import javafx.scene.control.Label
import javafx.scene.image.{ImageView, Image}
import javafx.scene.layout.{VBox}
import javafx.scene.input.MouseEvent
import javafx.scene.layout.{Background, BackgroundFill, VBox}
import javafx.scene.paint.Color
/**
* Created by drew on 8/6/14.
@ -12,10 +16,18 @@ import javafx.scene.layout.{VBox}
*/
object ImageTileFactory {
def get(image:com.sothr.imagetools.image.Image):VBox = {
val imageTile = new VBox()
def get(image:com.sothr.imagetools.image.Image):ImageTile = {
val imageTile = new ImageTile()
imageTile.setImageData(image)
imageTile.setPrefSize(192.0d,192.0d)
imageTile.setAlignment(Pos.TOP_CENTER)
imageTile.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler[MouseEvent] {
override def handle(event: MouseEvent): Unit = {
if (event.isSecondaryButtonDown()) {
//right click context menu
}
}
})
// Image
val genImageView = new ImageView()

22
src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala

@ -2,10 +2,10 @@ package com.sothr.imagetools.ui.controller
import javafx.fxml.FXML
import javafx.event.ActionEvent
import javafx.stage.{StageStyle, Stage}
import javafx.stage.{DirectoryChooser, StageStyle, Stage}
import javafx.scene.{Scene,Group}
import javafx.scene.text.{TextAlignment, Text}
import java.io.IOException
import java.io.{File, IOException}
import java.util.Scanner
import com.sothr.imagetools.image.Image
import com.sothr.imagetools.ui.component.ImageTileFactory
@ -20,13 +20,15 @@ import javafx.collections.{FXCollections}
*/
class AppController extends Logging {
//val logger:Logger = LoggerFactory.getLogger(this.getClass)
//Define controls
@FXML var rootPane : javafx.scene.layout.AnchorPane = null
@FXML var rootMenuBar : javafx.scene.control.MenuBar = null
@FXML var imageTilePane : javafx.scene.layout.TilePane = null
@FXML var tagListView : javafx.scene.control.ListView[String] = null
// Labels
@FXML var selectedDirectoryLabel: javafx.scene.control.Label = null
@FXML def initialize() = {
//test
val testImage = new Image()
@ -79,6 +81,18 @@ class AppController extends Logging {
stage.close()
}
@FXML
def browseFolders(event:ActionEvent) = {
val chooser = new DirectoryChooser()
chooser.setTitle("ImageTools Browser")
val defaultDirectory = new File(".")
chooser.setInitialDirectory(defaultDirectory)
val window = this.rootPane.getScene.getWindow
val selectedDirectory = chooser.showDialog(window)
info(s"Selected Directory: ${selectedDirectory.getAbsolutePath}")
selectedDirectoryLabel.setText(selectedDirectory.getAbsolutePath)
}
//endregion
//todo: include a templating engine for rendering information

Loading…
Cancel
Save