Source of VSortDisplay.java


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