package ui.view.main;

import java.awt.Canvas;

import javax.swing.JFrame;
import javax.swing.JSplitPane;

import utility.ImageImport;

/**
 * The MainFrame is responsible for the layout of Holeg.
 * 
 * @author Tom
 *
 */
public class MainFrame extends JFrame {
	// Constants
	private String frameTitle = "HOLEG";
	// Components
	private MainToolBar toolBar = new MainToolBar(this);
	private CatalogExplorer explorer = new CatalogExplorer();
	private HolonElementViewer elementViewer = new HolonElementViewer();
	private Inspector inspector = new Inspector();
	private HolonCanvas canvas = new HolonCanvas();

	// PanelLayout
	private JSplitPane splitCatalogCanvas = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, explorer, canvas);
	private JSplitPane splitElementInspector = new JSplitPane(JSplitPane.VERTICAL_SPLIT, elementViewer, inspector);
	private JSplitPane splitCanvasInspector = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitCatalogCanvas,
			splitElementInspector);

	public MainFrame() {
		// Size and Position
		setBounds(0, 0, 1000, 800);
		setLocationRelativeTo(null);

		// Title and Icon
		setTitle(frameTitle);
		setIconImage(ImageImport.loadImage("/Images/Holeg.png", 30, 30));

		// Display
		add(splitCanvasInspector);
		setVisible(true);
		// Default DividerLocations
		// can only be set after panel is visible
		splitCatalogCanvas.setDividerLocation(0.8);
		splitCanvasInspector.setDividerLocation(0.8);
		splitElementInspector.setDividerLocation(0.7);
		
		//Close Opperation
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	}
}
