/*------------------------------------------------------------------- InsertionCanvas class -----------------------------------------------------------------*/ import java.lang.*; import java.applet.*; import java.awt.*; import java.util.*; import java.io.*; public class InsertionCanvas extends BlocksCanvas { public InsertionCanvas( Sorter sorter ) { super( sorter ); setSize( 20*Sorter.MAX+1,20*Sorter.MAX+1 ); } // end of InsertionCanvas() constructor public void paint( Graphics g ) { if ( blocks.size() > 0 ) { int x = 0; drawBlocks( g,x ); Block key, b1, b2; for ( int i=1; i 0) && (((Block)blocks.elementAt(pos-1)).getValue() > key.getValue())) { blocks.setElementAt( (Block)blocks.elementAt(pos-1),pos ); pos--; } // end while blocks.setElementAt( key,pos ); x += 20; drawBlocks( g,x ); } // end for } } // end of paint() method } /* end of class InsertionCanvas */