/*
______________________________________________________________________
*
* 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: Default3dGrid.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.JCDefault3dGridDataSource;
import com.klg.jclass.util.swing.JCExitFrame;
import examples.chart3d.j3d.BaseExample;

/**
 * This class demonstrates the JCDefault3dGridDataSource
 */
public class Default3dGrid extends BaseExample {

public Default3dGrid()
{
    this("Default Grid Datasource");
}

public Default3dGrid(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() {

    JCDefault3dGridDataSource ds = new JCDefault3dGridDataSource();
    ds.setDataSourceName("New Name");

    // Set up the x values
    double  xarray[] = new double[15];
    for (int i = 0; i < xarray.length; i++) {
        xarray[i] = (double)i;
    }
    ds.setXGrid(xarray);


    // Set up the y values
    double  yarray[] = new double[15];
    for (int i = 0; i < yarray.length; i++) {
        yarray[i] = (double)i*2;
    }
    ds.setYGrid(yarray);

    // Set up the z values
    double  zvals[][] = new double[15][15];
    for (int i = 0; i < zvals.length; i++) {
        for (int j = 0; j < zvals[i].length; j++) {
            double xval = (double)(i-5);
            double yval = (double)(j-5);
            zvals[i][j] = xval*xval + yval*yval;
        }
    }
    ds.setZValues(zvals);
    getDataView().setElevationDataSource(ds);
}

public static void main(String[] args)
{
    Default3dGrid example = null;
    example = new Default3dGrid();
    final JCExitFrame frame = new JCExitFrame(example.getTitle());
    frame.getContentPane().add(example);

    frame.pack();
    frame.show();
    example.updateChart3d();
}

}




