/*
______________________________________________________________________
*
* 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: File3dChart.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.Chart3dDataModel;
import com.klg.jclass.chart3d.data.JCFile3dDataSource;
import com.klg.jclass.util.swing.JCExitFrame;
import examples.chart3d.j3d.BaseExample;

import javax.swing.*;

/**
 * This class demonstrates using the JCFile3dDataSource to create
 * a regular grid datasource from a file.
 */
public class File3dChart extends BaseExample {

public File3dChart()
{
	this("File Datasource");
}

public File3dChart(String title)
{
	super(title);
}

public void initData() {}

public void initData(String filename)
{
	if (filename == null) {
		System.out.println("Filename is null.  Cannot open.");
		System.exit(1);
	}
	Chart3dDataModel data =
        JCFile3dDataSource.createDataSourceFromFile(filename);
	if (data == null) {
		System.out.println("Cannot create datasource from filename:" +
                           filename);
		System.exit(1);
	}
	getDataView().setElevationDataSource(data);

    // By default, header is a JLabel - Set its text to be the filename
    getChart3d().getHeader().setVisible(true);
    ((JLabel)getChart3d().getHeader()).setText(filename);
}

public static void main(String[] args)
{
	if (args.length == 0) {
		System.out.println("Need a filename argument in order to run.");
		System.exit(-1);
	}
	File3dChart example = null;
	example = new File3dChart();
	example.initData(args[0]);
    final JCExitFrame frame = new JCExitFrame(example.getTitle());
    frame.getContentPane().add(example);

    frame.pack();
    frame.show();
	example.updateChart3d();
}

}


