import bsh.util.BshCanvas; // BshCanvas simply buffers graphics graph( int width, int height ) { canvas=new BshCanvas(); canvas.setSize( width, height ); frame=frame( canvas ); graphics=canvas.getBufferedGraphics(); // draw axis graphics.setColor( Color.red ); graphics.drawLine( 0, height/2, width, height/2 ); graphics.drawLine( width/2, 0, width/2, height ); graphics.setColor( Color.black ); plot(int x, int y) { graphics.fillOval( (x+width/2-1), (y+height/2-1), 3, 3); canvas.repaint(); } return this; } drawSin( graph ) { for (int x=-100; x<100; x++ ) { y=(int)(50*Math.sin( x/10.0 )); graph.plot( x, y ); } }