/*----------------------------------------------------------------------+ | Title: TimeGraph.java | | | | Author: David E. Joyce | | Department of Mathematics and Computer Science | | Clark University | | Worcester, MA 01610-1477 | | U.S.A. | | | http://aleph0.clarku.edu/~djoyce/home.html | | djoyce@clarku.edu | | | | Date: May, 2002 | +----------------------------------------------------------------------*/ import java.awt.*; public class TimeGraph extends Canvas { private Color background; // the background color private Color color[]; // the colors associated to the q quantities private int history[][]; // the history of the quantities being displayed private int point; // the oldest data point public void init(Color backgroundIn, Color colorIn[], int widthIn) { background = backgroundIn; color = colorIn; point = 0; // see if we need a new history matrix, or if we can use the old one if (history == null || history[0].length != widthIn) history = new int[widthIn][color.length]; // reset the histories to 0 for (int i=0; i max) max = sum; } // now, draw the graph Dimension d = getSize(); g.setColor(background); g.fillRect(0,0,d.width,d.height); int left = 0, right; for (int i=0; i