/*
______________________________________________________________________
*
* 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: XML3dChart.java,v $ $Revision: 1.1.1.1 $
//            $Date: 2006-03-09 22:09:07 $  $Locker:  $  Quest Software Inc.

package examples.chart3d.j3d.data;

import com.klg.jclass.chart3d.JCChart3d;
import com.klg.jclass.chart3d.data.JCXML3dDataSource;
import com.klg.jclass.util.swing.JCExitFrame;
import demos.common.FileUtil;
import examples.chart3d.j3d.BaseExample;

import javax.swing.*;

public class XML3dChart extends BaseExample {

/* The filename of XML file that stores the data source. */
static String                   FILENAME = "3d.xml";

public XML3dChart()
{
	this("XML Datasource");
}

public XML3dChart(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");
    }

    // By default, header is a JLabel - Set its text to be the filename
	if (getChart3d() != null) {
        getChart3d().getHeader().setVisible(true);
        ((JLabel)getChart3d().getHeader()).setText(FILENAME);
	}
}

public void initData()
{
	String filename = FileUtil.getFullFileName(getFullPackageName(), FILENAME);
	JCXML3dDataSource ds = new JCXML3dDataSource(filename);
    getDataView().setElevationDataSource(ds);
}

public static void main(String[] args)
{
    XML3dChart example = null;
	example = new XML3dChart();
    final JCExitFrame frame = new JCExitFrame(example.getTitle());
    frame.getContentPane().add(example);

    frame.pack();
    frame.show();
	example.updateChart3d();
}

}

