import java.awt.*; class MyCanvas extends Canvas { String numstring, sortType; int x, j; public float barwid, barhei, space; public float[] heights; public boolean[] arraycolor; SortClass sorter; MyCanvas (SortClass temp) { sorter = temp; } public void drawArrow(Graphics g,int x1,int y1,int x2,int y2) { int r=15; g.drawLine(x1,y1,x2,y2); int[] x=new int[3]; int[] y=new int[3]; x[0]=x2; y[0]=y2; double angle1=Math.atan2(y2-y1,x1-x2); x[1]=(int)Math.floor(r*Math.cos(angle1+Math.PI/6))+x2; y[1]=-(int)Math.floor(r*Math.sin(angle1+Math.PI/6))+y2; x[2]=(int)Math.floor(r*Math.cos(angle1-Math.PI/6))+x2; y[2]=-(int)Math.floor(r*Math.sin(angle1-Math.PI/6))+y2; g.fillPolygon(x,y,3); } public void paint(Graphics g) { int w=size().width; int h=size().height; int i; if (sorter.currsort.equals("select") || sorter.currsort.equals("bubble") || sorter.currsort.equals("insert") || sorter.currsort.equals("quick ") || sorter.currsort.equals("merge ") || sorter.currsort.equals("shell ")) { g.setColor(sorter.blockcolor); numstring = sorter.blockField.getText(); try { x = Integer.parseInt(numstring); } catch (NumberFormatException e) { x = 20; } sortType = sorter.orderChoices.getSelectedItem(); space = (float)x/(float)10; barwid = (float)w/((float)x+space); barhei = (float)h/(float)(x+1); if(sorter.newpaint == false) { for(i=0;i