package jas2.hist.test;

import jas2.hist.*;
import jas2.hist.util.*;
import java.util.*;

public class MemoryDataSource extends ObserverAdapter implements 
	HasDataSource, Rebinnable1DHistogramData, HasStyle
{
	private static final HistogramUpdate hdr = new HistogramUpdate(HistogramUpdate.DATA_UPDATE,true);
	private static final int SECONDS = 60;
	
	public MemoryDataSource()
	{
		super(t);
	}
	public DataSource getDataSource(String param) 
	{
		return this;
	}
	public double[][] rebin(int nbin, double min, double max, boolean wantErrors, boolean hurry)
	{
		double[] result = t.getSnapshot();
		double[][] r = { result };
		return r;
	}
	public double getMin()
	{
		return -SECONDS;
	}
	public double getMax()
	{
		return 0;
	}
	public int getBins()
	{
		return SECONDS;
	}
	public boolean isRebinnable()
	{
		return false;
	}
	public int getAxisType()
	{
		return Rebinnable1DHistogramData.INTEGER;
	}
	public String[] getAxisLabels()
	{
		return null;
	}
	public Statistics getStatistics()
	{
		return null;
	}
	public String getTitle()
	{
		return "Java Memory Usage";
	}
	public JASHistStyle getStyle()
	{
		JASHist1DHistogramStyle style = new JASHist1DHistogramStyle();
		style.setShowErrorBars(false);
		style.setShowDataPoints(true);
		style.setShowLinesBetweenPoints(true);
		style.setShowHistogramBars(false);
		return style;
	}
	private static MemoryThread t = new MemoryThread();
	private static class MemoryThread extends Observable implements Runnable
	{
		MemoryThread()
		{
			bins = new double[SECONDS];
			for (int i=0; i=SECONDS) index = 0;
					}
					setChanged();
					notifyObservers(hdr);
					thread.sleep(1000);			
				}
			}
			catch (InterruptedException x) { }
		}
		synchronized double[] getSnapshot()
		{
			double[] result = new double[SECONDS];
			int j=0;
			for (int i=index; i 

Ads help maintain this website.