Skip to content

Commit

Permalink
feat: add the functionality of switching between views for different …
Browse files Browse the repository at this point in the history
…trees
  • Loading branch information
SurfaceYellowDuck committed Apr 27, 2023
1 parent f83512f commit c52816b
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id("org.jetbrains.kotlin.jvm") version "1.8.10"
id("org.openjfx.javafxplugin") version "0.0.8"
id("org.openjfx.javafxplugin") version "0.0.12"
application
}

javafx {
version = "11.0.2"
modules("javafx.controls")
version = "17"
modules ( "javafx.controls", "javafx.fxml" )
}

repositories {
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/kotlin/app/App.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package app

import app.view.MainView
import javafx.stage.Stage
import tornadofx.*

class MainApp: App(MainView::class)
class MainApp: App(MainView::class){
override fun start(stage: Stage) {
with(stage){
width = 600.0
height = 400.0
}
super.start(stage)
}
}

fun main() {
launch<MainApp>()
Expand Down
15 changes: 10 additions & 5 deletions app/src/main/kotlin/app/view/MainView.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package app.view

import app.view.treeView.BinarySearchTreeView
import tornadofx.*

class MainView: View("Trees") {
override val root = vbox {
button("Hello, World!")
label("Waiting")
class MainView: View(){
private val tree = BinarySearchTreeView()
override val root = borderpane {
center{
add(tree)
}
left{
button("reset")
}
}
}
16 changes: 16 additions & 0 deletions app/src/main/kotlin/app/view/treeView/AVLTreeView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package app.view.treeView
import tornadofx.*
class AVLTreeView: View() {
override val root = vbox {
button("Binary Search Tree") {
action {
replaceWith<BinarySearchTreeView>()
}
}
button("Red Black Tree") {
action {
replaceWith<RedBlackTreeView>()
}
}
}
}
17 changes: 17 additions & 0 deletions app/src/main/kotlin/app/view/treeView/BinarySearchTreeView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package app.view.treeView
import tornadofx.*

class BinarySearchTreeView: View() {
override val root = vbox {
button("AVL Tree") {
action {
replaceWith<AVLTreeView>()
}
}
button("Red Black Tree") {
action {
replaceWith<RedBlackTreeView>()
}
}
}
}
23 changes: 23 additions & 0 deletions app/src/main/kotlin/app/view/treeView/RedBlackTreeView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package app.view.treeView
import app.view.treeView.AVLTreeView
import app.view.treeView.BinarySearchTreeView
import tornadofx.View
import tornadofx.action
import tornadofx.button
import tornadofx.vbox

class RedBlackTreeView: View() {
override val root = vbox {
button("AVL Tree") {
action {
replaceWith<AVLTreeView>()
}
}

button("Binary Search Tree") {
action {
replaceWith<BinarySearchTreeView>()
}
}
}
}

0 comments on commit c52816b

Please sign in to comment.