/*
______________________________________________________________________
*
* Copyright (c) 1996-2004, QUEST SOFTWARE INC. All Rights Reserved.
* http://java.quest.com
*
* This file is provided for demonstration and educational uses only.
* Permission to use, copy, modify and distribute this file for
* any purpose and without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies, and that the name of Quest Software not be used in advertising
* or publicity pertaining to this material without the specific,
* prior written permission of an authorized representative of
* Quest Software.
*
* QUEST SOFTWARE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
* OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. QUEST SOFTWARE SHALL NOT BE LIABLE FOR ANY
* DAMAGES SUFFERED BY USERS AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
* ______________________________________________________________________
*/

//   RCSID -- $RCSfile: Swing3dChart.java,v $ $Revision: 1.1.1.1 $
//            $Date: 2006-03-09 22:09:06 $  $Locker:  $  Quest Software Inc.

package examples.chart3d.j3d.data;

import com.klg.jclass.chart3d.JCChart3d;
import com.klg.jclass.chart3d.data.JCSwing3dDataSource;
import com.klg.jclass.util.swing.JCExitFrame;
import examples.chart3d.j3d.BaseExample;

import javax.swing.table.AbstractTableModel;

/**
 * This class demonstrates using the JCSwing3dDataSource to create
 * a grid datasource from a Swing TableModel.
 */
public class Swing3dChart extends BaseExample {

public Swing3dChart()
{
	this("Swing Datasource");
}

public Swing3dChart(String title)
{
	super(title);
}

public void init()
{
    try {
        init(JCChart3d.BAR);
    }
    catch (InstantiationException e) {
        showErrorMessage(e.toString(),
                         "JClass Chart3D could not be instantiated",
                         "JClass Chart3D Error");
    }
}

public void initData()
{
	AbstractTableModel dataModel = null;
	JCSwing3dDataSource ds = null;

	// Load data for the chart
	try {
		// Create a Swing TableModel
		dataModel = new AbstractTableModel() {
			public int getColumnCount()
			{
				return(9);
			}
			public int getRowCount()
			{
				return(23);
			}
			public Object getValueAt(int row, int col)
			{
				return(new Integer(row * col));
			}
		};

		// Pass the TableModel to the JCSwing3dDataSource
		ds = new JCSwing3dDataSource(dataModel);

        // Set the JCSwing3dDataSource as the ElevationDataSource
        getDataView().setElevationDataSource(ds);
	}
	catch (Exception e) {
        showErrorMessage(e.toString(),
                         "Error creating JCSwing3dDataSource",
                         "JClass Chart3D Error");
	}
}

public static void main(String[] args)
{
	Swing3dChart example = null;
	example = new Swing3dChart();
    final JCExitFrame frame = new JCExitFrame(example.getTitle());
    frame.getContentPane().add(example);

    frame.pack();
    frame.show();
	example.updateChart3d();
}

}




