package target;

import javax.swing.*;
import edu.csusb.danby.stat.*;
import java.awt.Dimension;

/**
* class HistogramPanel3 stacks 3 histograms
* into a panel
* @author Charles Stanton
* @version  May 3, 2002
*/
public class HistogramPanel3 extends JPanel{
    HistogramPanel hp1;
    HistogramPanel hp2;
    HistogramPanel hp3;
    TargetModel tm;

    /** 
    * constructor for HistogramPanel3
    * @param aTm is the calling TargetModel
    */
    public HistogramPanel3( TargetModel aTm) {
        tm = aTm;
        setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
        hp1 = new HistogramPanel(tm.getXHistogramData());
        hp2 = new HistogramPanel(tm.getYHistogramData());
        hp3 = new HistogramPanel(tm.getXYHistogramData());
    

    add(hp1);
    add(new JLabel("x distribution"));
    add(hp2);
    add(new JLabel("y distribution"));
    add(hp3);
    add(new JLabel("xySquared distribution"));
    this.setPreferredSize(new Dimension(250,350));
    this.setMinimumSize(new Dimension(250,350));
    repaint();
    }

    /**
    * update using new values provided by the TargetModel
    */
    public void update(){
        hp1.update(tm.getXHistogramData());
        hp2.update(tm.getYHistogramData());
        hp3.update(tm.getXYHistogramData());
    }
}
