/*
______________________________________________________________________
*
* 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: FileChart.java,v $ $Revision: 1.1.1.1 $
//            $Date: 2006-03-09 22:09:05 $  $Locker:  $  Quest Software Inc.

package examples.chart3d.j2d.data;

import com.klg.jclass.chart3d.Chart3dDataModel;
import com.klg.jclass.chart3d.Chart3dPointDataModel;
import com.klg.jclass.chart3d.JCChart3d;
import com.klg.jclass.chart3d.data.JCFile3dDataSource;
import com.klg.jclass.util.swing.JCExitFrame;
import demos.common.FileUtil;
import examples.chart3d.j2d.BaseExample;

import javax.swing.*;
import java.awt.*;

/**
 * This class demonstrates using the JCFile3dDataSource to create
 * a regular grid datasource from a file.
 */
public class FileChart extends BaseExample {

/**
 * Constructor for FileChart
 */
public FileChart(String pathname, String filename)
{
	super();
	String fullFilename = filename;
	if (pathname != null) {
	    fullFilename = FileUtil.getFullFileName(pathname, filename);
	}

	// Don't create a datasource directly, pass a call to the static method
	// through instead.
	Chart3dDataModel data =
        JCFile3dDataSource.createDataSourceFromFile(fullFilename);
	dataView.setElevationDataSource(data);
	if (data instanceof Chart3dPointDataModel) {
		dataView.setChartType(JCChart3d.SCATTER);
	}

	// Configure the chart
	dataView.getContour().setZoned(true);
	dataView.getContour().setContoured(true);
	dataView.getElevation().setTransparent(false);
	dataView.getElevation().setMeshed(true);
	dataView.getElevation().setShaded(true);
	chart3d.getLegend().setVisible(true);

	// By default, header is a JLabel - Set its text to be the filename
	chart3d.getHeader().setVisible(true);
	((JLabel)chart3d.getHeader()).setText(filename);
}

public Dimension getPreferredSize()
{
    return(new Dimension(600, 480));
}

public static void main(String[] args)
{
	JCExitFrame f = new JCExitFrame("File Datasource");
	f.getContentPane().setLayout(new GridLayout(1,1));
	FileChart fc = new FileChart(null, args[0]);
	f.getContentPane().add(fc);
	f.pack();
	f.setVisible(true);
}

}


