An interactive Binary Tree visualization desktop application built with JavaFX. Developed as a personal learning project to apply data structures visually.
- Two tree modes: Binary Search Tree (BST) and Standard Binary Tree
- O(log n) search: Animated path highlighting demonstrating optimal BST search performance
- Tree Traversals: InOrder, PreOrder, and PostOrder with step-by-step animations
- Mathematical Layout: In-Order layout algorithm prevents node overlap as the tree grows
- Adaptive Visuals: Background reacts to node count and balance state across 7 growth stages
- Real-time Analysis Panel: Instantly classifies the tree as Full, Perfect, Complete, Degenerate, or Balanced
- Zoom & Pan: Mouse-based pivot zoom (Ctrl + Scroll) and drag-to-pan canvas
- MVC-Inspired Design: Clean separation of business logic, UI, and data models
- Stack-Based Undo: Deep copy of tree states allows users to safely revert any action
- Error Handling: Alerts for duplicate values, capacity (60 nodes) and depth (10 levels) limits
- Keyboard Support: Press Enter to insert nodes
- Random Generation: Instantly populate the tree with random nodes
- Clear: Reset the entire tree and analysis panel in one click
src/
├── AppConfig.java # All constants (canvas size, zoom limits, tree limits)
├── Main.java # JavaFX entry point, screen management
│
├── BinaryTree.java # Abstract base class (insert, search, tree properties)
├── BinarySearchTree.java # BST with O(log n) contains & search path override
├── SimpleBinaryTree.java # BFS-based level-order insertion
├── TreeNode.java # Node model with deep copy support
│
├── TreeService.java # Business logic coordinator
├── ValidationService.java # Input validation (duplicate, capacity, depth)
├── ValidationResult.java # Validation response object
├── Undo.java # Stack-based undo with deep copy
├── TreeTraversal.java # InOrder / PreOrder / PostOrder
├── RandomGenerator.java # Safe random node generation
│
├── TreeController.java # Bridge between UI and service layers
├── TreeVisualizer.java # Tree rendering and layout calculation
├── TreeNodeView.java # Single node view with animations
├── TreeAnimator.java # Traversal and search animations
├── TreeBottomPane.java # Bottom control panel
├── TreeInfoPanel.java # Right-side live analysis panel
├── TreeViewPane.java # ScrollPane and canvas setup
├── ZoomHelper.java # Ctrl+Scroll pivot zoom logic
└── Launcher.java # JAR entry point
Requires Java 17 and JavaFX SDK 17 — Download JavaFX here
Step 1: Download TreeVisualizer.jar from the link above
Step 2: Download and extract JavaFX SDK 17 from openjfx.io
Step 3: Run the following command in your terminal:
java --module-path "path/to/javafx-sdk/lib" --add-modules javafx.controls,javafx.fxml,javafx.graphics -jar TreeVisualizer.jarWindows example:
java --module-path "C:\java\javafx-sdk-17.0.19\lib" --add-modules javafx.controls,javafx.fxml,javafx.graphics -jar TreeVisualizer.jarmacOS / Linux example:
java --module-path "/path/to/javafx-sdk-17/lib" --add-modules javafx.controls,javafx.fxml,javafx.graphics -jar TreeVisualizer.jar- Clone the repository
git clone https://github.com/fkleni/TreeVisualizer.git- Open in IntelliJ IDEA
- Go to File → Project Structure → Libraries → click
+→ add the JavaFX SDKlibfolder - Run
Main.java
- Java 17
- JavaFX 17
- IntelliJ IDEA








