Skip to content

Commit

Permalink
feat: add panning
Browse files Browse the repository at this point in the history
  • Loading branch information
ancavar committed May 2, 2023
1 parent 70ed4fd commit 6fc0436
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/src/main/kotlin/app/controller/AVLController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class AVLController : Controller() {
treePane.children.clear()
val root = tree.getRoot()
if (root != null) {
drawNode(root, treePane, treePane.width / 2.0, 50.0, treePane.width / 4.0)
drawNode(root, treePane, treePane.width / 2.0, treePane.width / 2.0, 250.0)
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/app/controller/BSTController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class BSTController : Controller() {
treePane.children.clear()
val root = tree.getRoot()
if (root != null) {
drawNode(root, treePane, treePane.width / 2.0, 50.0, treePane.width / 4.0)
drawNode(root, treePane, treePane.width / 2.0, treePane.width / 2.0, 250.0)
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/app/controller/RBTController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class RBTController : Controller() {
treePane.children.clear()
val root = tree.getRoot()
if (root != null) {
drawNode(root, treePane, treePane.width / 2.0, 50.0, treePane.width / 4.0)
drawNode(root, treePane, treePane.width / 2.0, treePane.width / 2.0, 250.0)
} else {
throw NullPointerException("Root of the tree is null.")
}
Expand Down
22 changes: 16 additions & 6 deletions app/src/main/kotlin/app/view/treeView/AVLTreeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import app.controller.AVLController
import bst.AVLTree
import javafx.beans.property.SimpleStringProperty
import javafx.scene.control.Alert
import javafx.scene.control.ScrollPane
import javafx.scene.layout.Pane
import tornadofx.ChangeListener
import tornadofx.View
Expand All @@ -16,7 +17,7 @@ import tornadofx.field
import tornadofx.fieldset
import tornadofx.form
import tornadofx.hbox
import tornadofx.plusAssign
import tornadofx.scrollpane
import tornadofx.seconds
import tornadofx.textfield
import tornadofx.vbox
Expand Down Expand Up @@ -148,11 +149,20 @@ class AVLTreeView : View() {
replaceWith(RedBlackTreeView::class, ViewTransition.Slide(0.3.seconds, ViewTransition.Direction.LEFT))
}
}
this += treePane
treePane.apply {
minWidth = 600.0
minHeight = 400.0
style = "-fx-border-color: black;"
scrollpane {
content = treePane
isPannable = true
hbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
vbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED

hvalue = 0.5
vvalue = 0.5

treePane.apply {
minWidth = 5000.0
minHeight = 5000.0
style = "-fx-border-color: black;"
}
}
}
}
22 changes: 16 additions & 6 deletions app/src/main/kotlin/app/view/treeView/BinarySearchTreeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import app.controller.BSTController
import bst.BSTree
import javafx.beans.property.SimpleStringProperty
import javafx.scene.control.Alert
import javafx.scene.control.ScrollPane
import javafx.scene.layout.Pane
import tornadofx.ChangeListener
import tornadofx.View
Expand All @@ -16,7 +17,7 @@ import tornadofx.field
import tornadofx.fieldset
import tornadofx.form
import tornadofx.hbox
import tornadofx.plusAssign
import tornadofx.scrollpane
import tornadofx.seconds
import tornadofx.textfield
import tornadofx.vbox
Expand Down Expand Up @@ -146,11 +147,20 @@ class BinarySearchTreeView : View() {
replaceWith(RedBlackTreeView::class, ViewTransition.Slide(0.3.seconds, ViewTransition.Direction.LEFT))
}
}
this += treePane
treePane.apply {
minWidth = 600.0
minHeight = 400.0
style = "-fx-border-color: black;"
scrollpane {
content = treePane
isPannable = true
hbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
vbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED

hvalue = 0.5
vvalue = 0.5

treePane.apply {
minWidth = 5000.0
minHeight = 5000.0
style = "-fx-border-color: black;"
}
}
}
}
22 changes: 16 additions & 6 deletions app/src/main/kotlin/app/view/treeView/RedBlackTreeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import app.controller.RBTController
import bst.RedBlackTree
import javafx.beans.property.SimpleStringProperty
import javafx.scene.control.Alert
import javafx.scene.control.ScrollPane
import javafx.scene.layout.Pane
import tornadofx.ChangeListener
import tornadofx.View
Expand All @@ -16,7 +17,7 @@ import tornadofx.field
import tornadofx.fieldset
import tornadofx.form
import tornadofx.hbox
import tornadofx.plusAssign
import tornadofx.scrollpane
import tornadofx.seconds
import tornadofx.textfield
import tornadofx.vbox
Expand Down Expand Up @@ -146,11 +147,20 @@ class RedBlackTreeView : View() {
replaceWith(BinarySearchTreeView::class, ViewTransition.Slide(0.3.seconds, ViewTransition.Direction.LEFT))
}
}
this += treePane
treePane.apply {
minWidth = 600.0
minHeight = 400.0
style = "-fx-border-color: black;"
scrollpane {
content = treePane
isPannable = true
hbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
vbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED

hvalue = 0.5
vvalue = 0.5

treePane.apply {
minWidth = 5000.0
minHeight = 5000.0
style = "-fx-border-color: black;"
}
}
}
}

0 comments on commit 6fc0436

Please sign in to comment.