tri.promptfx.PromptFx.kt Maven / Gradle / Ivy
/*-
* #%L
* tri.promptfx:promptfx
* %%
* Copyright (C) 2023 - 2024 Johns Hopkins University Applied Physics Laboratory
* %%
* 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
*
* http://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.
* #L%
*/
package tri.promptfx
import javafx.scene.Cursor
import javafx.scene.paint.Color
import javafx.scene.text.TextAlignment
import org.apache.commons.logging.LogFactory
import org.apache.commons.logging.impl.Jdk14Logger
import org.apache.pdfbox.pdmodel.font.PDSimpleFont
import tornadofx.*
import tri.promptfx.docs.DocumentQaView
import java.util.logging.Level
import kotlin.system.exitProcess
class PromptFx : App(PromptFxWorkspace::class, PromptFxStyles::class) {
val promptFxConfig : PromptFxConfig by inject()
override fun init() {
promptFxConfig.isStarshipEnabled = parameters.raw.contains("starship")
}
override fun onBeforeShow(view: UIComponent) {
workspace.dock()
}
override fun stop() {
workspace.find().close()
promptFxConfig.save()
super.stop()
// exit process after 2-second timer that runs in the background
// to allow for any cleanup to occur
Thread {
Thread.sleep(2000)
exitProcess(0)
}.start()
}
}
fun main(args: Array) {
(LogFactory.getLog(PDSimpleFont::class.java) as? Jdk14Logger)?.apply {
logger.level = Level.SEVERE
}
launch(args)
}
/** Stylesheet for the application. */
class PromptFxStyles: Stylesheet() {
companion object {
val transparentTextArea by cssclass()
val scrollPane by cssclass()
val content by cssclass()
}
init {
transparentTextArea {
cursor = Cursor.TEXT
textFill = Color.WHITE
fontFamily = "Serif"
textAlignment = TextAlignment.CENTER
scrollPane {
content {
backgroundColor += Color.TRANSPARENT
borderColor += box(Color.TRANSPARENT)
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy