package io.github.jjsimas.chart2d;

import java.awt.Color;
import java.awt.Dimension;
import java.util.List;

public final class Chart2DModernSmokeTest {

  private Chart2DModernSmokeTest() {
  }

  public static void main(String[] args) {
    CartesianChart cartesian = new CartesianChart(
      new CartesianChartModel(
        "Smoke",
        "Month",
        "Value",
        List.of("Jan", "Feb", "Mar", "Apr", "May", "Jun"),
        List.of(
          new CartesianSeries("Bars", List.of(5.0, 12.0, 9.0, 15.0, 17.0, 21.0), SeriesRenderer.BAR, new Color(52, 110, 208)),
          new CartesianSeries("Trend", List.of(4.0, 11.0, 10.0, 13.0, 16.0, 20.0), SeriesRenderer.LINE, new Color(240, 113, 83))
        ),
        List.of(new WarningBand(14.0, 22.0, new Color(255, 226, 226, 150))),
        CartesianChartOptions.defaults(),
        ChartTheme.defaults()
      )
    );

    Dimension preferred = cartesian.getPreferredSize();
    assert preferred.width > 0;
    assert preferred.height > 0;

    CartesianLayoutSnapshot large = cartesian.layoutSnapshot(new Dimension(preferred.width * 2, preferred.height * 2));
    assert large.plotBounds().width > 0;
    assert large.plotBounds().height > 0;
    assert large.scale() >= 1.0f;

    CartesianLayoutSnapshot small = cartesian.layoutSnapshot(new Dimension(160, 120));
    assert small.plotBounds().width > 0;
    assert small.plotBounds().height > 0;

    cartesian.renderImage(new Dimension(640, 400));
    cartesian.renderImage(new Dimension(140, 100));

    PieChart pie = new PieChart(
      new PieChartModel(
        "Traffic",
        List.of(
          new PieSlice("Organic", 40.0, new Color(54, 116, 217)),
          new PieSlice("Paid", 20.0, new Color(242, 109, 79)),
          new PieSlice("Referral", 15.0, new Color(75, 181, 120)),
          new PieSlice("Email", 15.0, new Color(240, 189, 76)),
          new PieSlice("Other", 10.0, new Color(154, 121, 213))
        ),
        PieChartOptions.defaults(),
        ChartTheme.defaults()
      )
    );

    PieLayoutSnapshot pieLarge = pie.layoutSnapshot(new Dimension(640, 400));
    assert pieLarge.pieBounds().width > 0;
    assert pieLarge.pieBounds().height > 0;

    PieLayoutSnapshot pieSmall = pie.layoutSnapshot(new Dimension(160, 120));
    assert pieSmall.pieBounds().width > 0;
    assert pieSmall.pieBounds().height > 0;

    pie.renderImage(new Dimension(640, 400));
    pie.renderImage(new Dimension(140, 100));
  }
}
