Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • heevtont/ohj2
  • ojmannex/ohj2
  • veosvuol/ohj2
  • teoilalo/ohj2
  • pakakata/ohj2
  • tie/ohj2/2023k/ohj2
  • jupesate/ohj2
  • olrutane/ohj2
  • vesal/ohj-2-k-23
  • alejarta/ohj2
  • romaasun/ohj2
  • maxvitik/ohj2
  • jatakarj/ohj2
  • forsheal/harjoitustyo
  • paemhiet/ohj2
  • onhuhtal/ohj2
  • peukteni/ohj2
  • kallvaxu/ohj-2-ht-kasityorekisteri
  • piipjuhe/ohj2
  • alanenee/ohj2
  • osterava/ohj2
  • savolpet/ohj2
  • jaalsiik/ohj2
  • jbpalola/ohj2
  • khakarpp/ohj2
  • sokapalo/ohj2
  • luomkohe/ohj2
  • ltahonex/ohj2
  • hejojurv/ohj-2-sukupuu
  • karkhkxy/ohj2
  • vewaheik/ohj2
  • tejumeri/ohj2
  • erkkjjyv/ohj2
  • kkautio/ohj2
  • jaeianro/ohj2
  • olmisalo/ohj2
  • ukkolaaa/ohj2
  • esbrunil/ohj2
  • pjsavola/ohj2
  • mosaluht/jasenrekisteri
  • nviianen/ohj2
  • eetpatsu/ohj2
  • iinelipi/ohj2
  • kaupkama/ohj2
  • myyryejk/ohj-2-ht-myyry
  • mnjtiili/ohj2
  • leppanm/ohj2
  • malineps/ohj2
  • antulepp/ohj-2-b
  • helatukk/ohj2
  • aaahalom/ohj2
  • juvonevi/ruokanaattori
  • atkaanhe/ohj2
  • jypemiko/ohj2-23
  • anuemiko/ohj2
  • lvvuolle/ohj2
  • valkeiti/ohj-2
  • suvileos/ohj2
  • mikpekpu/ohj2
  • savevalo/ohj2
  • martiksm/ohj2
  • enlejuhe/ohj2
  • eealhakk/ohj-2-ht
  • savomaaa/ohj2
  • elkrleht/ohj2
  • maospelt/ohj2
  • tufiras/ohj2
  • lihavavy/ohj2
  • pepihlaj/ohj2
  • urpiteju/ohj2
  • aetakala/ohj-2-ht
  • tjkajant/ohj2
  • remoneve/ohj2
  • jeismont/ohj2
  • mietanai/ohj2
  • inkilaka/ohj2
  • pmruusu/ohj2
  • pykakimp/reseptirekisteriprojekti
  • mielarju/ohj2
  • jmjleixu/ohj2
  • kalakoiv/ohj2
  • meamalxv/ohj2
  • heinota/ohj2
  • majauusi/ohj2
  • tusakki/ohj2
  • jjpahkin/ohj2
  • nurmimk/ohj2
  • mieemalo/ohj2
  • idmahako/ohj2
  • ajrautia/ohj2
  • evaltaiv/ohj2
  • vevajoki/ohj2
  • vijumato/ohj2
  • nikrantt/ohj2
  • kupialnx/ohj2
  • jujukest/ohj2ht
  • aojuntun/ohj2
  • jhthorxu/ohj2
  • aaaalto/ohj2
  • haggpoo/ohj2
  • mialniem/ohj2
  • marteevi/ohj2
  • amslappi/ohj2
  • jiheikzt/ohj2
  • elbeeltv/ohj2
  • virommss/ohj2
  • tootuoka/ohj2
  • hasultxt/ohj-2
  • laanmaat/ohj-2-2023
  • laueerjo/ohj2
  • jutakoir/osrsprocesspal
  • alalojap/ohj2
  • joaahirv/ohj2
  • venmaamo/ohj2
  • jejaolpa/ohj2
  • anbudano/ohj2
  • peolkyll/ohj2
  • blomerjo/ohj2
  • aasahonk/ohj2
  • lapahama/ohj2
  • karpot/ohj2
  • psbroman/ohj2
  • vemakael/ohj2
  • alninybe/harkkatyo
  • tosakorh/ohj-2-k-23
  • ntkumpul/ntkumpul
  • riiijoko/ohj-2-2023
127 results
Show changes
Commits on Source (96)
Showing
with 1126 additions and 6 deletions
......@@ -42,12 +42,12 @@ out/
*.iml
*.ipr
*.iws
htmlReport/
##############################
## Eclipse
##############################
.settings/
bin/
tmp/
.metadata
*.tmp
......@@ -61,7 +61,6 @@ local.properties
## NetBeans
##############################
nbproject/private/
build/
nbbuild/
dist/
nbdist/
......@@ -71,4 +70,9 @@ nb-configuration.xml
##############################
## OS X
##############################
.DS_Store
\ No newline at end of file
.DS_Store
##############################
## Other general files
##############################
*.log
\ No newline at end of file
# pohja
<img align="center" src="kuvat/ronove128.png">
Pohja kevään 2023 harjoitustöiden GIT-repoille
# Ronove
Lue käyttöohjeet TIMistä: <https://tim.jyu.fi/view/kurssit/tie/ohj2/tyokalut/git/ohj2git#fork>
Työkalu tekstin manuaaliseen käyttämiseen konekäännöksellä tuettuna.
![](kuvat/paaikkuna.gif)
\ No newline at end of file
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.8.0"
application
id("org.jetbrains.dokka") version "1.7.20"
}
group = "me.theka"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven { url = uri("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") }
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://mvnrepository.com/artifact/com.google.cloud/google-cloud-translate") }
}
dependencies {
implementation("no.tornado:tornadofx:1.7.20")
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.8.0")
implementation("com.deepl.api:deepl-java:1.0.1")
implementation("com.google.cloud:google-cloud-translate:2.8.0")
implementation("com.fasterxml.woodstox:woodstox-core:6.5.0")
platform("com.google.cloud:libraries-bom:26.1.4")
testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
testImplementation("org.testfx:testfx-core:4.0.16-alpha")
testImplementation("org.testfx:testfx-junit5:4.0.16-alpha")
testImplementation("org.assertj","assertj-core","3.13.2")
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.7.20")
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
application {
mainClass.set("guru.kake.ronove.Ronove")
}
tasks {
val fatJar = register<Jar>("fatJar") {
dependsOn.addAll(listOf("compileJava", "compileKotlin", "processResources")) // We need this for Gradle optimization to work
archiveClassifier.set("standalone") // Naming the jar
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest { attributes(mapOf("Main-Class" to application.mainClass)) } // Provided we set it up in the application plugin configuration
val sourcesMain = sourceSets.main.get()
val contents = configurations.runtimeClasspath.get()
.map { if (it.isDirectory) it else zipTree(it) } +
sourcesMain.output
from(contents)
}
build {
dependsOn(fatJar) // Trigger fat jar creation during build
}
}
\ No newline at end of file
kotlin.code.style=official
\ No newline at end of file
File added
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
This diff is collapsed.
kuvat/mtlsettings.png

6.96 KiB

kuvat/paaikkuna.gif

78 KiB

kuvat/projectsettings.png

7.79 KiB

kuvat/ronove128.png

5.91 KiB

kuvat/splash.png

14.6 KiB

rootProject.name = "ht2"
package guru.kake.ronove
import guru.kake.xmlp.XMLParser
import java.io.FileInputStream
import java.io.InputStream
import javax.xml.stream.XMLEventReader
import javax.xml.stream.XMLInputFactory
import javax.xml.stream.events.XMLEvent
/**
* Kanjidic2 Kanji dictionary character
* @param literal representation as kanji symbol
*/
class Character(var literal: String = "") : Comparable<Character> {
/** Readings and meanings */
var rmgroups: MutableList<RMGroup> = mutableListOf()
override fun equals(other: Any?): Boolean {
if (other is Character) {
return literal == other.literal
}
return super.equals(other)
}
override fun compareTo(other: Character): Int = literal.compareTo(other.literal)
override fun hashCode(): Int = literal.hashCode()
}
/**
* Combinations of readings and meanings for a dictionary entry
*/
class RMGroup {
/** Readings of the character as Pair of reading type, reading */
var reading: MutableList<Pair<String?, String>> = mutableListOf()
/** Meadings of the character as Pair of reading language (null for English), meaning */
var meaning: MutableList<Pair<String?, String>> = mutableListOf()
}
/**
* JMdict phrase
* @param japanese phrase in Japanese
*/
class Phrase(var japanese: String) : Comparable<Phrase> {
/** Collection of meanings and translations for a phrase */
var senses: MutableList<Sense> = mutableListOf()
override fun equals(other: Any?): Boolean {
if (other is Phrase) {
return japanese == other.japanese
}
return super.equals(other)
}
override fun compareTo(other: Phrase): Int = japanese.compareTo(other.japanese)
override fun hashCode(): Int = japanese.hashCode()
}
/**
* Translation for a JMdict entry
*/
class Sense {
/** List of translations */
var glosses: MutableList<String> = mutableListOf()
}
/**
* Collection of functions to parse several dictionary files provided by EDRDG.
* Use functions under companion object, an instance of this class is not needed.
* See https://www.edrdg.org/
*/
class DictionaryParser private constructor() {
companion object {
private val xmlInputFactory: XMLInputFactory = XMLInputFactory.newInstance()
/**
* Parses Kanjidic2 as provided by EDRDG from a file found in path
* See https://www.edrdg.org/wiki/index.php/KANJIDIC_Project
*/
fun parseKanjidic2(path: String): List<Character> = parseKanjidic2(FileInputStream(path))
/**
* Parses Kanjidic2 as provided by EDRDG from any [InputStream]
* See https://www.edrdg.org/wiki/index.php/KANJIDIC_Project
*/
fun parseKanjidic2(stream: InputStream) : List<Character> {
val parsed: MutableList<Character> = mutableListOf()
var character: Character? = null
var rmgroup: RMGroup? = null
XMLParser.parse(stream) {
element("character") {
start { character = Character() }
end {
parsed.add(character!!)
character = null
}
}
element("literal") {
start { character!!.literal = content()!! }
}
element("reading_meaning") {
start { rmgroup = RMGroup() }
end {
character!!.rmgroups.add(rmgroup!!)
rmgroup = null
}
}
element("meaning") {
start {
rmgroup!!.meaning.add(Pair(
attribute("m_lang"),
content()!!
))
}
}
element("reading") {
start {
rmgroup!!.reading.add(Pair(
attribute("r_type"),
content()!!
))
}
}
}
return parsed.toList()
}
/**
* Parses JMdict as provided by EDRDG
* See https://www.edrdg.org/wiki/index.php/JMdict-EDICT_Dictionary_Project
*/
fun parseJMdict(path: String): List<Phrase> {
//TODO: DSL
val parsed: MutableList<Phrase> = mutableListOf()
val phrases: MutableList<Phrase> = mutableListOf()
var sense: Sense? = null
val reader: XMLEventReader = xmlInputFactory.createXMLEventReader(FileInputStream(path))
while (reader.hasNext()) {
val nextEvent: XMLEvent = reader.nextEvent()
when {
nextEvent.isStartElement -> {
val startElement = nextEvent.asStartElement()
when (startElement.name.localPart.toString()) {
//"entry" -> phrase = Character()
"keb" -> {
phrases.add(Phrase(reader.nextEvent().asCharacters().data))
}
"reb" -> {
}
"sense" -> {
sense = Sense()
}
"gloss" -> {
sense!!.glosses.add(reader.nextEvent().asCharacters().data)
}
}
}
nextEvent.isEndElement -> {
when (nextEvent.asEndElement().name.localPart.toString()) {
"entry" -> {
parsed.addAll(phrases)
phrases.clear()
}
"sense" -> {
phrases.forEach { it.senses.add(sense!!) }
}
}
}
}
}
return parsed.toList()
}
}
}
\ No newline at end of file
package guru.kake.ronove
import guru.kake.bst.BST
import javafx.scene.control.TextField
import javafx.scene.text.FontSmoothingType
import kotlinx.html.*
import kotlinx.html.stream.createHTML
import netscape.javascript.JSObject
import tornadofx.*
/**
* Tab class to display text using HTML formatting
*/
class ReaderTab : View("Reader") {
private val cbobject: WebViewCallback = WebViewCallback()
/** TornadoFX root */
override val root = vbox {
webview {
style {
fontSmoothingType = FontSmoothingType.GRAY
}
engine.loadContent(createHTML().html {
head {
style {
unsafe { raw("body { font-size: 48px; }") }
}
}
body {
onLoad = "alert()"
p {
ruby { +"私"; rt { +"わたし" }}
+"の"
ruby { +"猫"; rt { +"ねこ" }}
+"わかわいいです"
ruby("a") {+"b"}
a("#") {
onClick = "cb.test('foo');"
+"linkki"
}
}
}
})
engine.setOnAlert {
(engine.executeScript("window") as JSObject).setMember("cb", cbobject)
}
}
}
}
/**
* Class for receiving events from JS in [ReaderTab]
*/
@Suppress("unused") //IDEA doesn't detect uses of these functions since they are called from JS in the WebView
class WebViewCallback {
/***/
fun test(message: String) {
println(message)
}
}
/**
* Tab class for displaying dictionaries
*/
class DictionaryTab : View("Kanji Dictionary") {
private val ret = DictionaryParser.parseKanjidic2("C:\\repos\\kanjisho\\kanjidic2.xml")
private val tree = BST(ret)
/** TornadoFX root */
override val root = vbox {
(app as Ronove).cellSelection.addListener(fun(_, _, newSelection) {
if (newSelection != null) {
getCharacters(newSelection.original)
}
})
this += searchBox()
}
private fun searchBox() = hbox {
val search = textfield()
button("Search") {
action {
getCharacters(search.text)
}
}
}
private fun getCharacters(chars: String) {
root.clear()
root += searchBox()
chars.forEach { getCharacter(it.toString()) }
}
private fun getCharacter(char: String) {
val c = tree.find(Character(char))
if (c != null) {
val kun: String = c.rmgroups[0].reading.find { it.first == "ja_kun" }?.second ?: ""
val on: String = c.rmgroups[0].reading.find { it.first == "ja_on" }?.second ?: ""
val meaning: String = c.rmgroups[0].meaning.find { it.first == null }?.second ?: ""
root += DictionaryEntry(c.literal, kun, on, meaning)
}
}
}
/**
* TornadoFX fragment to display information on a Kanji
* @param kanji the kanji
* @param kun kunyomi reading
* @param on onyomi reading
* @param meaning English meaning of the kanji
*/
class DictionaryEntry(
private val kanji: String,
private val kun: String,
private val on: String,
private val meaning: String
) : Fragment("") {
/** TornadoFX root */
override val root = hbox {
label(kanji) {
addClass(RonoveStylesheet.bigLabel)
}
vbox {
label("Kun: $kun")
label("On: $on")
label(meaning)
}
}
}
/**
* Tab class for displaying original material in image form
*/
class ImageTab : View("Image") {
/** TornadoFX root */
override val root = vbox {
imageview("/yopage.jpg") {
fitWidth = 300.0
isPreserveRatio = true
isSmooth = true
}
}
}
/**
* Tab class for a separate window letting the user run arbitrary strings through machine translation
*/
class TranslatorTab : View("Machine translation") {
private var fromField: TextField by singleAssign()
private var toField: TextField by singleAssign()
//TODO allow switching languages on the fly
/** TornadoFX root */
override val root = vbox {
vbox {
label("Japanese")
fromField = textfield()
button("To English") {
action {
TranslationBackend.destinationLanguage = "en-US"
TranslationBackend.sourceLanguage = "ja"
toField.text = TranslationBackend(fromField.text)
}
}
}
vbox {
label("English")
toField = textfield()
button("To Japanese") {
action {
TranslationBackend.destinationLanguage = "ja"
TranslationBackend.sourceLanguage = "en"
fromField.text = TranslationBackend(toField.text)
}
}
}
}
}
\ No newline at end of file
package guru.kake.ronove
import javafx.collections.FXCollections
import javafx.scene.image.Image
import javafx.stage.Modality
import javafx.stage.StageStyle
import tornadofx.*
import kotlin.system.exitProcess
/**
* The main window of the program
*/
class MainView : View("Ronove") {
/** TornadoFX root */
override val root = borderpane {
//Main menu
top = menubar {
menu("File") {
item("New project...") { action { TODO() } }
item("New empty project") { action { (app as Ronove).project.new() } }
separator()
item("Open...","Shortcut+O") { action { (app as Ronove).project.open() }}
menu("Open recent") {
item("Recent 1")
item("Recent 2")
item("Recent 3")
item("Recent 4")
item("Recent 5")
}
separator()
item("Save","Shortcut+S") {
action { (app as Ronove).project.save() }
enableWhen {(app as Ronove).project.projectFileSet}
}
item("Save as...","Shortcut+Shift+S") { action { (app as Ronove).project.saveAs() }}
item("Export...") { action { TODO() } }
separator()
item("Exit") {
action {
//TODO: Confirm unsaved changes
exitProcess(0)
}
}
}
menu("Edit") {
item("Add page") { action { (app as Ronove).addPage() } }
item("Remove page") { action { (app as Ronove).removePage() } }
separator()
item("Add line","Shortcut+N") { action { (app as Ronove).addLine() } }
//item("Remove line") { action { TODO() } }
separator()
item("Project settings...") { action { TODO() } }
}
menu("Machine translation") {
item("Translate line") { action { TODO() } }
item("Translate page") { action { TODO() } }
item("Translate all pages") { action { TODO() } }
separator()
item("Machine translation settings...") {
action {
TranslationSettings().openModal()
}
}
}
menu("Dictionary") {
item("Project dictionary...")
item("User dictionary...")
}
menu("Help") {
item("Help")
item("About")
}
}
//Table view for editing data
center {
this += TranslationPageView(app as Ronove)
}
//Status bar
bottom = hbox {
label("MTL: Deepl | ")
label("API quota ")
progressbar(TranslationBackend.quotaProperty)
label(" 48 / 500,000 | ")
val providers = FXCollections.observableArrayList("DeepL","Google Translate")
combobox(values = providers)
}
//Drawer for tabbed tools
right = drawer(multiselect = true) {
fixedContentSize = 300.0
maxWidth = 100.0
item<ImageTab> {
maxWidth = 100.0
}
item<ReaderTab>()
item<DictionaryTab>()
item<TranslatorTab>()
}
}
init {
primaryStage.icons.add(Image("/ronove128.png"))
SplashScreen((app as Ronove).project).openModal(stageStyle = StageStyle.UTILITY, block = true,
modality = Modality.APPLICATION_MODAL, owner = primaryStage)
}
}
\ No newline at end of file
package guru.kake.ronove
import javafx.beans.property.SimpleBooleanProperty
import javafx.stage.FileChooser
import tornadofx.FileChooserMode
import tornadofx.chooseFile
import java.io.File
import java.io.PrintWriter
import kotlin.reflect.KProperty1
/**
* Class for holding the data of the entire translation project, which consists of pages consisting of lines.
*/
class Project {
/** Last used file for saving, updated on Load/Save as */
private var projectFile: File? = null
/** Observable denoting if projectfile is set */
var projectFileSet = SimpleBooleanProperty(false)
/** Pages of the project */
var pages: MutableList<Page> = mutableListOf(Page())
/** Prompts user for project file to open and loads it */
fun open() {
val file = chooseFile("Open...",
arrayOf(
FileChooser.ExtensionFilter("Ronove project files", "*.rvp", "*.RVP"),
FileChooser.ExtensionFilter("All files", "*")
),
mode=FileChooserMode.Single
)
if (file.isEmpty()) return
loadFile(file[0])
projectFile = file[0]
projectFileSet.value = true
}
/** Prompts user for project file to open and saves to it */
fun saveAs() {
val file = chooseFile("Save as..",
arrayOf(
FileChooser.ExtensionFilter("Ronove project files", "*.rvp", "*.RVP"),
FileChooser.ExtensionFilter("All files", "*")
),
mode=FileChooserMode.Save
)
if (file.isEmpty()) return
saveFile(file[0])
projectFile = file[0]
projectFileSet.value = true
}
fun save() = projectFile?.let { saveFile(it) }
fun new() {
pages = mutableListOf()
projectFile = null
projectFileSet.value = false
}
private fun loadFile(file: File) {
if (!file.exists()) return
new()
file.bufferedReader().use { reader ->
var line: String?
while (reader.readLine().also { line = it } != null) {
println(line)
if (line!!.startsWith('#')) {
pages.add(Page())
} else {
pages.last().lines.add(Line(line!!))
}
}
}
}
private fun saveFile(file: File) {
file.printWriter().use { writer ->
var pageNumber = 1
for (page in pages) {
writer.println("#${pageNumber++}")
page.save(writer)
}
}
}
}
/**
* Class for holding the data of a single translation page
*/
class Page(lines: Collection<Line> = listOf()) {
/** Lines on a page */
var lines: MutableList<Line> = lines.toMutableList()
/**
* Get a specific column of the page as a list
* @param column the column to get, for example [Line::original]
* @return list containing the elements of the column
*/
fun getColumn(column: KProperty1<Line, String>) : List<String> = buildList {
for (line in lines) add(column.get(line))
}
/**
* Translates all lines on page
*/
fun translatePage() {
TranslationBackend(getColumn(Line::original)).zip(lines).forEach { (translation, line) ->
line.machineTranslation = translation
}
}
/**
* Debug function for printing a page in stdout
*/
@Deprecated("For debug use only", level = DeprecationLevel.WARNING)
fun debugPrint() {
for (line in lines) {
println("${line.original}: ${line.machineTranslation}")
}
}
fun save(writer: PrintWriter) {
for (line in lines) {
with(line) {
writer.println("$original|$machineTranslation|$finalTranslation|$notes")
}
}
}
}
/**
* Class for holding the data of a single line of translation
*/
data class Line(
/** Original, untranslated text */
var original: String = "",
/** Machine translation of the original */
var machineTranslation: String = "",
/** Manual, finalized translation*/
var finalTranslation: String = "",
/** Translator notes for the line */
var notes: String = ""
) {
constructor(s: String) : this() {
val args = s.split('|')
original = args.getOrElse(0) { "" }
machineTranslation = args.getOrElse(1) { "" }
finalTranslation = args.getOrElse(2) { "" }
notes = args.getOrElse(3) { "" }
}
}
\ No newline at end of file
package guru.kake.ronove
import javafx.scene.control.ToggleGroup
import tornadofx.*
/**
* View for initializing new and editing existing projects' settings
*/
class ProjectSettings : View("Ronove") {
private val toggleGroup = ToggleGroup()
/** TornadoFX root */
override val root = form {
//val numbers = (1..10).toList()
val kittens = listOf("https://i.imgur.com/DuFZ6PQb.jpg", "https://i.imgur.com/o2QoeNnb.jpg")
fieldset {
field("Project name") {
textfield()
}
field("Folder") {
textfield()
button("Open...")
}
hbox(20) {
field("Language") {
combobox<String> {
}
}
field("to") {
combobox<String> {
}
}
}
field("Source files") {
radiobutton("Text", toggleGroup)
radiobutton("Images", toggleGroup)
radiobutton("None", toggleGroup)
}
}
datagrid(kittens) {
cellHeight = 150.0
cellWidth = 150.0
multiSelect = true
cellCache {
vbox {
imageview(it) {
fitWidth = 150.0
fitHeight = 120.0
isPreserveRatio = true
}
label(it)
}
}
}
fieldset {
field {
button("|<")
button("<")
button("Add...")
button("Remove")
button("Sort")
button(">")
button(">|")
}
field {
button("Cancel")
button("Confirm")
}
}
}
}
\ No newline at end of file