import jas.hist.*;
import jas.hist.test.MemoryDataSource;
import jas.plot.PrintHelper;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class PrintExample extends JFrame implements	ActionListener
{
	PrintExample()
	{
		super("Print Example");
		plot = new JASHist();
					 
		JASHistData	data = plot.addData(new	MemoryDataSource());

		plot.setTitle("Java	Memory Usage");
		plot.setDataAreaBorderType(plot.ETCHED);
		plot.getYAxis().setLabel("MBytes");
		plot.getXAxis().setLabel("Time (seconds)");
		plot.setAllowUserInteraction(false);
					 
		data.show(true);
		getContentPane().add(plot);
				   
	  JButton printButton =	new	JButton("Print...");
	  printButton.addActionListener(this);
	  getContentPane().add(printButton,BorderLayout.SOUTH);
				   
		setSize(400,400);
		show();
	}
   // Called when print	button is pushed
   public void actionPerformed(ActionEvent e)
   {
	  try
	  {
		 PrintHelper ph	= PrintHelper.instance();
		 ph.printTarget(plot);
	  }
	  catch	(Exception x) // Error while printing
	  {
		 x.printStackTrace();
	  }
   }
	public static void main(String[] argv)
	{
		new	PrintExample();
	}
   private JASHist plot;
}
