import java.awt.*;// Written by Julian Devlin, 8/97, for the text book// "Introduction to Probability," by Charles M. Grinstead & J. Laurie Snellpublic class StockGraph extends Graph {	boolean owner;	public StockGraph() {		super();		owner = false;	}		public StockGraph(Float[] x, Float[] y) {		super(x, y);		owner = false;	}		public void paint(Graphics g) {			Font f;		String fName;		FontMetrics fm;			if (length > 0) { 					// Make sure we have at least one point			f = g.getFont();			fName = f.getName();			f = new Font(fName, Font.PLAIN, 9);			g.setFont(f);			fm = g.getFontMetrics();					setPoints();				// When we are ready to paint, the dimensions of the component have been			setTicks(true, fm);			// set, so we can calculate coordinates of all the points			g.setColor(new Color(0, 0, 0));			for (int i = 0; i < length - 1; i++) {		// For each point				if (owner == false && yCoords[i].floatValue() == 0)					owner = true;				else if (owner == true && yCoords[i].floatValue() == 1)					owner = false;				if (owner == true) {					g.setColor(new Color(150, 0, 0));					g.drawLine(pixels[i].x, pixels[i].y, pixels[i].x + (pixels[i + 1].x -						pixels[i].x) / 3, pixels[i].y + (pixels[i + 1].y -						pixels[i].y) / 3);				// Make it dashed					g.drawLine(pixels[i + 1].x - (pixels[i + 1].x - pixels[i].x) / 3, 						pixels[i + 1].y - (pixels[i + 1].y - pixels[i].y) / 3, pixels[i + 1].x,						pixels[i + 1].y);					g.setColor(new Color(0, 0, 0));				}				else {					g.drawLine(pixels[i].x, pixels[i].y, pixels[i + 1].x,						pixels[i + 1].y);				// Connect it to the next point				}			}						drawXAxis(g);			drawYAxis(g);			g.setColor(new Color(150, 0, 0));			// Make ticks red			drawTicks(g);			g.setColor(new Color(0, 0, 100));			// Make labels blue			labelTicks(g);			g.setColor(new Color(0, 0, 0));		}	}	}
