Source of HSortDisplay.java


  1: import java.awt.*; 
  2: 
  3: public class HSortDisplay implements SortDisplay {
  4:   public int getArraySize(Dimension d) {
  5:     return d.height / 2; 
  6:   }
  7: 
  8:   public void display(int a[], Graphics g, Dimension d) {
  9:     double f = d.width / (double) a.length;
 10:     g.setColor(Color.white);
 11:     g.fillRect(0, 0, d.width, d.height); 
 12:     int y = d.height - 1;    
 13:     g.setColor(Color.black);
 14:     y = d.height - 1;
 15:     for (int i = a.length; --i >= 0; y -= 2)
 16:       g.drawLine(0, y, (int)(a[i] * f), y);
 17:   }
 18: }
 19: