This project automates the creation of images that visualize a Java program's state. It also provides a Python interface for doing this.
Code | Output |
public class Main {
public static void main(String[] args) {
Person alice = new Person("Alice", 42);
}
}
record Person(String name, int age) { }; |
You should have the uv package manager installed. This program gets source code input from standard input and outputs image data to standard output. You should use shell input/output redirection.
$ uv run render_image < In.java > out.png
Usage information for the Python interface is provided as docstrings in __init__.py
.
This project has three major components: the trace generator, the frontend, the browser driver.
The trace generator is essentially a Python wrapper around a Java tracer program. It:
- downloads and installs both the latest release of the tracer and the latest release of the JDK
- executes the tracer on the input code
- returns the output of the tracer
The frontend is a lightly modified version of OnlinePythonTutor. It is a web page that takes the trace generated by the Java tracer and turns it into a visualization.
The browser driver creates a headless Chrome browser process using Selenium, loads the frontend with the trace, and then takes a screenshot of the visualization created by the frontend.