Skip to content

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

🌳 TreeVisualizer

An interactive Binary Tree visualization desktop application built with JavaFX. Developed as a personal learning project to apply data structures visually.

Main Menu


Features

Data Structures & Algorithms

  • 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

Visualization & UI

  • 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

Architecture & UX

  • 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

Screenshots

Balanced BST

Balanced Tree

Unbalanced Tree

Unbalanced Tree

Tree Analysis Panel

Analysis Panel Full

Error Handling

Error Handling


Demo

Random Node Addition

Random Add

Search Animation (O(log n) path highlighting)

Search

InOrder Traversal

InOrder

Clear & Undo

Clear Undo


Architecture

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

How to Run

Download TreeVisualizer.jar from Releases

Requires Java 17 and JavaFX SDK 17 — Download JavaFX here


Option 1: Run with JAR (Recommended)

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.jar

Windows example:

java --module-path "C:\java\javafx-sdk-17.0.19\lib" --add-modules javafx.controls,javafx.fxml,javafx.graphics -jar TreeVisualizer.jar

macOS / Linux example:

java --module-path "/path/to/javafx-sdk-17/lib" --add-modules javafx.controls,javafx.fxml,javafx.graphics -jar TreeVisualizer.jar

Option 2: Run from Source (IntelliJ IDEA)

  1. Clone the repository
   git clone https://github.com/fkleni/TreeVisualizer.git
  1. Open in IntelliJ IDEA
  2. Go to File → Project Structure → Libraries → click + → add the JavaFX SDK lib folder
  3. Run Main.java

Built With

  • Java 17
  • JavaFX 17
  • IntelliJ IDEA

About

Interactive Binary Tree visualization and education tool built with JavaFX

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages