package ArrayDemos;

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

public class Histogram extends NGP.Containers.Frame{
    private static final int DPWIDTH = 700;
    private static final int NUMBEROFCATEGORIES = 10;

    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 HistogramColumn[] _bars;

    public Histogram (){
	super("Histogram");
	_bars = new HistogramColumn[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++)
	    _bars[i] = new HistogramColumn(_barRow, (char)('A'+i));
	
	NGP.Containers.Row sortRow = new NGP.Containers.Row(_column);
	sortRow.setColor(java.awt.Color.white);
	new NGP.Components.Label(sortRow, "Sort by: ");
	new SortButton(sortRow, "Count", _bars, _barRow,
		       this, new ColumnCountComparitor());
	new SortButton(sortRow, "Category", _bars, _barRow,
		       this, new ColumnCategoryComparitor());

	_quitButton = new NGP.Components.QuitButton(_column, "Quit");
    }

    public static void main (String[] args) {
	Histogram hist = new Histogram();
	hist.pack();
	hist.show();
    } // end of main ()
    
}// Histogram
