/* Copyright F. P. Marin ( August 21 19:38:19 1997 ) E-mail: felix@bloch.ciens.ucv.ve Permission to use, copy, modify and distribute this software and its documentation for NON-COMERCIAL purposes and without fee is hereby granted provided that this copyright notice appears in all copies. F. P. Marin makes no representations or warranties about the suitability of the software, either express or implied, including but no limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. F. P. Marin shall not be liable for any damage suffered by license as a result of using, modifying or distributing this software or its derivatives. HTML code is */ import java.awt.*; public class StraightInsertion extends java.applet.Applet implements Runnable { Graphics detras; int delay; int dx,h[],height,height1,nelem,nelem1,width,width1; Image imagen; Thread bars=null; public void init() { String s=getParameter("nelem"); nelem=( s!=null ) ? Integer.parseInt(s):20; s=getParameter("delay"); delay=( s!=null ) ? Integer.parseInt(s):42; nelem1=nelem - 1; width=size().width; width1=width - 1; height=size().height; height1=height - 1; dx=width/nelem; disorder(); imagen=createImage(size().width,size().height); detras=imagen.getGraphics(); } public void disorder() { int xi,xf; h=new int[nelem]; xi=height/10; xf=height - xi; for ( int i=0 ; i=0 ) && ( h[j]>insertvalue ) ; --j ) { h[j + 1]=h[j]; repaint(); try { Thread.sleep(delay); } catch (InterruptedException e) {} } h[j + 1]=insertvalue; repaint(); try { Thread.sleep(delay); } catch (InterruptedException e) {} } bars=null; } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { int i,x; detras.setColor(Color.cyan); detras.fillRect(0,0,size().width,size().height); x=0; for ( i=0 ; i