package io.github.jjsimas.chart2d.demo;

import io.github.jjsimas.chart2d.CartesianChart;
import io.github.jjsimas.chart2d.PieChart;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import javax.imageio.ImageIO;

public final class RenderDemoImages {

  private RenderDemoImages() {
  }

  public static void main(String[] args) throws IOException {
    Path outDir = Path.of("rendered-demo");
    Files.createDirectories(outDir);

    CartesianChart vertical = ModernChart2DDemo.buildVerticalChartForExport();
    CartesianChart horizontal = ModernChart2DDemo.buildHorizontalChartForExport();
    PieChart pie = ModernChart2DDemo.buildPieChartForExport();

    write(vertical.renderImage(new java.awt.Dimension(860, 520)), outDir.resolve("modern-vertical.png"));
    write(horizontal.renderImage(new java.awt.Dimension(860, 520)), outDir.resolve("modern-horizontal.png"));
    write(pie.renderImage(new java.awt.Dimension(860, 520)), outDir.resolve("modern-pie.png"));
  }

  private static void write(BufferedImage image, Path path) throws IOException {
    ImageIO.write(image, "png", path.toFile());
  }
}
