Implemented JavaFx app, but could not test if it works
This commit is contained in:
parent
807228f869
commit
f88070181d
|
@ -58,7 +58,11 @@ kotlin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val jvmMain by getting
|
val jvmMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation("com.google.zxing:javase:3.4.1")
|
||||||
|
}
|
||||||
|
}
|
||||||
val jvmTest by getting {
|
val jvmTest by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("test-junit"))
|
implementation(kotlin("test-junit"))
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package net.codinux.banking.epcqrcode
|
||||||
|
|
||||||
|
import com.google.zxing.BarcodeFormat
|
||||||
|
import com.google.zxing.EncodeHintType
|
||||||
|
import com.google.zxing.client.j2se.MatrixToImageWriter
|
||||||
|
import com.google.zxing.qrcode.QRCodeWriter
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
|
||||||
|
|
||||||
|
class QrCodeGenerator {
|
||||||
|
|
||||||
|
fun generateQrCode(informationToEncode: String, config: EncodeToQrCodeConfig = EncodeToQrCodeConfig()): ByteArray {
|
||||||
|
val hints = mutableMapOf<EncodeHintType, Any>()
|
||||||
|
|
||||||
|
hints[EncodeHintType.CHARACTER_SET] = config.encoding.name
|
||||||
|
|
||||||
|
val bitMatrix = QRCodeWriter().encode(informationToEncode, BarcodeFormat.QR_CODE, config.width, config.height, hints)
|
||||||
|
|
||||||
|
val outputStream = ByteArrayOutputStream()
|
||||||
|
MatrixToImageWriter.writeToStream(bitMatrix, config.format.name, outputStream)
|
||||||
|
outputStream.flush()
|
||||||
|
|
||||||
|
return outputStream.toByteArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,9 +7,19 @@ plugins {
|
||||||
|
|
||||||
group = "net.codinux.banking.epcqrcode.javafx"
|
group = "net.codinux.banking.epcqrcode.javafx"
|
||||||
|
|
||||||
|
val mainClassName = "net.codinux.banking.epcqrcode.EpcQrCodeJavaFxAppKt"
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation(kotlin("test-junit"))
|
implementation(project(":EpcQrCode"))
|
||||||
|
|
||||||
|
implementation("net.dankito.utils:java-fx-utils:1.0.8")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile>() {
|
tasks.withType<KotlinCompile>() {
|
||||||
|
@ -17,5 +27,34 @@ tasks.withType<KotlinCompile>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClassName = "MainKt"
|
mainClassName = mainClassName
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tasks.withType<Jar> {
|
||||||
|
isZip64 = true
|
||||||
|
|
||||||
|
// If one of the source JARs is signed, merging it into one fat jar destroys the signature -> remove signatures
|
||||||
|
// (but may runs into problems with jars that require a valid signature like BouncyCastle, see
|
||||||
|
// https://stackoverflow.com/questions/51455197/gradle-fatjar-could-not-find-or-load-main-class)
|
||||||
|
exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA")
|
||||||
|
|
||||||
|
manifest {
|
||||||
|
attributes(mapOf(
|
||||||
|
"Main-Class" to mainClassName,
|
||||||
|
"Implementation-Title" to "EPC QR Code",
|
||||||
|
"Implementation-Version" to "1.0.0-SNAPSHOT"
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
|
||||||
|
// To add all of the dependencies
|
||||||
|
from(sourceSets.main.get().output)
|
||||||
|
|
||||||
|
dependsOn(configurations.runtimeClasspath)
|
||||||
|
from({
|
||||||
|
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
|
||||||
|
})
|
||||||
}
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
fun main(args: Array<String>) {
|
|
||||||
println("Hello World!")
|
|
||||||
}
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package net.codinux.banking.epcqrcode
|
||||||
|
|
||||||
|
import javafx.application.Application
|
||||||
|
import net.codinux.banking.epcqrcode.windows.main.MainWindow
|
||||||
|
import net.dankito.utils.javafx.ui.Utf8App
|
||||||
|
|
||||||
|
|
||||||
|
class EpcQrCodeJavaFxApp : Utf8App("Messages", MainWindow::class) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
Application.launch(EpcQrCodeJavaFxApp::class.java, *args)
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package net.codinux.banking.epcqrcode.windows.main
|
||||||
|
|
||||||
|
import javafx.beans.property.SimpleObjectProperty
|
||||||
|
import javafx.scene.image.Image
|
||||||
|
import tornadofx.*
|
||||||
|
import java.io.ByteArrayInputStream
|
||||||
|
import net.codinux.banking.epcqrcode.MppTest
|
||||||
|
import net.codinux.banking.epcqrcode.QrCodeGenerator
|
||||||
|
|
||||||
|
|
||||||
|
class MainWindow : View(FX.messages["application.title"]) {
|
||||||
|
|
||||||
|
private val qrCodeGenerator = QrCodeGenerator()
|
||||||
|
|
||||||
|
private val qrCode = SimpleObjectProperty<Image>(generateQrCode(MppTest().getTestEpcQrCodeContent()))
|
||||||
|
|
||||||
|
|
||||||
|
override val root = vbox {
|
||||||
|
imageview(qrCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun generateQrCode(informationToEncode: String): Image? {
|
||||||
|
val qrCodeBytes = qrCodeGenerator.generateQrCode(informationToEncode)
|
||||||
|
|
||||||
|
return Image(ByteArrayInputStream(qrCodeBytes))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
application.title=EPC QR Code
|
||||||
|
|
||||||
|
|
||||||
|
ok=OK
|
||||||
|
cancel=Cancel
|
||||||
|
|
||||||
|
|
||||||
|
main.window.menu.file=File
|
||||||
|
main.window.menu.file.quit=Quit
|
|
@ -0,0 +1,9 @@
|
||||||
|
application.title=EPC QR Code
|
||||||
|
|
||||||
|
|
||||||
|
ok=OK
|
||||||
|
cancel=Abbrechen
|
||||||
|
|
||||||
|
|
||||||
|
main.window.menu.file=Datei
|
||||||
|
main.window.menu.file.quit=Beenden
|
Loading…
Reference in New Issue