86 Commits

Author SHA1 Message Date
b8ca5dc498 added ST#24 2019-06-14 14:23:18 +02:00
dbdba120c3 tested Akzeptanztests 2019-06-14 14:20:59 +02:00
33a46c4cbf added sync systemtests 2019-06-14 12:35:45 +02:00
d81aa56e49 Server Version in Cargo.toml -> '1.0.1' 2019-06-14 12:27:38 +02:00
95496536db Worarround for #43 #44
Use 'invisible' ViewTransition (0.01 seconds)
Fixes #43
Fixes #44
2019-06-14 12:19:55 +02:00
8f3b61462a remove TODO in Systemtests 2019-06-14 12:09:19 +02:00
cff5ec76bf Merge branch 'master' of git.mosad.xyz:localhorst/TextureSync 2019-06-14 12:07:58 +02:00
1bbfe800e1 fix '1.0.0-beta' -> '1.0.0'
'1.0.0-beta' does not exist.
2019-06-14 12:06:37 +02:00
c722a39116 first set of systemtests 2019-06-14 11:52:00 +02:00
911983bff4 don't crash if the previously selected export directory doesn't exist 2019-06-14 11:38:20 +02:00
6feb1c3dad Merge branch 'master' of git.mosad.xyz:localhorst/TextureSync 2019-06-14 11:29:35 +02:00
7da58c7dbe Fix #42, dont load IP from File, if auto-connected 2019-06-14 11:28:43 +02:00
86c05c0363 show width x height, not the other way round 2019-06-14 11:18:58 +02:00
a3c03c4bc7 Make search for texture name case-insensitive
Fixes #47
2019-06-14 11:12:56 +02:00
9444e8198f Repeat Test MT#10 in module tests 2019-06-14 10:37:14 +02:00
730a0ab383 Fix "fix #46" 2019-06-14 01:14:01 +02:00
a10e2aceb6 Revert "fix #46"
This reverts commit f0fe4bb981.
2019-06-14 01:12:33 +02:00
f0fe4bb981 fix #46 2019-06-14 01:09:30 +02:00
32883a2639 Merge branch 'master' of git.mosad.xyz:localhorst/TextureSync 2019-06-14 01:01:23 +02:00
0e293768d7 integrationstest ausfüllen 2019-06-14 01:00:52 +02:00
6a5b2f555c Do the module tests 2019-06-14 00:48:48 +02:00
8d210d756d Integrationstest: Ergebnisbeschreibung präzisiert. 2019-06-14 00:36:04 +02:00
8c6a43fc22 change version to 1.0 2019-06-13 22:21:41 +02:00
7f4182bfad added JFXInfoAlert if connect manually failed
closes #39
2019-06-13 21:52:26 +02:00
5fff4023f9 clear DetailVIew on delete, rename submitButton to btnSubmit, clean up 2019-06-13 21:43:43 +02:00
dfad679e6e updated planner 2019-06-13 21:36:14 +02:00
391dfe4282 don't open export if nothing is selected & clean up 2019-06-13 21:22:42 +02:00
225316abb9 Merge branch 'fix-40' of localhorst/TextureSync into master 2019-06-13 20:04:44 +02:00
f5dbcc0134 use Borderpane + Anchorpane for #40 2019-06-13 18:38:38 +02:00
cac4807357 BUG FIX: show resolution in detailview. 2019-06-13 18:37:07 +02:00
33fa741a2a fix font-color of import action btn 2019-06-13 18:35:34 +02:00
37406acd98 Fix #27 (StartupViewController is created twice) again 2019-06-13 18:04:46 +02:00
56c62422cc use blue for "Ändern" Button 2019-06-13 00:19:16 +02:00
bc43b33536 Fix #38
Note: The client architecture is broken beyond repair
2019-06-13 00:10:00 +02:00
1ac13f80d5 fix MainView ChipView TextColor 2019-06-12 22:54:30 +02:00
8dfbbae559 fix #28 2019-06-12 22:42:28 +02:00
cc03b32ade Fix #29
Redo Text of FolderView + DetailView
2019-06-12 21:05:40 +02:00
a2f5b65e30 Calling App.start(stage) early
Calling super.start early prevents a weird layouting bug
were the button of the window is white.
This could(?) be caused by stage and StartupView having
a different min-size.
2019-06-12 19:37:32 +02:00
f094a68b04 Merge branch 'resize' 2019-06-12 19:11:08 +02:00
b5545e1bae fix icon path: use png for alpha-channel 2019-06-12 19:07:29 +02:00
9a9a1e0056 Merge commit '10076fc' into resize 2019-06-12 19:03:26 +02:00
0f23749001 Merge commit '6219ad9' into resize 2019-06-12 19:03:19 +02:00
c1dbd8ffb7 Merge commit '35f8145' into resize 2019-06-12 19:03:05 +02:00
ebc6449e48 Merge commit 'e26d54e' into resize 2019-06-12 19:02:50 +02:00
bef56f978c Merge commit '9975364' into resize 2019-06-12 19:02:12 +02:00
50ea54c8d6 reformat 2019-06-12 18:57:42 +02:00
24b9755089 Merge commit '4915788' into resize 2019-06-12 18:56:37 +02:00
6fbfa050b3 Merge commit 'ee7fbae' into resize 2019-06-12 18:53:57 +02:00
9a3524143a Merge commit 'efc2845' into resize 2019-06-12 18:53:42 +02:00
10076fcef2 updated test docs 2019-06-12 14:08:23 +02:00
6219ad93d0 Fix #31 : Config Path use ~/.config instead.
This is more common for Desktop Apps.
2019-06-12 13:28:03 +02:00
8109782e4e Merge branch 'master' of git.mosad.xyz:localhorst/TextureSync 2019-06-12 13:24:26 +02:00
c2d01760c7 Set Server Version to 1.0; Show Version on Startup 2019-06-12 13:23:47 +02:00
2cac52b48d Replace logo with the new one 2019-06-12 11:38:05 +02:00
35f8145112 [kurzanleitung] added first thoughts 2019-06-10 16:05:07 +02:00
e26d54e96f added praesentation 2019-06-10 15:58:32 +02:00
7e3ce9ce56 fixed StartupViewController is created twice
closes #27
2019-06-10 15:30:00 +02:00
9975364621 updated all test documents 2019-06-10 15:19:53 +02:00
491578806e Multiple changes in the ChipView will now work for the update to server 2019-06-10 14:05:56 +02:00
b1052fa894 added shortcut ctrl+e for exporting a texture 2019-06-10 12:41:11 +02:00
36c4805061 added shortcut ctrl+i for the ImportView 2019-06-10 12:25:06 +02:00
ee7fbae29c Fix display of the month at creation date
This time on serialization as well as on deserialization
2019-06-09 16:29:37 +02:00
07f2682a2d resize ImportView too 2019-06-09 13:38:11 +02:00
efc28455c1 fixed error handling at import 2019-06-09 13:29:07 +02:00
5d223ba72b make window resizable, rework MainView code 2019-06-09 13:12:56 +02:00
15cbbb1bac fast fix for calendar bug 2019-06-09 13:03:20 +02:00
08840c4c2b Revert "Fix display of the month at creation date"
This reverts commit 19eb6660e1.
2019-06-09 13:02:26 +02:00
6b6ef67122 Revert "Make Client resizeable"
This reverts commit 36a8bccfe3.
2019-06-08 22:46:34 +02:00
4a213afdf5 Merge branch 'master' of git.mosad.xyz:localhorst/TextureSync 2019-06-08 22:17:24 +02:00
36a8bccfe3 Make Client resizeable 2019-06-08 22:16:47 +02:00
4f35293151 hide metadata and ChipView in DetailView 2019-06-08 22:09:43 +02:00
29354199cc show all textures at startup 2019-06-08 21:59:09 +02:00
f4db466b37 Client Connection: [Auto]Retry Once
if Connection is lost or timed out
2019-06-08 21:25:56 +02:00
19eb6660e1 Fix display of the month at creation date 2019-06-08 16:35:45 +02:00
4e8b4c364b Add java program to create test data 2019-06-08 16:07:55 +02:00
f22a9eb260 added com.github.johnrengelman.shadow
this makes it a lot easier to build a runnable jar file
2019-06-08 15:32:05 +02:00
9ae50df1a4 don't resize the window, set the correct Title
* closes #19
2019-06-08 14:39:18 +02:00
ce11d2e263 added a icon 2019-06-08 14:27:11 +02:00
3f18760a74 Merge branch 'master' of git.mosad.xyz:localhorst/TextureSync 2019-06-08 14:21:34 +02:00
89ef736954 alert if import failed 2019-06-08 14:20:48 +02:00
3e1c46db81 some clean up, adjusted the DetailView background 2019-06-08 14:19:14 +02:00
be11f35159 show alert if export fails 2019-06-08 14:01:49 +02:00
39c358c00f update to JFoenix 8.0.9
* added a promptText to the search ChipView
2019-06-08 13:48:16 +02:00
61980905e3 changed debbuging color in 3DPreview to release color 2019-06-08 13:40:59 +02:00
fc5db5d051 Merge branch 'master' of git.mosad.xyz:localhorst/TextureSync 2019-06-08 13:32:09 +02:00
4c2e1c2917 show metadata in better format 2019-06-08 13:31:29 +02:00
52 changed files with 221888 additions and 73367 deletions

View File

@ -15,10 +15,21 @@ buildscript {
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.31'
id "com.github.johnrengelman.shadow" version "5.0.0"
id "application"
}
group 'com.hso'
version '1.0-SNAPSHOT'
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
group 'org.hso'
version '1.0.1'
archivesBaseName = 'TextureSync'
mainClassName = 'org.hso.texturesyncclient.app.Main'
repositories {
mavenCentral()
@ -27,13 +38,6 @@ repositories {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "no.tornado:tornadofx:$tornadofx_version"
implementation "com.jfoenix:jfoenix:8.0.8"
implementation "com.jfoenix:jfoenix:8.0.9"
implementation 'com.google.code.gson:gson:2.8.5'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

View File

@ -1,2 +1,2 @@
rootProject.name = 'texuresync_client'
rootProject.name = 'texturesync_client'

View File

@ -1,19 +1,36 @@
package org.hso.texturesyncclient.app
import javafx.scene.image.Image
import javafx.stage.Stage
import org.hso.texturesyncclient.controller.SettingsController
import org.hso.texturesyncclient.view.startupView.StartupView
import org.hso.texturesyncclient.view.startupView.StartupViewController
import tornadofx.App
class Main: App(StartupView::class){
class Main : App(StartupView::class) {
//start first controller
private val svc = StartupViewController()
private val svc: StartupViewController by inject()
override fun start(stage: Stage) {
// Calling super.start early prevents a weird layouting bug
// were the button of the window is white.
// This could(?) be caused by stage and StartupView having
// a different min-size.
super.start(stage)
stage.minWidth = 1050.00
stage.minHeight = 700.00
stage.width = 1050.00
stage.height = 700.00
stage.isResizable = true
stage.icons.add(Image("icons/TextureSync_Icon_256x256.png"))
stage.setOnCloseRequest { System.exit(0) }
stage.scene.stylesheets.add("/css/Styles.css")
SettingsController.init()
svc.initConnection()
}
}

View File

@ -3,7 +3,9 @@ package org.hso.texturesyncclient.controller
import javafx.application.Platform
import javafx.collections.ObservableList
import javafx.event.EventHandler
import javafx.scene.image.Image
import javafx.stage.DirectoryChooser
import org.hso.texturesyncclient.alerts.JFXInfoAlert
import org.hso.texturesyncclient.alerts.JFXOkayCancelAlert
import org.hso.texturesyncclient.controller.net.AutoConnect
import org.hso.texturesyncclient.controller.net.Connection
@ -12,31 +14,27 @@ import org.hso.texturesyncclient.model.Sha256
import org.hso.texturesyncclient.model.Texture
import org.hso.texturesyncclient.model.TextureFormat
import org.hso.texturesyncclient.view.importView.ImportView
import org.hso.texturesyncclient.view.importView.ImportViewController
import org.hso.texturesyncclient.view.mainView.MainView
import org.hso.texturesyncclient.view.mainView.MainViewController
import org.hso.texturesyncclient.view.startupView.StartupView
import org.hso.texturesyncclient.view.startupView.StartupViewController
import tornadofx.Controller
import tornadofx.observable
import java.net.InetAddress
import java.util.Calendar
import tornadofx.*
import java.io.File
import javax.imageio.ImageIO
import java.util.UUID
import java.nio.file.Files
import java.io.FileOutputStream
import java.io.IOException
import java.net.InetAddress
import java.nio.file.Files
import java.text.SimpleDateFormat
import java.util.*
import javax.imageio.ImageIO
class RootController : Controller() {
private val mvc: MainViewController by inject()
private val svc: StartupViewController by inject()
private val ivc: ImportViewController by inject()
private lateinit var con: Connection
private lateinit var selectedTexture: Texture
private lateinit var selectedTextureModel: GUIModel
private var lastExportDir: String = System.getProperty("user.home")
/**
@ -51,20 +49,39 @@ class RootController : Controller() {
val uuid = UUID.randomUUID()
val format = if (File(path).extension.toLowerCase() == "png") TextureFormat.PNG else TextureFormat.JPEG
val bimg = ImageIO.read(File(path)) //image for obtaining resolution
val resolution = Pair(bimg.height, bimg.width)
val resolution = Pair(bimg.width, bimg.height)
val cal = Calendar.getInstance() //calendar obj with current time
val hash = Sha256(data)
//Todo free image
val alertImportHash = JFXInfoAlert(
"Upload fehlgeschlagen",
"Die Textur wurde nicht fehlerfrei übertragen",
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
)
val alertImport = JFXInfoAlert(
"Upload fehlgeschlagen",
"Mögliche Ursachen:" +
"\n- Textur existiert bereits" +
"\n- Server nicht bereit",
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
)
val newTexture = Texture(uuid, name, tags.toTypedArray(), format, resolution, cal, hash)
try {
con.uploadTexture(newTexture, data)
println("Texture upload successful")
} catch (e: IllegalArgumentException) {
println(e)
alertImportHash.showAndWait()
} catch (e: Exception) {
alertImport.showAndWait()
println(e)
}
}
/**
@ -81,14 +98,17 @@ class RootController : Controller() {
println("[auto] server found")
con = foundServer
con.ping()
println("auto Connection to Server successful")
println("[auto] Connection to Server successful")
switchStartupToMain()
showAll()
return // abort
} else {
println("[auto] no server found")
}
} catch (e: Exception) {
println(e)
println("auto Connection to Server NOT successful")
println("[auto] Connection to Server NOT successful")
}
if (SettingsController.serverAddressIsSet()) {
println("[file] try connect with settings file")
@ -98,6 +118,9 @@ class RootController : Controller() {
con.ping()
println("[file] Connection to Server successful")
switchStartupToMain()
showAll()
return // abort
} catch (e: Exception) {
println(e)
println("[file] Connection to Server NOT successful")
@ -114,15 +137,30 @@ class RootController : Controller() {
println("Connection to Server successful")
SettingsController.setServerAddress(name) //store address in settings file
switchStartupToMain()
showAll()
println("swithing to MainView @ initCon")
return // abort
} catch (e: Exception) {
println(e)
println("Connection to Server NOT successful")
Platform.runLater {
JFXInfoAlert(
"Verbinden fehlgeschlagen",
"Mögliche Ursachen:" +
"\n- der angegebene Server ist offline" +
"\n- die benötigten Ports sind nicht offen",
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
).showAndWait()
}
}
}
}
fun queryElements(tags: ObservableList<String>): ArrayList<GUIModel> {
mvc.setVisibleMetaTags(false)
val previewList = arrayListOf<GUIModel>()
try {
@ -142,26 +180,6 @@ class RootController : Controller() {
return previewList
}
// TODO this could be a companion object
fun switchStartupToMain() {
Platform.runLater {
find(StartupView::class).replaceWith(MainView::class, sizeToScene = true, centerOnScreen = true)
}
}
// These runLater calls should be unnecessary
fun switchMainToImport() {
Platform.runLater {
find(MainView::class).replaceWith(ImportView::class, sizeToScene = true, centerOnScreen = true)
}
}
fun switchImportToMain() {
Platform.runLater {
find(ImportView::class).replaceWith(MainView::class, sizeToScene = true, centerOnScreen = true)
}
}
/**
* save the texture file to a local directory
* @param data the texture as meta element
@ -169,17 +187,34 @@ class RootController : Controller() {
fun exportTexture(data: Texture) {
val directoryChooser = DirectoryChooser()
directoryChooser.title = "Export Verzeichnis wählen"
directoryChooser.initialDirectory = File(lastExportDir)
directoryChooser.initialDirectory = if(File(lastExportDir).exists()) File(lastExportDir) else File(System.getProperty("user.home"))
val alertExport = JFXInfoAlert(
"Exporterien fehlgeschlagen",
"Mögliche Ursachen:" +
"\n- Datei existiert bereits" +
"\n- Ordner nicht beschreibbar",
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
)
val dir = directoryChooser.showDialog(primaryStage)
if (dir != null) {
val extension = if (data.format == TextureFormat.PNG) ".png" else ".jpeg" //get file format
val filePath = "$dir/${data.name}$extension" //build absolute exported texture path
val exportedFile = File(filePath) //create file
val fileout = FileOutputStream(exportedFile)
fileout.write(con.getTextureFile(data.textureHash)) //write bytes in file
fileout.close()
if (exportedFile.exists()) {
alertExport.showAndWait()
} else {
try {
val fileout = FileOutputStream(exportedFile)
fileout.write(con.getTextureFile(data.textureHash)) //write bytes in file fileout.close()
fileout.close()
} catch (e: IOException) {
alertExport.showAndWait()
}
}
lastExportDir = dir.absolutePath //store last user chosen dir
}
}
@ -190,24 +225,33 @@ class RootController : Controller() {
*/
fun showDetail(data: Texture) {
mvc.setPreview3DTexture(con.getTexturePreview(data.textureHash))
mvc.setMeta(data.name, data.resolution.toString(), "")
val sdf = SimpleDateFormat("dd.MM.yyyy")
mvc.setMeta(
data.name,
"${data.resolution.first}px x ${data.resolution.second}px",
data.format.toString(),
sdf.format(data.addedOn.time)
)
mvc.setTags(data.tags.toList().observable())
selectedTexture = data
mvc.setVisibleMetaTags(true)
}
/**
* remove a texture from the FolderView and the server
* @param data the texture as meta element
*/
fun deleteTexture(data: Texture) {
fun deleteTexture() {
val dialogDelete = JFXOkayCancelAlert(
"Löschen",
"Textur wirklich löschen?",
"Textur ${selectedTextureModel.data.name} wirklich löschen?",
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
)
dialogDelete.okayAction = EventHandler {
mvc.removeTextureFromView(data)
con.deleteTexture(data)
con.deleteTexture(selectedTextureModel.data)
mvc.removeTextureFromView(selectedTextureModel.data)
// reset the DetailView
mvc.setVisibleMetaTags(false)
mvc.setPreview3DTexture(Image("icons/TextureSync_Icon_256x256.jpeg"))
}
dialogDelete.cancelAction = EventHandler {
// Do nothing
@ -215,19 +259,61 @@ class RootController : Controller() {
dialogDelete.showAndWait()
}
fun updateTexture(chips: ObservableList<String>) {
val uuid = UUID.randomUUID()
val newTexture = Texture(
uuid,
selectedTexture.name,
chips.toTypedArray(),
selectedTexture.format,
selectedTexture.resolution,
selectedTexture.addedOn,
selectedTexture.textureHash
fun updateTexture(name: String, tags: Array<String>) {
val newTexture = selectedTextureModel.data.copy(
tags = tags,
name = name
)
con.updateTexture(selectedTexture, newTexture, con.getTextureFile(selectedTexture.textureHash))
try {
con.updateTexture(
selectedTextureModel.data,
newTexture,
con.getTextureFile(selectedTextureModel.data.textureHash)
)
selectedTextureModel.data = newTexture
} catch (e: Exception) {
println(e)
}
}
/**
* show all available textures at start
*/
private fun showAll() {
queryElements(mvc.getTags())
}
/**
* set the last selected texture-GUIModell
* @param model the last selected element
*/
fun setSelectedTexture(model: GUIModel) {
selectedTextureModel = model
selectedTexture = model.data
}
companion object {
var selectedTexture: Texture? = null
fun switchStartupToMain() {
Platform.runLater {
find(StartupView::class).replaceWith(MainView::class, ViewTransition.FadeThrough(0.01.seconds))
}
}
// These runLater calls should be unnecessary
fun switchMainToImport() {
Platform.runLater {
find(MainView::class).replaceWith(ImportView::class, ViewTransition.FadeThrough(0.01.seconds))
}
}
fun switchImportToMain() {
Platform.runLater {
find(ImportView::class).replaceWith(MainView::class, ViewTransition.FadeThrough(0.01.seconds))
}
}
}
}

View File

@ -26,7 +26,7 @@ class SettingsController {
dirPath = if (osName.contains("Windows")) {
"$userHome/Documents/TextureSync"
} else {
"$userHome/.TextureSync"
"$userHome/.config/TextureSync"
}
settingsFile = File("$dirPath/config.xml") //open Settings file

View File

@ -19,7 +19,7 @@ class Connection(val address: InetAddress, val port: Int = 10796) : Closeable {
@Throws(IOException::class)
@Synchronized
private fun getStreams(): Pair<DataInputStream, DataOutputStream> {
private fun <R> withStreams(retry: Boolean = true, inner: (DataInputStream, DataOutputStream) -> R): R {
val i: DataInputStream
val o: DataOutputStream
@ -40,242 +40,253 @@ class Connection(val address: InetAddress, val port: Int = 10796) : Closeable {
o = output!!
}
return Pair(i, o)
return try {
inner(i, o)
} catch (e: IOException) {
if (retry) {
println("Got IOException; Retry ${e.message}")
close()
withStreams(false, inner)
} else {
throw e
}
}
}
@Throws(IOException::class, ConnectionException::class)
@Synchronized
fun ping() {
val io = getStreams()
return withStreams { i, o ->
val obj = JsonObject()
obj.add("ping", JsonObject())
val obj = JsonObject()
obj.add("ping", JsonObject())
JsonPackage(obj).write(io.second)
JsonPackage(obj).write(o)
when (val pkg = Package.read(io.first)) {
is JsonPackage -> return
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
when (val pkg = Package.read(i)) {
is JsonPackage -> return@withStreams
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
};
}
@Throws(IOException::class, ConnectionException::class)
@Synchronized
fun query(query: Array<String>): Array<Texture> {
val io = getStreams()
return withStreams { i, o ->
val obj = JsonObject()
obj.add("query", {
val inner = JsonObject()
inner.add("query", {
val array = JsonArray()
for (queryString in query) {
array.add(queryString)
}
array
val obj = JsonObject()
obj.add("query", {
val inner = JsonObject()
inner.add("query", {
val array = JsonArray()
for (queryString in query) {
array.add(queryString)
}
array
}())
inner
}())
inner
}())
JsonPackage(obj).write(io.second)
JsonPackage(obj).write(o)
when (val pkg = Package.read(io.first)) {
is JsonPackage -> {
try {
return Gson().fromJson<Array<InternalTexture>>(pkg.content, Array<InternalTexture>::class.java)
.map { tex ->
tex.toTexture()
}.toTypedArray()
} catch (e: JsonSyntaxException) {
throw ConnectionInvalidJsonException()
when (val pkg = Package.read(i)) {
is JsonPackage -> {
try {
return@withStreams Gson().fromJson<Array<InternalTexture>>(
pkg.content,
Array<InternalTexture>::class.java
)
.map { tex ->
tex.toTexture()
}.toTypedArray()
} catch (e: JsonSyntaxException) {
throw ConnectionInvalidJsonException()
}
}
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
}
@Throws(IOException::class, ConnectionException::class)
@Synchronized
fun getTextureById(id: UUID): Texture? {
val io = getStreams()
return withStreams { i, o ->
val obj = JsonObject()
obj.add("get_texture", {
val inner = JsonObject()
inner.addProperty("id", id.toString())
inner
}())
JsonPackage(obj).write(io.second)
val obj = JsonObject()
obj.add("get_texture", {
val inner = JsonObject()
inner.addProperty("id", id.toString())
inner
}())
when (val pkg = Package.read(io.first)) {
is JsonPackage -> {
return if (pkg.content.isJsonNull) {
null
} else {
try {
Gson()
.fromJson<InternalTexture>(pkg.content, InternalTexture::class.java)
.toTexture()
} catch (e: JsonSyntaxException) {
throw ConnectionInvalidJsonException()
}
}
}
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
JsonPackage(obj).write(o)
}
@Throws(IOException::class, ConnectionException::class)
@Synchronized
fun getTextureByName(name: String): Texture? {
val io = getStreams()
val obj = JsonObject()
obj.add("get_texture", {
val inner = JsonObject()
inner.addProperty("name", name)
inner
}())
JsonPackage(obj).write(io.second)
when (val pkg = Package.read(io.first)) {
is JsonPackage -> {
return if (pkg.content.isJsonNull) {
null
} else {
try {
Gson()
.fromJson<InternalTexture>(pkg.content, InternalTexture::class.java)
.toTexture()
} catch (e: JsonSyntaxException) {
throw ConnectionInvalidJsonException()
}
}
}
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
}
@Throws(IOException::class, ConnectionException::class)
@Synchronized
fun getTextureFile(hash: Sha256): ByteArray {
val io = getStreams()
val obj = JsonObject()
obj.add("get_texture_file", {
val inner = JsonObject()
inner.addProperty("texture_hash", hash.toString())
inner
}())
JsonPackage(obj).write(io.second)
when (val pkg = Package.read(io.first)) {
is JsonPackage -> throw ConnectionUnexpectedPacketException()
is BinaryPackage -> return pkg.content
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
}
@Throws(IOException::class, ConnectionException::class)
@Synchronized
fun getTexturePreview(hash: Sha256): Image {
val io = getStreams()
val obj = JsonObject()
obj.add("get_texture_preview", {
val inner = JsonObject()
inner.addProperty("texture_hash", hash.toString())
inner.addProperty("desired_format", "jpeg")
inner
}())
JsonPackage(obj).write(io.second)
when (val pkg = Package.read(io.first)) {
is JsonPackage -> throw ConnectionUnexpectedPacketException()
is BinaryPackage -> {
return Image(ByteArrayInputStream(pkg.content))
}
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
}
@Throws(IOException::class, ConnectionException::class, IllegalArgumentException::class)
@Synchronized
private fun replaceTexture(old: Texture?, new: Texture?, image: ByteArray?) {
val io = getStreams()
val obj = JsonObject()
obj.add("replace_texture", {
val inner = JsonObject()
if (old != null) {
inner.add("old", Gson().toJsonTree(InternalTexture(old), InternalTexture::class.java))
} else {
inner.add("old", null)
}
if (new != null) {
inner.add("new", Gson().toJsonTree(InternalTexture(new), InternalTexture::class.java))
} else {
inner.add("new", null)
}
inner
}())
JsonPackage(obj).write(io.second)
when (val pkg = Package.read(io.first)) {
is JsonPackage -> {
when {
pkg.content == JsonPrimitive(true) -> // everthing is fine!
return
image != null -> {
// should be { "get_texture_file": { texture_hash : <Hash> }}
// we don't check, since there is no good way to handle it.
BinaryPackage(image).write(io.second)
when (val ipkg = Package.read(io.first)) {
is JsonPackage -> {
if (ipkg.content != JsonPrimitive(true)) {
// Protokoll Assertion failed
throw ConnectionUnexpectedPacketException()
}
}
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(ipkg)
else -> throw RuntimeException("Unreachable")
when (val pkg = Package.read(i)) {
is JsonPackage -> {
return@withStreams if (pkg.content.isJsonNull) {
null
} else {
try {
Gson()
.fromJson<InternalTexture>(pkg.content, InternalTexture::class.java)
.toTexture()
} catch (e: JsonSyntaxException) {
throw ConnectionInvalidJsonException()
}
}
else -> {
ErrorPackage(404, "Texture not found!").write(io.second)
close() // gets re-opened on next request.
throw IllegalArgumentException("Image Argument was needed.")
}
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
}
}
@Throws(IOException::class, ConnectionException::class)
fun getTextureByName(name: String): Texture? {
return withStreams { i, o ->
val obj = JsonObject()
obj.add("get_texture", {
val inner = JsonObject()
inner.addProperty("name", name)
inner
}())
JsonPackage(obj).write(o)
when (val pkg = Package.read(i)) {
is JsonPackage -> {
return@withStreams if (pkg.content.isJsonNull) {
null
} else {
try {
Gson()
.fromJson<InternalTexture>(pkg.content, InternalTexture::class.java)
.toTexture()
} catch (e: JsonSyntaxException) {
throw ConnectionInvalidJsonException()
}
}
}
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
}
}
@Throws(IOException::class, ConnectionException::class)
fun getTextureFile(hash: Sha256): ByteArray {
return withStreams { i, o ->
val obj = JsonObject()
obj.add("get_texture_file", {
val inner = JsonObject()
inner.addProperty("texture_hash", hash.toString())
inner
}())
JsonPackage(obj).write(o)
when (val pkg = Package.read(i)) {
is JsonPackage -> throw ConnectionUnexpectedPacketException()
is BinaryPackage -> return@withStreams pkg.content
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
}
}
@Throws(IOException::class, ConnectionException::class)
fun getTexturePreview(hash: Sha256): Image {
return withStreams { i, o ->
val obj = JsonObject()
obj.add("get_texture_preview", {
val inner = JsonObject()
inner.addProperty("texture_hash", hash.toString())
inner.addProperty("desired_format", "jpeg")
inner
}())
JsonPackage(obj).write(o)
when (val pkg = Package.read(i)) {
is JsonPackage -> throw ConnectionUnexpectedPacketException()
is BinaryPackage -> {
return@withStreams Image(ByteArrayInputStream(pkg.content))
}
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
}
}
@Throws(IOException::class, ConnectionException::class, IllegalArgumentException::class)
private fun replaceTexture(old: Texture?, new: Texture?, image: ByteArray?) {
return withStreams { i, o ->
val obj = JsonObject()
obj.add("replace_texture", {
val inner = JsonObject()
if (old != null) {
inner.add("old", Gson().toJsonTree(InternalTexture(old), InternalTexture::class.java))
} else {
inner.add("old", null)
}
if (new != null) {
inner.add("new", Gson().toJsonTree(InternalTexture(new), InternalTexture::class.java))
} else {
inner.add("new", null)
}
inner
}())
JsonPackage(obj).write(o)
when (val pkg = Package.read(i)) {
is JsonPackage -> {
when {
pkg.content == JsonPrimitive(true) -> // everthing is fine!
return@withStreams
image != null -> {
// should be { "get_texture_file": { texture_hash : <Hash> }}
// we don't check, since there is no good way to handle it.
BinaryPackage(image).write(o)
when (val ipkg = Package.read(i)) {
is JsonPackage -> {
if (ipkg.content != JsonPrimitive(true)) {
// Protokoll Assertion failed
throw ConnectionUnexpectedPacketException()
}
}
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(ipkg)
else -> throw RuntimeException("Unreachable")
}
}
else -> {
ErrorPackage(404, "Texture not found!").write(o)
close() // gets re-opened on next request.
throw IllegalArgumentException("Image Argument was needed.")
}
}
}
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
is BinaryPackage -> throw ConnectionUnexpectedPacketException()
is ErrorPackage -> throw ConnectionErrorException(pkg)
else -> throw RuntimeException("Unreachable")
}
}
@Throws(IOException::class, ConnectionException::class, IllegalArgumentException::class)
@Synchronized
fun uploadTexture(texture: Texture, image: ByteArray) {
if (texture.textureHash != Sha256(image)) {
throw IllegalArgumentException("Sha256 of Image does not Match with Texture.")
@ -285,7 +296,6 @@ class Connection(val address: InetAddress, val port: Int = 10796) : Closeable {
}
@Throws(IOException::class, ConnectionException::class, IllegalArgumentException::class)
@Synchronized
fun updateTexture(old: Texture, new: Texture, image: ByteArray) {
if (new.textureHash != Sha256(image)) {
throw IllegalArgumentException("Sha256 of Image does not Match with Texture.")
@ -295,26 +305,28 @@ class Connection(val address: InetAddress, val port: Int = 10796) : Closeable {
}
@Throws(IOException::class, ConnectionException::class, IllegalArgumentException::class)
@Synchronized
fun deleteTexture(texture: Texture) {
replaceTexture(texture, null, null)
}
@Throws(IOException::class)
@Synchronized
override fun close() {
if (output != null) {
output!!.close()
output = null
}
if (input != null) {
input!!.close()
input = null
}
if (socket != null) {
socket!!.close()
socket = null
try {
if (output != null) {
output!!.close()
output = null
}
if (input != null) {
input!!.close()
input = null
}
if (socket != null) {
socket!!.close()
socket = null
}
} catch (e: IOException) {
// Ignore
}
}
}
}

View File

@ -30,7 +30,7 @@ internal data class InternalTexture(
resolution = arrayOf(tex.resolution.first, tex.resolution.second),
added_on = arrayOf(
tex.addedOn.get(Calendar.YEAR), //
tex.addedOn.get(Calendar.MONTH), //
tex.addedOn.get(Calendar.MONTH) + 1, //
tex.addedOn.get(Calendar.DAY_OF_MONTH)
),
texture_hash = tex.textureHash.toString()
@ -50,7 +50,7 @@ internal data class InternalTexture(
else -> throw ConnectionInvalidJsonException()
},
resolution = Pair(resolution[0], resolution[1]),
addedOn = GregorianCalendar(added_on[0], added_on[1], added_on[2]),
addedOn = GregorianCalendar(added_on[0], added_on[1] - 1, added_on[2]),
textureHash = Sha256(texture_hash)
)
} catch (e: Exception) { // i Know, but no time :[]

View File

@ -6,7 +6,7 @@ import java.lang.Exception
sealed class ConnectionException(override val message: String) : Exception(message)
class ConnectionErrorException(val errorCode: Int, val errorMessage: String) :
class ConnectionErrorException(errorCode: Int, errorMessage: String) :
ConnectionException("$errorCode $errorMessage") {
internal constructor(err: ErrorPackage) : this(err.code, err.message)
}

View File

@ -13,7 +13,7 @@ enum class TextureFormat {
data class Texture(
val id : UUID,
val name : String,
val tags : Array<String>,
var tags : Array<String>,
val format : TextureFormat,
val resolution : Pair<Int, Int>,
val addedOn : Calendar,

View File

@ -12,9 +12,11 @@ import javafx.scene.layout.BackgroundFill
import javafx.scene.layout.CornerRadii
import javafx.scene.layout.VBox
import javafx.scene.paint.Paint
import tornadofx.*
import tornadofx.addClass
import tornadofx.find
import tornadofx.paddingTop
class GUIModel constructor(var data: Texture, img: Image) : VBox(){
class GUIModel constructor(var data: Texture, img: Image) : VBox() {
private var image = ImageView()
private var label = Label()
@ -22,13 +24,13 @@ class GUIModel constructor(var data: Texture, img: Image) : VBox(){
private var exportItem = MenuItem("exportiern")
private var deleteItem = MenuItem("löschen")
private val gmc = find(GUIModelController::class)
private val gmc = find(GUIModelController::class)
init {
super.setPadding(Insets(5.0, 5.0, 5.0, 5.0))
super.getChildren().addAll(image, label)
super.setOnContextMenuRequested { p0 -> contextMenu.show(this@GUIModel, p0.screenX, p0.screenY) }
super.setOnMouseClicked{
super.setOnMouseClicked {
if (gmc.isLastSelectedInitialized()) {
gmc.lastSelected.background = Background.EMPTY
this.background = Background(BackgroundFill(Paint.valueOf("#2b7bbb"), CornerRadii.EMPTY, Insets.EMPTY))
@ -38,13 +40,22 @@ class GUIModel constructor(var data: Texture, img: Image) : VBox(){
gmc.lastSelected = this
}
gmc.previewSelectedAction(data)
gmc.setSelected(this)
}
label.addClass("metadata")
label.paddingTop = 5.0
label.prefWidth = 128.0
label.alignment = Pos.CENTER
label.text = data.name
label.background = Background(BackgroundFill(Paint.valueOf("#FFFF2b"), CornerRadii.EMPTY, Insets.EMPTY))
label.text = if (data.name.length > 15) {
"${data.name.subSequence(0, 14)}.."
} else {
data.name
}
label.background = Background(BackgroundFill(Paint.valueOf("#3a3a3a"), CornerRadii.EMPTY, Insets.EMPTY))
image.fitHeight = 128.0
image.fitWidth = 128.0
@ -55,7 +66,7 @@ class GUIModel constructor(var data: Texture, img: Image) : VBox(){
}
deleteItem.setOnAction {
gmc.delete(data)
gmc.delete()
}
contextMenu.items.add(exportItem)

View File

@ -3,7 +3,7 @@ package org.hso.texturesyncclient.model
import org.hso.texturesyncclient.controller.RootController
import tornadofx.Controller
class GUIModelController: Controller() {
class GUIModelController : Controller() {
private val rootc = find(RootController::class)
@ -14,11 +14,15 @@ class GUIModelController: Controller() {
rootc.exportTexture(data)
}
fun delete(data: Texture) {
rootc.deleteTexture(data)
fun delete() {
rootc.deleteTexture()
}
fun previewSelectedAction(data: Texture) {
rootc.showDetail(data)
}
fun setSelected(model: GUIModel) {
rootc.setSelectedTexture(model)
}
}

View File

@ -10,25 +10,30 @@ import javafx.scene.layout.BackgroundFill
import javafx.scene.layout.CornerRadii
import javafx.scene.paint.Paint
import javafx.scene.layout.Priority
import org.hso.texturesyncclient.view.mainView.Preview3D
import tornadofx.*
class ImportView : View() {
class ImportView : View("TextureSync") {
val tfFilePath = JFXTextField()
val tfName = JFXTextField()
val cvTags = JFXChipView<String>()
val btnImport = JFXButton("Importieren")
val btnBack = JFXButton("Zurück")
val preview = Preview3D()
private val btnBack = JFXButton("Zurück")
private val ivc: ImportViewController by inject()
init {
btnImport.isVisible = false
preview.root.isVisible = false
}
override val root = borderpane {
minWidth = 1000.0
minHeight = 500.0
prefWidth = FX.primaryStage.width
prefHeight = FX.primaryStage.height
background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY))
center = vbox(50) {
@ -39,6 +44,8 @@ class ImportView : View() {
style = "-fx-font: 20px Verdana; -fx-text-fill: #2b7bbb;"
}
add(preview)
vbox(20) {
hbox(10) {
add(tfFilePath)

View File

@ -1,9 +1,11 @@
package org.hso.texturesyncclient.view.importView
import javafx.scene.image.Image
import javafx.stage.FileChooser
import org.hso.texturesyncclient.controller.RootController
import tornadofx.Controller
import javafx.stage.FileChooser
import java.io.File
import java.io.FileInputStream
class ImportViewController : Controller() {
@ -29,15 +31,25 @@ class ImportViewController : Controller() {
iv.tfFilePath.text = file.absolutePath
iv.tfName.text = file.nameWithoutExtension
lastImportDir = file.parent.toString() //store last user chosen dir
runAsync {
try {
val fileInput = FileInputStream(file.absolutePath)
val img = Image(fileInput)
iv.preview.setTexture(img)
iv.preview.root.isVisible = true
} catch (e: Exception) {
// Got a catch'em all
println(e.message)
}
}
}
}
fun btnImportAction() {
rootc.importTexture(iv.tfFilePath.text, iv.tfName.text, iv.cvTags.chips)
rootc.switchImportToMain()
iv.tfFilePath.clear()
iv.tfName.clear()
iv.cvTags.chips.clear()
RootController.switchImportToMain()
reset()
}
fun validateImport() {
@ -46,9 +58,14 @@ class ImportViewController : Controller() {
}
fun btnBackAction() {
rootc.switchImportToMain()
RootController.switchImportToMain()
reset()
}
fun reset() {
iv.tfFilePath.clear()
iv.tfName.clear()
iv.cvTags.chips.clear()
iv.preview.root.isVisible = false
}
}

View File

@ -2,10 +2,9 @@ package org.hso.texturesyncclient.view.mainView
import com.jfoenix.controls.JFXButton
import com.jfoenix.controls.JFXChipView
import com.jfoenix.controls.JFXTextField
import javafx.geometry.Insets
import javafx.geometry.Orientation
import javafx.geometry.Pos
import javafx.scene.control.Label
import javafx.scene.image.Image
import javafx.scene.layout.Background
import javafx.scene.layout.BackgroundFill
@ -13,59 +12,69 @@ import javafx.scene.layout.CornerRadii
import javafx.scene.paint.Paint
import tornadofx.*
class DetailView: View() {
private val mvc: MainViewController by inject()
class DetailView : View() {
val preview = Preview3D()
val metaLabel = Label("Auflösung: 8MP\nName: Texture.png\nAndere: was anderes")
val cvTags = JFXChipView<String>()
val btnImport = JFXButton("+")
init {
// set a default texture
preview.setTexture(Image("textures/sample_texture_1.jpg"))
val nameInfo = JFXTextField().addClass("metadata")
val resolutionInfo = label().addClass("metadata")
val formatInfo = label().addClass("metadata")
val dateInfo = label().addClass("metadata")
val btnSubmit = JFXButton("Ändern").addClass("btn-blue")
val metadataPanel = gridpane {
row {
label("Name ").addClass("metadata")
add(nameInfo)
}
row {
label("Auflösung ").addClass("metadata")
add(resolutionInfo)
}
row {
label("Format ").addClass("metadata")
add(formatInfo)
}
row {
label("Einfügedatum ").addClass("metadata")
add(dateInfo)
}
}
override val root = form {
minWidth = 250.0
background = Background(BackgroundFill(Paint.valueOf("#9f9f9f"), CornerRadii.EMPTY, Insets.EMPTY))
background = Background(BackgroundFill(Paint.valueOf("#3a3a3a"), CornerRadii.EMPTY, Insets.EMPTY))
fieldset(labelPosition = Orientation.VERTICAL) {
field{
field {
vbox(7) {
add(preview)
}
}
field("Meta") {
add(metaLabel)
field {
add(metadataPanel)
}
field {
minHeight = 145.0
minHeight = 155.0
add(cvTags)
}
field {
hbox(alignment = Pos.CENTER_RIGHT) {
add(btnImport)
}
add(btnSubmit)
}
// TODO add "Import" Btn
}
}
style {
cvTags.minHeight = 135.0
cvTags.paddingAll = 3.0
cvTags.style = "-fx-background-color: #53585b; -fx-text-inner-color: #b15b2e;"
btnImport.buttonType = JFXButton.ButtonType.RAISED
btnImport.styleClass.add("jfx-floating-action-button");
}
init {
// set a default texture
preview.setTexture(Image("icons/TextureSync_Icon_256x256.jpeg"))
btnSubmit.useMaxWidth = true
}
}

View File

@ -13,12 +13,7 @@ class FolderView : View("FolderView"){
hgap = 5.0
vgap = 5.0
paddingAll = 10.0
prefWidth = 732.0
prefHeight = 401.0
background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY))
style {
}
}
}

View File

@ -1,8 +1,8 @@
package org.hso.texturesyncclient.view.mainView
import com.jfoenix.controls.JFXButton
import com.jfoenix.controls.JFXChipView
import javafx.geometry.Insets
import javafx.scene.control.ScrollPane
import javafx.scene.layout.Background
import javafx.scene.layout.BackgroundFill
@ -10,53 +10,56 @@ import javafx.scene.layout.CornerRadii
import javafx.scene.paint.Paint
import tornadofx.*
class MainView : View() {
class MainView : View("TextureSync") {
val cvSearch = JFXChipView<String>()
private val btnImport = JFXButton("+")
val folderView = find(FolderView::class)
val detailView = find(DetailView::class)
private val mvc: MainViewController by inject()
override val root = borderpane {
override val root = anchorpane {
background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY))
minWidth = 1000.0
maxWidth = 1000.0
minHeight = 500.0
maxHeight = 500.0
prefWidth = FX.primaryStage.width
prefHeight = FX.primaryStage.height
left = vbox {
//background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY))
anchorpane{
this.fitToParentWidth()
paddingAll = 5.0
borderpane {
right = detailView.root
center = vbox {
add(cvSearch)
}
anchorpane {
scrollpane {
this.fitToParentSize()
this.vbarPolicy = ScrollPane.ScrollBarPolicy.ALWAYS
add(folderView.root)
style = "-fx-background-color:transparent;"
isFitToWidth = true
isFitToHeight = true
add(folderView.root)
}
}
anchorpaneConstraints {
topAnchor = 0
bottomAnchor = 0
rightAnchor = 0
leftAnchor = 0
}
}
right = detailView.root
add(btnImport)
style {
cvSearch.promptText = "Suche"
cvSearch.paddingAll = 5.0
cvSearch.minHeight = 70.0
cvSearch.minHeight = 65.0
cvSearch.style = "-fx-background-color: #53585b; -fx-text-inner-color: #b15b2e;"
cvSearch.anchorpaneConstraints {
topAnchor = 3
bottomAnchor = 3
leftAnchor = 3
rightAnchor = -5
}
btnImport.buttonType = JFXButton.ButtonType.RAISED
btnImport.styleClass.add("jfx-floating-action-button")
btnImport.anchorpaneConstraints {
bottomAnchor = 5
rightAnchor = 5
}
}
// actions
@ -64,14 +67,33 @@ class MainView : View() {
mvc.cvSearchAction(cvSearch.chips)
}
detailView.cvTags.chips.onChange {
mvc.updateTags()
}
detailView.btnImport.setOnAction {
btnImport.setOnAction {
mvc.btnImportAction()
}
// TODO: on chipview update on name update
detailView.cvTags.chips.onChange {
detailView.btnSubmit.isVisible = true
}
detailView.nameInfo.textProperty().onChange {
detailView.btnSubmit.isVisible = true
}
detailView.btnSubmit.setOnAction {
mvc.updateTags()
detailView.btnSubmit.isVisible = false
}
//keyboard actions
shortcut("Ctrl+I") {
mvc.btnImportAction()
}
shortcut("Ctrl+E") {
mvc.scExport()
}
}
}

View File

@ -2,10 +2,10 @@ package org.hso.texturesyncclient.view.mainView
import javafx.collections.ObservableList
import javafx.scene.image.Image
import org.hso.texturesyncclient.model.GUIModel
import tornadofx.Controller
import org.hso.texturesyncclient.controller.RootController
import org.hso.texturesyncclient.model.GUIModel
import org.hso.texturesyncclient.model.Texture
import tornadofx.Controller
class MainViewController : Controller() {
@ -17,7 +17,6 @@ class MainViewController : Controller() {
// DetailView elements
private val preview = mv.detailView.preview
private val metaLabel = mv.detailView.metaLabel
private val cvTags = mv.detailView.cvTags
private var lockUpdate: Boolean = false //lock update func when the system changes the detailview chipview
@ -26,18 +25,18 @@ class MainViewController : Controller() {
folderView.children.add(element)
}
fun addAllElements(elementList: ArrayList<GUIModel>) {
folderView.children.addAll(elementList)
}
// DetailView functions
fun setPreview3DTexture(img: Image) {
preview.setTexture(img)
}
fun setMeta(name: String, res: String, etc: String) {
metaLabel.text = "Name: $name\nAuflösung: $res\nAnderes: $etc"
fun setMeta(name: String, res: String, format: String, date: String) {
with(mv.detailView) {
nameInfo.text = name
formatInfo.text = format
resolutionInfo.text = res
dateInfo.text = date
}
}
fun setTags(chips: ObservableList<String>) {
@ -47,19 +46,28 @@ class MainViewController : Controller() {
lockUpdate = true //allow update with onChange
}
fun getTags(): ObservableList<String> {
return cvTags.chips
}
fun updateTags() {
if (lockUpdate) { //the chipView was changed by the user
println("Tags changed")
rootc.updateTexture(cvTags.chips)
rootc.updateTexture(
tags = cvTags.chips.toTypedArray(),
name = mv.detailView.nameInfo.text
)
}
}
// DetailView actions
// MainView actions
fun cvSearchAction(tags: ObservableList<String>) {
// show spinner, block ui
folderView.children.clear()
mv.cvSearch.isDisable = true
setPreview3DTexture(Image("icons/TextureSync_Icon_256x256.jpeg")) // reset the 3DPreview to the logo
RootController.selectedTexture = null
runAsync {
rootc.queryElements(tags)
@ -70,15 +78,29 @@ class MainViewController : Controller() {
}
fun btnImportAction() {
rootc.switchMainToImport()
RootController.switchMainToImport()
}
fun removeTextureFromView(data: Texture) {
// stream all children nodes, filter them as GUIModel with data.id == data.id, for any found object if it's still present remove it from the folderView
folderView.children.stream().filter { x -> (x as GUIModel).data.id == data.id }.findAny()
.ifPresent { x -> folderView.children.remove(x) }
}
fun setVisibleMetaTags(bool: Boolean) {
if (bool) {
mv.detailView.metadataPanel.isVisible = true
mv.detailView.btnSubmit.isVisible = false
cvTags.isVisible = true
} else {
mv.detailView.metadataPanel.isVisible = false
mv.detailView.btnSubmit.isVisible = false
cvTags.isVisible = false
}
}
fun scExport() {
RootController.selectedTexture?.let { rootc.exportTexture(RootController.selectedTexture!!) }
}
}

View File

@ -36,7 +36,6 @@ class Preview3D : View("Preview3D") {
pointLightFront.rotate = 90.0
}
override val root = stackpane {
add(dBox).apply {
@ -56,7 +55,7 @@ class Preview3D : View("Preview3D") {
style {
minWidth = 200.px
minHeight = 200.px
background = Background(BackgroundFill(Color.BLUEVIOLET, CornerRadii.EMPTY, Insets.EMPTY))
background = Background(BackgroundFill(Color.valueOf("#3a3a3a"), CornerRadii.EMPTY, Insets.EMPTY))
}
}

View File

@ -13,7 +13,7 @@ import javafx.scene.layout.CornerRadii
import javafx.scene.paint.Paint
import tornadofx.*
class StartupView : View("StartupView") {
class StartupView : View("TextureSync") {
val labelStatus = Label("Verbindung zum Server einrichten")
val spinnerStatus = JFXSpinner()
@ -22,6 +22,7 @@ class StartupView : View("StartupView") {
private val svc: StartupViewController by inject()
override val root = borderpane {
minWidth = 1000.0
minHeight = 500.0

View File

@ -1,7 +1,6 @@
package org.hso.texturesyncclient.view.startupView
import org.hso.texturesyncclient.controller.RootController
import org.hso.texturesyncclient.controller.SettingsController
import tornadofx.Controller
@ -10,9 +9,8 @@ class StartupViewController : Controller() {
private val sv = find(StartupView::class)
private val rootc = find(RootController::class)
init {
fun initConnection() {
println("init StartupViewController")
SettingsController.init()
startConnectionUI()
runAsync {
rootc.initConnection(" ")
@ -23,7 +21,7 @@ class StartupViewController : Controller() {
}
fun setServerAddress(address: String) {
sv.tfServerIP.text = address
//sv.tfServerIP.text = address
sv.tfServerIP.isFocusTraversable = false
}

View File

@ -88,5 +88,58 @@
-fx-min-height: -fx-pref-height;
-fx-max-height: -fx-pref-height;
-jfx-button-type: RAISED;
-fx-font-size: 25px
-fx-text-inner-color: #2b2b2b;
-fx-font-size: 20px;
}
/*******************************************************************************
* *
* ChipView *
* *
******************************************************************************/
.jfx-chip-view .jfx-chip > HBox {
-fx-font-family: "Roboto Medium";
-fx-font-size: 14.0;
-fx-background-color: #E0E0E0;
-fx-background-radius: 40px;
-fx-padding: 5px 8px 5px 12px;
-fx-pref-height: 32px;
-fx-alignment: center-left;
-fx-spacing: 8;
}
.jfx-chip-view {
-fx-text-inner-color: #E0E0E0;
}
/*******************************************************************************
* *
* Buttons *
* *
******************************************************************************/
.btn-blue {
-fx-button-type: RAISED;
-fx-background-color: #3c3f41;
-fx-text-fill: #2b7bbb;
-fx-padding: 10;
}
.btn-orange {
-fx-button-type: RAISED;
-fx-background-color: #b15b2e;
-fx-text-fill: #3c3f41;
}
/*******************************************************************************
* *
* DetailView *
* *
******************************************************************************/
.metadata {
-fx-font: 14px Verdana;
-fx-text-fill: #E0E0E0;
}

View File

@ -0,0 +1 @@
<svg width="640" height="640" xmlns="http://www.w3.org/2000/svg"><defs><radialGradient id="a" cx="0.2" cy="-0.5" r="1.7"><stop offset="40%" stop-color="#8c8c8c"/><stop offset="100%" stop-color="#4c4c4c"/></radialGradient><radialGradient id="b" cx="0.2" cy="0.2" fx="0.34" fy="0.32" r="0.9"><stop offset="0%" stop-color="#fbf6f0"/><stop offset="50%" stop-color="#eadec4"/><stop offset="100%" stop-color="#aba390"/></radialGradient><radialGradient id="c" cx="0.2" cy="0.2" fx="0.34" fy="0.32" r="0.9"><stop offset="5%" stop-color="#fbf1cd"/><stop offset="50%" stop-color="#ffba00"/><stop offset="100%" stop-color="#bc8602"/></radialGradient></defs><path d="M158.58 102.89C144.48 110.79 143.14 130.93 155.49 141.35C169.62 153.27 184.17 164.75 199.13 175.69C138.27 240.95 105.0 337.14 105.0 426.0C105.0 525.49 179.5 590.92 278.99 591.0C342.5 591.05 406.69 553.62 449.59 506.78C501.0 450.65 531.88 370.14 532.0 294.02C532.06 254.61 524.06 213.61 505.46 178.86C487.92 146.11 450.51 118.09 413.38 117.01C388.12 116.27 362.24 125.41 340.98 139.06C331.11 145.4 321.78 152.65 313.04 160.6C313.88 131.47 312.82 102.25 309.97 73.31C308.35 56.96 293.5 46.31 277.86 51.34C236.62 64.58 196.37 81.72 158.58 102.89Z" fill="#000"/><path d="M165.42 115.11C158.26 119.12 158.24 125.36 164.51 130.65C201.33 161.71 241.11 189.73 283.36 212.86C290.09 216.54 295.26 213.92 296.04 206.29C300.48 162.65 300.34 118.34 296.03 74.69C295.17 65.95 290.5 61.98 282.14 64.66C241.79 77.63 202.4 94.39 165.42 115.11Z" fill="url(#a)"/><path d="M220.6 190.82C238.75 203.14 257.44 214.63 276.64 225.14C282.11 228.13 288.25 228.46 293.76 226.78L496.27 366.27C484.19 411.93 461.33 455.47 430.41 489.22C397.54 525.11 350.51 555.58 301.99 563.18L136.05 367.03C147.1 301.77 176.06 237.27 220.6 190.82Z" fill="url(#b)"/><path d="M293.76 226.78C302.1 224.23 309.01 217.1 309.96 207.71C310.21 205.29 310.44 202.86 310.66 200.43C323.57 185.24 338.43 171.6 355.02 160.94C371.91 150.09 392.56 142.41 412.62 142.99C440.73 143.82 469.27 166.35 482.54 191.14C499.13 222.12 506.06 258.84 506.0 293.98C505.96 317.93 502.59 342.39 496.27 366.27L330.0 369.0L301.99 563.18C294.35 564.38 286.68 565.01 279.01 565.0C192.51 564.93 131.0 512.5 131.0 426.0C131.0 406.59 132.7 386.78 136.05 367.03L290.0 332.0L293.76 226.78Z" fill="url(#c)"/></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,15 @@
- herunterladen (Release Gitea)
- installiern (Java VM)
- starten
- connecten
- neue textur einfügen
- query mit Tags
- query mit Name
- query mit Auflösung
- query mit Datum
- query mit Kombination
- exportieren
- ändern
- löschen
- settings file löschen

View File

@ -0,0 +1,7 @@
- herunterladen (Release Gitea)
- installiern (service daemon)
- starten
- loggen
- stoppen
- backups machen
- backups wieder einspielen

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,4 @@
- kleine Präsentation über Projekt
- Idee (Problem der Verwaltung vieler Texturen)
- Ziele (einfach, lokale Daten, gemeinschafftlicher Zugriff)
- Gelerntes (gute Planung, Tests, Versionsverwaltung, Issue-Tracker)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -4,9 +4,9 @@
<phases/>
<calendars>
<day-types>
<day-type id="0" name="Working" description="A default working day"/>
<day-type id="1" name="Nonworking" description="A default non working day"/>
<day-type id="2" name="Use base" description="Use day from base calendar"/>
<day-type id="0" name="Arbeiten" description="Ein Vorgabe-Arbeitstag"/>
<day-type id="1" name="Nicht Arbeiten" description="Ein Vorgabetag, an dem nicht gearbeitet wird"/>
<day-type id="2" name="Basis verwenden" description="Tag vom Basiskalender verwenden"/>
</day-types>
<calendar id="1" name="Vorgabe">
<default-week mon="1" tue="0" wed="0" thu="1" fri="1" sat="0" sun="1"/>
@ -16,7 +16,9 @@
<interval start="1300" end="1700"/>
</overridden-day-type>
</overridden-day-types>
<days/>
<days>
<day date="20190613" type="day-type" id="0"/>
</days>
</calendar>
</calendars>
<tasks>
@ -92,88 +94,82 @@
<predecessor id="1" predecessor-id="10" type="FS"/>
</predecessors>
</task>
<task id="19" name="Realisation" note="" work="1065600" start="20190423T000000Z" end="20190511T170000Z" work-start="20190423T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<task id="19" name="Realisation" note="" work="1641600" start="20190416T133640Z" end="20190612T170000Z" work-start="20190416T133640Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="18" type="FS"/>
</predecessors>
<task id="20" name="Einrichtung von Tests" note="" work="28800" start="20190423T000000Z" end="20190423T170000Z" work-start="20190423T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<task id="20" name="Einrichtung von Tests" note="" work="28800" start="20190416T133640Z" end="20190417T133640Z" work-start="20190416T133640Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="11" type="FS"/>
</predecessors>
<task id="21" name="Client Tests" note="" work="28800" start="20190423T000000Z" end="20190423T170000Z" work-start="20190423T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
</task>
<task id="21" name="Client" note="" work="1123200" start="20190416T133640Z" end="20190612T170000Z" work-start="20190416T133640Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="11" type="FS"/>
</predecessors>
<task id="22" name="UI" note="" work="288000" start="20190416T133640Z" end="20190423T133640Z" work-start="20190416T133640Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<task id="23" name="Previews" note="" work="86400" start="20190416T133640Z" end="20190423T133640Z" work-start="20190416T133640Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work"/>
<task id="24" name="Filter UI" note="" work="86400" start="20190416T133640Z" end="20190423T133640Z" work-start="20190416T133640Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work"/>
<task id="25" name="3D Visualisierung" note="" work="57600" start="20190416T133640Z" end="20190420T133640Z" work-start="20190416T133640Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work"/>
<task id="26" name="Dateien hinzuf&#xFC;gen" note="" work="28800" start="20190416T133640Z" end="20190417T133640Z" work-start="20190416T133640Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work"/>
<task id="27" name="Dateien lokal abspeichern" note="" work="28800" start="20190416T133640Z" end="20190417T133640Z" work-start="20190416T133640Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work"/>
</task>
<task id="28" name="Grund Architektur" note="" work="662400" start="20190423T000000Z" end="20190612T170000Z" work-start="20190423T080000Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work">
<constraint type="start-no-earlier-than" time="20190423T000000Z"/>
</task>
<task id="29" name="Protokoll implementieren" note="" work="172800" start="20190423T000000Z" end="20190504T170000Z" work-start="20190423T080000Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work">
<constraint type="start-no-earlier-than" time="20190423T000000Z"/>
</task>
</task>
<task id="22" name="Client" note="" work="547200" start="20190423T000000Z" end="20190504T170000Z" work-start="20190423T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<task id="30" name="Server" note="" work="489600" start="20190423T000000Z" end="20190511T170000Z" work-start="20190423T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="11" type="FS"/>
</predecessors>
<task id="23" name="UI" note="" work="288000" start="20190423T170000Z" end="20190430T170000Z" work-start="20190424T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="21" type="FS"/>
</predecessors>
<task id="24" name="Previews" note="" work="86400" start="20190423T170000Z" end="20190430T170000Z" work-start="20190424T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work"/>
<task id="25" name="Filter UI" note="" work="86400" start="20190423T170000Z" end="20190430T170000Z" work-start="20190424T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work"/>
<task id="26" name="3D Visualisierung" note="" work="57600" start="20190423T170000Z" end="20190427T170000Z" work-start="20190424T080000Z" percent-complete="50" priority="0" type="normal" scheduling="fixed-work"/>
<task id="27" name="Dateien hinzuf&#xFC;gen" note="" work="28800" start="20190423T170000Z" end="20190424T170000Z" work-start="20190424T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work"/>
<task id="28" name="Dateien lokal abspeichern" note="" work="28800" start="20190423T170000Z" end="20190424T170000Z" work-start="20190424T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work"/>
</task>
<task id="29" name="Grund Architektur" note="" work="86400" start="20190423T000000Z" end="20190427T170000Z" work-start="20190423T080000Z" percent-complete="70" priority="0" type="normal" scheduling="fixed-work">
<constraint type="start-no-earlier-than" time="20190423T000000Z"/>
</task>
<task id="30" name="Protokoll implementieren" note="" work="172800" start="20190423T000000Z" end="20190504T170000Z" work-start="20190423T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<constraint type="start-no-earlier-than" time="20190423T000000Z"/>
</task>
</task>
<task id="31" name="Server" note="" work="489600" start="20190423T000000Z" end="20190511T170000Z" work-start="20190423T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="11" type="FS"/>
</predecessors>
<task id="32" name="Dateien speichern/verwalten" note="" work="172800" start="20190423T000000Z" end="20190504T170000Z" work-start="20190423T080000Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work">
<task id="31" name="Dateien speichern/verwalten" note="" work="172800" start="20190423T000000Z" end="20190504T170000Z" work-start="20190423T080000Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work">
<constraint type="must-start-on" time="20190423T000000Z"/>
</task>
<task id="33" name="Protokoll implementieren" note="" work="172800" start="20190423T000000Z" end="20190504T170000Z" work-start="20190423T080000Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work">
<task id="32" name="Protokoll implementieren" note="" work="172800" start="20190423T000000Z" end="20190504T170000Z" work-start="20190423T080000Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work">
<constraint type="must-start-on" time="20190423T000000Z"/>
</task>
<task id="34" name="Suche implementieren" note="" work="86400" start="20190504T170000Z" end="20190511T170000Z" work-start="20190507T080000Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work">
<task id="33" name="Suche implementieren" note="" work="86400" start="20190504T170000Z" end="20190511T170000Z" work-start="20190507T080000Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="32" type="FS"/>
<predecessor id="1" predecessor-id="31" type="FS"/>
</predecessors>
</task>
<task id="35" name="Hauptlogik implementieren" note="Haupts&#xE4;chlich Glue-Code&#10;&#10;" work="57600" start="20190504T170000Z" end="20190508T170000Z" work-start="20190507T080000Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work">
<task id="34" name="Hauptlogik implementieren" note="Haupts&#xE4;chlich Glue-Code&#10;&#10;" work="57600" start="20190504T170000Z" end="20190508T170000Z" work-start="20190507T080000Z" percent-complete="100" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="33" type="FS"/>
<predecessor id="1" predecessor-id="32" type="FS"/>
<predecessor id="1" predecessor-id="31" type="FS"/>
</predecessors>
</task>
</task>
</task>
<task id="36" name="End of Implementation" note="" work="0" start="20190511T170000Z" end="20190511T170000Z" work-start="20190511T170000Z" percent-complete="0" priority="0" type="milestone" scheduling="fixed-work">
<task id="35" name="End of Implementation" note="" work="0" start="20190612T170000Z" end="20190612T170000Z" work-start="20190612T170000Z" percent-complete="0" priority="0" type="milestone" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="31" type="FS"/>
<predecessor id="1" predecessor-id="22" type="FS"/>
<predecessor id="1" predecessor-id="30" type="FS"/>
<predecessor id="1" predecessor-id="21" type="FS"/>
<predecessor id="1" predecessor-id="20" type="FS"/>
</predecessors>
</task>
<task id="37" name="Abnahme" note="" work="374400" start="20190511T170000Z" end="20190611T170000Z" work-start="20190514T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<task id="38" name="Modultests [M]" note="" work="115200" start="20190511T170000Z" end="20190521T170000Z" work-start="20190514T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<task id="36" name="Abnahme" note="" work="115200" start="20190612T170000Z" end="20190613T170000Z" work-start="20190613T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<task id="37" name="Modultests [M]" note="" work="28800" start="20190612T170000Z" end="20190613T170000Z" work-start="20190613T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="36" type="FS"/>
<predecessor id="1" predecessor-id="35" type="FS"/>
</predecessors>
</task>
<task id="39" name="Integrationstests [M]" note="" work="115200" start="20190521T170000Z" end="20190529T170000Z" work-start="20190522T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<task id="38" name="Integrationstests [M]" note="" work="28800" start="20190612T170000Z" end="20190613T170000Z" work-start="20190613T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="38" type="FS"/>
<predecessor id="1" predecessor-id="35" type="FS"/>
</predecessors>
</task>
<task id="40" name="Systemtests [M]" note="" work="115200" start="20190529T170000Z" end="20190608T170000Z" work-start="20190601T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<task id="39" name="Systemtests [M]" note="" work="28800" start="20190612T170000Z" end="20190613T170000Z" work-start="20190613T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="39" type="FS"/>
<predecessor id="1" predecessor-id="35" type="FS"/>
</predecessors>
</task>
<task id="41" name="Akzeptanztest [M]" note="" work="28800" start="20190608T170000Z" end="20190611T170000Z" work-start="20190611T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<task id="40" name="Akzeptanztest [M]" note="" work="28800" start="20190612T170000Z" end="20190613T170000Z" work-start="20190613T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="40" type="FS"/>
<predecessor id="1" predecessor-id="35" type="FS"/>
</predecessors>
</task>
</task>
@ -186,16 +182,17 @@
<resource id="4" name="Lukas" short-name="L" type="1" units="0" email="" note="" std-rate="0"/>
</resources>
<allocations>
<allocation task-id="33" resource-id="1" units="100"/>
<allocation task-id="29" resource-id="1" units="100"/>
<allocation task-id="32" resource-id="1" units="100"/>
<allocation task-id="8" resource-id="1" units="100"/>
<allocation task-id="13" resource-id="1" units="100"/>
<allocation task-id="11" resource-id="1" units="100"/>
<allocation task-id="5" resource-id="1" units="50"/>
<allocation task-id="29" resource-id="2" units="50"/>
<allocation task-id="28" resource-id="2" units="50"/>
<allocation task-id="8" resource-id="2" units="10"/>
<allocation task-id="17" resource-id="2" units="100"/>
<allocation task-id="5" resource-id="2" units="50"/>
<allocation task-id="29" resource-id="3" units="50"/>
<allocation task-id="28" resource-id="3" units="50"/>
<allocation task-id="15" resource-id="3" units="100"/>
<allocation task-id="12" resource-id="3" units="100"/>
<allocation task-id="10" resource-id="3" units="100"/>

View File

@ -1,6 +1,6 @@
[package]
name = "texture-sync-server"
version = "0.1.0"
version = "1.0.1"
authors = ["CodeSteak <codesteak@shellf.art>"]
edition = "2018"
@ -10,4 +10,4 @@ serde = { version = "1.0.90", features = ["derive"] }
serde_json = "1.0.39"
sha2 = "0.8.0"
lovecraft = "0.2.0"
num_cpus = "1.0"
num_cpus = "1.0"

View File

@ -24,6 +24,8 @@ use std::path::*;
fn main() -> std::io::Result<()> {
lovecraft::invoke();
println!("\n\n\t=== TextureSync Server {} ===\t\n\n\n", env!("CARGO_PKG_VERSION"));
let data_path = Path::new("./data");
println!("loading files from {:?}", data_path);
let server_state = ServerState::new(data_path)?;

View File

@ -66,7 +66,7 @@ impl QueryFilter {
SpecialInName(name) => Score::RequiredMatch(
//
texture.name.contains(name),
texture.name.to_lowercase().contains(&name.to_lowercase()),
),
SpecialBeforeDate(date) => Score::RequiredMatch(texture.added_on <= *date),

2
testdata/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
bin
outputdir

22
testdata/create.sh vendored Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
# use the correct working directory
cd $(dirname "$0")
# compile java code
mkdir -p bin
javac -sourcepath src -d bin src/creation/Creator.java
# recreate output dir
rm -rf outputdir
mkdir -p outputdir/data/textures
# create textures
java -classpath bin creation.Creator
# place a server binary in the output directory
(
cd ../server/texture-sync-server
cargo build --release
)
cp ../server/texture-sync-server/target/release/texture-sync-server ./outputdir/

184
testdata/src/creation/Creator.java vendored Normal file
View File

@ -0,0 +1,184 @@
package creation;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import java.util.UUID;
import javax.imageio.ImageIO;
public class Creator {
public static void main(String[] args) {
Random r = new Random(1);
String basedir = "outputdir/data";
String[] names = NameCreator.generateNames(r);
try {
FileOutputStream collectionOutput = new FileOutputStream(basedir + "/collection.json");
PrintWriter collectionWriter = new PrintWriter(collectionOutput);
collectionWriter.write("{\n \"textures\": [\n ");
boolean first = true;
int i=1;
for (String name : names) {
if (first) {
first = false;
} else {
collectionWriter.write(",\n ");
}
System.out.println("Creating " + name + " (texture " + i + " of " + names.length + ")");
storeImage(name, basedir, r, collectionWriter);
i++;
}
collectionWriter.write("\n ]\n}\n");
collectionWriter.close();
collectionOutput.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private static boolean randBool(Random r, double probability) {
return r.nextDouble() < probability;
}
private static void storeImage(String name, String outputdir, Random r, PrintWriter collectionWriter)
throws IOException {
int size = 256 * (1 << r.nextInt(6));
NamedColor[] shuffling = Dictionary.colors.clone();
NamedColor[] mycolors = new NamedColor[3];
for (int i = 0; i < 3; i++) {
int otherPos = r.nextInt(7 - i) + i;
mycolors[i] = shuffling[otherPos];
shuffling[otherPos] = shuffling[i];
}
MyDate date = randomDate(r);
boolean grey = randBool(r, 0.01);
boolean border = randBool(r, 0.1);
boolean bold = randBool(r, 0.03);
boolean italic = randBool(r, 0.07);
BufferedImage img = createImage(size, name, mycolors, date, grey, border, bold, italic);
File tmpLocation = new File(outputdir + "/tempimage");
ImageIO.write(img, name.substring(name.length() - 3), tmpLocation);
String hash = hashFile(tmpLocation);
String ending = name.substring(name.length() - 3);
if (ending.equals("jpg")) {
ending = "jpeg";
}
tmpLocation.renameTo(new File(outputdir + "/textures/" + hash));
String tags = mycolors[0].name + "\", \"" + mycolors[1].name + "\", \"" + mycolors[2].name;
if (grey) {
tags += "\", \"grey";
}
if (border) {
tags += "\", \"border";
}
if (bold) {
tags += "\", \"bold";
}
if (italic) {
tags += "\", \"italic";
}
collectionWriter.write("{\n");
collectionWriter.write(" \"id\": \"" + UUID.randomUUID() + "\",\n");
collectionWriter.write(" \"name\": \"" + name + "\",\n");
collectionWriter.write(" \"tags\": [\"" + tags + "\"],\n");
collectionWriter.write(" \"format\": \"" + ending + "\",\n");
collectionWriter.write(" \"resolution\": [" + size + ", " + size + "],\n");
collectionWriter.write(" \"added_on\": " + date.asJsonArray() + ",\n");
collectionWriter.write(" \"texture_hash\": \"" + hash + "\"\n");
collectionWriter.write(" }");
}
private static MyDate randomDate(Random r) {
int back = (int) (-300 * Math.log(r.nextDouble()));
return new MyDate(3, 6, 2019).ago(back);
}
private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for (int j = 0; j < bytes.length; j++) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}
private static String hashFile(File f) throws IOException {
byte[] data = Files.readAllBytes(f.toPath());
try {
MessageDigest hash = MessageDigest.getInstance("SHA-256");
byte[] hashval = hash.digest(data);
return bytesToHex(hashval);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return null;
}
}
private static BufferedImage createImage(int size, String name, NamedColor[] colors, MyDate date, boolean grey,
boolean border, boolean bold, boolean italic) {
BufferedImage img = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
Graphics g = img.getGraphics();
// background
if (grey) {
g.setColor(Color.LIGHT_GRAY);
} else {
g.setColor(Color.WHITE);
}
g.fillRect(0, 0, size, size);
// border
if (border) {
int w = size / 40;
int l = size - 2*w;
g.setColor(Color.BLACK);
g.fillRect(w, w, l, w);
g.fillRect(w, w, w, l);
g.fillRect(w, l, l, w);
g.fillRect(l, w, w, l);
}
// text
int fontstyle = Font.PLAIN;
if (bold) {
fontstyle |= Font.BOLD;
}
if (italic) {
fontstyle |= Font.ITALIC;
}
Font f = new Font("Arial", fontstyle, size / 10);
g.setFont(f);
g.setColor(Color.BLACK);
int width = g.getFontMetrics().stringWidth(name);
int basey = size / 2 + g.getFontMetrics().getAscent();
int textheight = g.getFontMetrics().getHeight();
g.drawString(name, (size - width) / 2, basey);
g.drawString(size + " x " + size, (size - width) / 2, basey + textheight);
g.drawString(date.asReadableString(), (size - width) / 2, basey + 2 * textheight);
// color dots
for (int i = 0; i < 3; i++) {
NamedColor current = colors[i];
g.setColor(current.color);
g.fillOval((1 + 3 * i) * size / 10, size * 3 / 10, size / 5, size / 5);
}
return img;
}
}

16
testdata/src/creation/Dictionary.java vendored Normal file
View File

@ -0,0 +1,16 @@
package creation;
import java.awt.Color;
public class Dictionary {
public static final String[] adjectives = { "fast", "slow", "long", "short", "fat", "big", "small", "angry",
"awful", "calm", "clever", "crazy", "dirty", "excited", "evil", "kind", "lucky", "poor", "shy", "soft",
"tall", };
public static final String[] animals = { "bat", "bee", "camel", "cat", "chicken", "cod", "deer", "dog", "duck",
"fly", "fox", "frog", "horse", "koala", "lion", "mouse", "owl", "pig", "rabbit", "rat", "tiger", "turtle",
"wolf", "zebra" };
public static final NamedColor[] colors = { new NamedColor("red", Color.RED),
new NamedColor("orange", Color.ORANGE), new NamedColor("yellow", Color.YELLOW),
new NamedColor("green", Color.GREEN), new NamedColor("blue", Color.BLUE),
new NamedColor("magenta", Color.MAGENTA), new NamedColor("black", Color.BLACK), };
}

66
testdata/src/creation/MyDate.java vendored Normal file
View File

@ -0,0 +1,66 @@
package creation;
public class MyDate {
public final int day, month, year;
public MyDate(int day, int month, int year) {
if (!isValid(day, month, year)) {
throw new IllegalArgumentException("Invalid date");
}
this.day = day;
this.month = month;
this.year = year;
}
public String asJsonArray() {
return "[" + year + ", " + month + ", " + day + "]";
}
public String asReadableString() {
return twoDigit(day) + "." + twoDigit(month) + "." + twoDigit(year);
}
public MyDate previous() {
if (isValid(day - 1, month, year)) {
return new MyDate(day - 1, month, year);
}
for (int possibleDay = 31; possibleDay >= 28; possibleDay--) {
if (isValid(possibleDay, month - 1, year)) {
return new MyDate(possibleDay, month - 1, year);
}
}
return new MyDate(31, 12, year - 1);
}
public MyDate ago(int number) {
MyDate d = this;
for (int i=0; i<number; i++) {
d = d.previous();
}
return d;
}
private static String twoDigit(int x) {
String s = ""+x;
while (s.length() < 2) {
s = "0"+s;
}
return s;
}
private boolean isValid(int day, int month, int year) {
int[] monthLengths = new int[] { 31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (month < 1 || month > 12) {
return false;
}
int length = monthLengths[month - 1];
if (day < 1 || day > length) {
return false;
}
return true;
}
private boolean isLeapYear(int year) {
return (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0);
}
}

35
testdata/src/creation/NameCreator.java vendored Normal file
View File

@ -0,0 +1,35 @@
package creation;
import java.util.ArrayList;
import java.util.Random;
public class NameCreator {
private static void shuffle(ArrayList<String> list, Random r) {
for (int low=0; low<list.size()-1; low++) {
int high = r.nextInt(list.size() - low) + low;
// swap
String sLow = list.get(low);
String sHigh = list.get(high);
list.set(low, sHigh);
list.set(high, sLow);
}
}
public static String[] generateNames(Random r) {
ArrayList<String> names = new ArrayList<>();
for (String ending : new String[] {"jpg", "png"}) {
for (String animal : Dictionary.animals) {
for (String adjective : Dictionary.adjectives) {
String name = adjective + "-" + animal + "." + ending;
names.add(name);
}
}
}
shuffle(names, r);
while (names.size() > 1000) {
names.remove(names.size() - 1);
}
return names.toArray(new String[1000]);
}
}

13
testdata/src/creation/NamedColor.java vendored Normal file
View File

@ -0,0 +1,13 @@
package creation;
import java.awt.Color;
public class NamedColor {
public final String name;
public final Color color;
public NamedColor(String name, Color color) {
this.name = name;
this.color = color;
}
}