# Chart2D Modern

This repository now contains two codepaths:

- `net/sourceforge/chart2d`: the original 2001-2002 Chart2D source.
- `src/main/java/io/github/jjsimas/chart2d`: a Java 21 rewrite with a modern API.

## What Changed

The rewrite keeps the two behaviors that made the original code interesting:

- Preferred sizes are computed bottom-up from chart content.
- When the available size grows, model-sized elements scale proportionally.
- When the available size shrinks, optional elements degrade gracefully instead of failing.

The new code uses:

- Immutable records for chart models
- Modern enums and builders for options/themes
- Swing/Java2D rendering on Java 21
- Layout snapshots so responsive behavior is observable and testable

## Main Types

- `CartesianChart`
- `PieChart`
- `CartesianChartModel`
- `PieChartModel`
- `ChartTheme`

## Compile

This environment did not include Maven, so the rewrite was verified with `javac` directly:

```powershell
javac --release 21 -d out (Get-ChildItem -Recurse src/main/java -Filter *.java | ForEach-Object { $_.FullName })
```

## Run The Demo

```powershell
java -cp out io.github.jjsimas.chart2d.demo.ModernChart2DDemo
```

## Run The Smoke Test

```powershell
javac --release 21 -cp out -d out (Get-ChildItem -Recurse src/test/java -Filter *.java | ForEach-Object { $_.FullName })
java -ea -cp out io.github.jjsimas.chart2d.Chart2DModernSmokeTest
```
