package client.components.imagePanel;

import client.components.imagePanel.listeners.ImageControlsListener;
import client.persistence.*;

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

public class ImagePanel extends JPanel {

    private ImageControl imageControl;
    private ScalableImage scalableImage;

    private ImageState imageState;

    public ImagePanel(ImageState imageState) {
        this.imageState = imageState;

        setupView();
    }

    private void setupView() {
        this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
        this.setBackground(Color.DARK_GRAY);

        scalableImage = new ScalableImage(imageState);
        ImageControlsListener imageControlsListener = scalableImage.getImageControlsListener();

        imageControl = new ImageControl(imageState);
        imageControl.addControlsListener(imageControlsListener);

        this.add(imageControl, Component.LEFT_ALIGNMENT);

        this.add(scalableImage, BorderLayout.CENTER);
    }
}
