/* File: ToolPane.java
 * Author: Jason Gookins
 * Description: This class builds the pane that contains the core tool.
 */

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
 
public class ToolPane extends JPanel
{
	/************************
	 ** Instance Variables **
	 ************************/

	private ListPane listPane;
	private JLabel networkLabel;
	private NetworkPane networkPane;
	private JButton listButton;



	/**********************
	 ** Main Constructor **
	 **********************/

	public ToolPane(Belief belief)
	{
		setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();

		listPane = new ListPane(belief);
		listPane.setPreferredSize(new Dimension(0, this.getHeight()));
		listPane.setMinimumSize(new Dimension(0, this.getHeight()));
		c.gridx = 0;
		c.gridy = 0;
		c.gridwidth = 1;
		c.gridheight = 2;
		c.fill = GridBagConstraints.BOTH;
		add(listPane, c);

		listButton = new JButton();
		listButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
		listButton.setPreferredSize(new Dimension(10, this.getHeight()));
		listButton.setMinimumSize(new Dimension(10, this.getHeight()));
		listButton.addActionListener(belief.getBeliefListener());
		c.gridx = 1;
		add(listButton, c);

		networkLabel = new JLabel("Unnamed Network", JLabel.CENTER);
		c.gridx = 2;
		c.gridheight = 1;
		c.insets = new Insets(5, 5, 5, 5);
		add(networkLabel, c);

		networkPane = new NetworkPane(belief);
		networkPane.setPreferredSize(new Dimension(10000, 10000));
		JScrollPane networkScrollPane = new JScrollPane(networkPane);
		networkScrollPane.getVerticalScrollBar().setUnitIncrement(25);
		networkScrollPane.getHorizontalScrollBar().setUnitIncrement(25);
		JPanel editPane = new JPanel(new BorderLayout());
		editPane.add(networkScrollPane, BorderLayout.CENTER);
		c.gridy = 1;
		c.weightx = 1.0;
		c.weighty = 1.0;
		c.insets = new Insets(0, 0, 0, 0);
		add(editPane, c);
	}



	/***************
	 ** Accessors **
	 ***************/

	public ListPane getListPane()
	{
		return this.listPane;
	}

	public JLabel getNetworkLabel()
	{
		return this.networkLabel;
	}

	public JButton getListButton()
	{
		return this.listButton;
	}

	public NetworkPane getNetworkPane()
	{
		return this.networkPane;
	}
}