package ArrayDemos;
import NGP.Containers.*;

/**
 * Histogramlet.java
 *
 *
 * Created: Mon Apr  9 10:32:53 2001
 *
 * @author Stuart C. Shapiro
 */

public class Histogramlet extends NGP.Containers.Applet{
    private static final int DPWIDTH = 700;
    private static final int NUMBEROFCATEGORIES = 8;

    protected static final int DPHEIGHT = 400;
    protected static final int MAXCOUNT = 10;
    protected static final int BARWIDTH = DPWIDTH/NUMBEROFCATEGORIES/2;
    protected static StatisticsGenerator STATGENERATOR;

    private NGP.Containers.Column _column;
    private NGP.Containers.Row _statRow;
    private NGP.Containers.Row _barRow;
    private NGP.Components.QuitButton _quitButton;
    private Bar[] _bars;

    public Histogramlet (){
	//super("Histogram");
	_bars = new Bar[NUMBEROFCATEGORIES];

	_column = new NGP.Containers.Column(this);

	/* A row to hold statistics. */
	_statRow = new NGP.Containers.Row(_column);
	_statRow.setColor(java.awt.Color.white);
	STATGENERATOR = new StatisticsGenerator(_statRow, _bars);

	/* A row to hold the bars and buttons. */
	_barRow = new NGP.Containers.Row(_column);
	_barRow.setColor(java.awt.Color.white);

	for (int i=0; i<NUMBEROFCATEGORIES; i++) {
	    /* for each category,
	     * place a column holding a drawingPanel with a bar,
	     * and a button. */
	    NGP.Containers.Column column = new NGP.Containers.Column(_barRow);
	    column.setColor(java.awt.Color.white);
	    NGP.Containers.DrawingPanel drawingPanel =
		new NGP.Containers.DrawingPanel(column);
	    drawingPanel.setDimension(new java.awt.Dimension(BARWIDTH,
							     DPHEIGHT));
	    drawingPanel.setColor(java.awt.Color.white);

	    _bars[i] = new Bar(drawingPanel);
	    new CountButton(column, ""+(char)('A'+i), _bars[i]);
	}
	
	_quitButton = new NGP.Components.QuitButton(_column, "Quit");
    }

}// Histogramlet
