<commit_before>package org.helioviewer.jhv.display;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Timer;

import org.helioviewer.jhv.base.scale.GridScale;
import org.helioviewer.jhv.camera.Camera;
import org.helioviewer.jhv.data.datatype.event.JHVEvent;
import org.helioviewer.jhv.data.datatype.event.JHVEventHighlightListener;
import org.helioviewer.jhv.gui.ImageViewerGui;
import org.helioviewer.jhv.layers.Layers;
import org.helioviewer.jhv.opengl.GLSLSolarShader;

public class Displayer implements JHVEventHighlightListener {

    public static enum DisplayMode {
        ORTHO, POLAR, LATITUDINAL, LOGPOLAR;

        public String getLabel() {
            String label;
            switch (this) {
            case ORTHO:
                label = "Orthographic";
                break;
            case POLAR:
                label = "Polar";
                break;
            case LATITUDINAL:
                label = "Latitudinal";
                break;
            case LOGPOLAR:
                label = "LogPolar";
                break;
            default:
                label = "";
            }
            return label;
        }

        public GLSLSolarShader getSolarShader() {
            switch (this) {
            case ORTHO:
                return GLSLSolarShader.ortho;
            case POLAR:
                return GLSLSolarShader.polar;
            case LATITUDINAL:
                return GLSLSolarShader.lati;
            case LOGPOLAR:
                return GLSLSolarShader.logpolar;
            default:
                return null;
            }
        }

        public void setGridScale() {
            switch (this) {
            case ORTHO:
                GridScale.current = GridScale.ortho;
                break;
            case POLAR:
                GridScale.current = GridScale.polar;
                break;
            case LATITUDINAL:
                GridScale.current = GridScale.latitudinal;
                break;
            case LOGPOLAR:
                GridScale.current = GridScale.logpolar;
                break;
            default:
                GridScale.current = null;
            }
        }

    }

    public static DisplayMode mode = DisplayMode.ORTHO;
    public static boolean multiview = false;

    public static void setMode(DisplayMode newMode) {
        mode = newMode;
        Displayer.getCamera().reset();
    }

    static int glWidth = 1;
    static int glHeight = 1;

    public static void setGLSize(int x, int y, int w, int h) {
        glWidth = w;
        glHeight = h;
        fullViewport = new Viewport(-1, x, y, w, h);
    }

    private static Camera camera = new Camera();

    public static Camera getCamera() {<commit_msg>Zoom to fit miniview camera on display mode change<commit_after>package org.helioviewer.jhv.display;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Timer;

import org.helioviewer.jhv.base.scale.GridScale;
import org.helioviewer.jhv.camera.Camera;
import org.helioviewer.jhv.camera.CameraHelper;
import org.helioviewer.jhv.data.datatype.event.JHVEvent;
import org.helioviewer.jhv.data.datatype.event.JHVEventHighlightListener;
import org.helioviewer.jhv.gui.ImageViewerGui;
import org.helioviewer.jhv.layers.Layers;
import org.helioviewer.jhv.opengl.GLSLSolarShader;

public class Displayer implements JHVEventHighlightListener {

    public static enum DisplayMode {
        ORTHO, POLAR, LATITUDINAL, LOGPOLAR;

        public String getLabel() {
            String label;
            switch (this) {
            case ORTHO:
                label = "Orthographic";
                break;
            case POLAR:
                label = "Polar";
                break;
            case LATITUDINAL:
                label = "Latitudinal";
                break;
            case LOGPOLAR:
                label = "LogPolar";
                break;
            default:
                label = "";
            }
            return label;
        }

        public GLSLSolarShader getSolarShader() {
            switch (this) {
            case ORTHO:
                return GLSLSolarShader.ortho;
            case POLAR:
                return GLSLSolarShader.polar;
            case LATITUDINAL:
                return GLSLSolarShader.lati;
            case LOGPOLAR:
                return GLSLSolarShader.logpolar;
            default:
                return null;
            }
        }

        public void setGridScale() {
            switch (this) {
            case ORTHO:
                GridScale.current = GridScale.ortho;
                break;
            case POLAR:
                GridScale.current = GridScale.polar;
                break;
            case LATITUDINAL:
                GridScale.current = GridScale.latitudinal;
                break;
            case LOGPOLAR:
                GridScale.current = GridScale.logpolar;
                break;
            default:
                GridScale.current = null;
            }
        }

    }

    public static DisplayMode mode = DisplayMode.ORTHO;
    public static boolean multiview = false;

    public static void setMode(DisplayMode newMode) {
        mode = newMode;

        CameraHelper.zoomToFit(ImageViewerGui.getRenderableMiniview().getCamera());
        //ImageViewerGui.getRenderableMiniview().getCamera().reset();

        Displayer.getCamera().reset();
    }

    static int glWidth = 1;
    static int glHeight = 1;

    public static void setGLSize(int x, int y, int w, int h) {
        glWidth = w;
        glHeight = h;
        fullViewport = new Viewport(-1, x, y, w, h);
    }

    private static Camera camera = new Camera();

    public static Camera getCamera() {
{'fraction_non_alphanumeric': 0.07769510295898945, 'fraction_numerical': 0.001038241910365115, 'mean_word_length': 1.6260790549750113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1885196', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1596, 'n_words': 364}