package renderer.debug;

import renderer.Resolution;
import renderer.Scheduler;

import javax.swing.*;
import java.awt.*;

public class DebugOverlay {
    private JLabel frametime;
    private JLabel threads;
    private JLabel targetDimension;
    private JLabel tileDimensions;
    private JLabel samples;
    private JPanel root;
    private JLabel downScale;
    private JLabel time;

    public void setup(){
        this.root.setOpaque(false);
        this.root.setBackground(new Color(0,0,0,0));
    }

    public void setFrametime(long ms) {
        this.frametime.setText(String.format("%dms", ms));
    }

    public void setSamples(int samples) {
        this.samples.setText("" + samples);
    }

    public void setTargetDimension(Resolution resolution) {
        this.targetDimension.setText(String.format("%dx%d", resolution.getScaledWidth(), resolution.getScaledHeight()));
        this.downScale.setText("" + resolution.getDownScale());
    }

    public void setThreads() {
        this.threads.setText("" + Scheduler.THREADS_PER_SIDE * Scheduler.THREADS_PER_SIDE);
    }

    public void setTileDimensions(int width, int height) {
        this.tileDimensions.setText(String.format("%dx%d", width, height));
    }

    public JPanel getRoot() {
        return root;
    }

    public void setTime(long l) {
        this.time.setText(String.format("%.1fs", l * 1e-3));
    }
}
