/** * author Jia Xiaoping * author Alex Rudniy * Rounded rectangles changing color at each iteration */ import java.awt.*; public class VRoundRectDisplay implements SortDisplay { public int getArraySize(Dimension d) { return d.width / 14; } public void display(int a[], Graphics g, Dimension d) { g.setColor(Color.white); g.fillRect(0, 0, d.width, d.height); double f = d.height / (double) a.length; double cf = 255.0 / (double) a.length; int x = d.width - 14; for (int i = a.length; --i >= 0; x -= 14) { g.setColor(new Color((int)(255 * Math.random()), (int)(255 * Math.random()), (int)(255 * Math.random()))); g.fillRoundRect(x, d.height - (int)(a[i] * f), 14, (int)(a[i] * f), 10, 2); } } }