/*

	class GraphsPanel.java
	
	This is a simple p[anel that allows the user to specify which graphs
	she would like the applet to draw...
	
*/

import java.awt.*;

public class GraphsPanel extends Panel{
	
	private TalkerCheckbox nnCheck;
	private TalkerCheckbox liveAddCheck;
	private TalkerCheckbox circlesCheck;
	private TalkerCheckbox sicheck;
	private GridBagLayout theLay;

	// constructor
	
	public GraphsPanel(CommandParser commander){
		super();
		
		theLay = new GridBagLayout();
		setLayout(theLay);
		
		nnCheck = new TalkerCheckbox("Nearest Neighbour",false){
			public String talkCommand(){
				if (getState())
					return "graph + nn";
				else
					return "graph - nn";
				}
			};
		nnCheck.addItemListener(commander);
		add(nnCheck,0,0,10,1);
		
		liveAddCheck = new TalkerCheckbox("Live Add",false){
			public String talkCommand(){
				if (getState())
					return "set LIVEADD true";
				else
					return "set LIVEADD false";
				}
			};
		liveAddCheck.addItemListener(commander);
		add(liveAddCheck,0,1,10,1);
		
		circlesCheck = new TalkerCheckbox("Show Circles",false){
			public String talkCommand(){
				if (getState())
					return "graph + cc";
				else
					return "graph - cc";
				}
			};
		circlesCheck.addItemListener(commander);
		add(circlesCheck,0,2,10,1);

		sicheck = new TalkerCheckbox("Spheres of Influence",false){
			public String talkCommand(){
				if (getState())
					return "graph + si";
				else
					return "graph - si";
				}
			};
		sicheck.addItemListener(commander);
		add(sicheck,10,0,10,1);
		
		
		}

	

	public void add(Component what,int gridx,int gridy,int wid,int high,int wx,int wy,int anc,int fill){
		GridBagConstraints c = new GridBagConstraints();
		c.gridx=gridx;
		c.gridy=gridy;
		c.gridwidth=wid;
		c.gridheight=high;
		c.weightx=wx;
		c.weighty=wy;
		c.anchor=anc;
		c.fill=fill;
		theLay.setConstraints(what,c);		//set constraints
		add(what);							//add it to panel
		}
	public void add(Component what,int gridx,int gridy,int wid,int high){
		add(what,gridx,gridy,wid,high,100,100,GridBagConstraints.WEST,GridBagConstraints.NONE);
		}

}