import java.awt.FlowLayout;
import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import java.awt.Image;

/**
 * 
 */

/**
 * PersonPanel displays all of the information for an indiviudal
 */
public class PersonPanel extends JPanel {
	private BufferedImage originalTemplate; // the first template of the person

	private BufferedImage lastSeenTemplate; // the last template seen of this
											// person

	private JLabel origTempLabel; // label which will display originalTemplate

	private JLabel lastSeenTempLabel; // label which will display
										// lastSeenTemplate

	private JLabel lastCorrelationLabel; // label which will display last
											// correlation value
	private JLabel numTrainingSamplesLabel; //label which displays # of training samples collected
	private JLabel numTestingSamplesLabel; //label which displays # of testing samples collected
	
	int numTrainingSamples, numTestingSamples;
	public PersonPanel(BufferedImage originalTemplate) {
		super();
		
		numTrainingSamples = 0; 
		numTestingSamples  = 0; 
		
		this.setLayout(new FlowLayout(FlowLayout.LEFT));
		this.originalTemplate = originalTemplate;

		origTempLabel = new JLabel(new ImageIcon(originalTemplate));
		lastSeenTempLabel = new JLabel(new ImageIcon(originalTemplate));
		lastCorrelationLabel = new JLabel(Integer.toString(0));
		numTrainingSamplesLabel = new JLabel("# Training Samples: " + Integer.toString(numTrainingSamples)); 
		numTestingSamplesLabel = new JLabel("# Testing Samples: " + Integer.toString(numTestingSamples)); 
		
		this.add(origTempLabel);
		this.add(lastSeenTempLabel);
		this.add(lastCorrelationLabel);
		this.add(numTrainingSamplesLabel);
		this.add(numTestingSamplesLabel); 
	}
	
	public void updateLastSeen(BufferedImage lst, int correlation, int type) {
		this.lastSeenTemplate = lst;
		Image img = lst.getScaledInstance(originalTemplate.getWidth(),
				originalTemplate.getHeight(), Image.SCALE_FAST);
		lastSeenTempLabel.setIcon(new ImageIcon(img));
		lastCorrelationLabel.setText(Integer.toString(correlation));
		
		switch (type) {
		case 0: //training
			numTrainingSamples++; 
			numTrainingSamplesLabel.setText("# Training Samples: " + Integer.toString(numTrainingSamples));
			break;
		case 1: //testing
			numTestingSamples++;
			numTestingSamplesLabel.setText("# Testing Samples: " + Integer.toString(numTestingSamples));
			break; 
		}
	}
	
	public void updateTrainingImage(BufferedImage lst, int correlation, int type) {
		
	}
	public void updateTestingImage(BufferedImage lst, int correlation, int type) {
		
	}
	
}
