-
Notifications
You must be signed in to change notification settings - Fork 0
/
SorterCanvas.java
62 lines (52 loc) · 1.25 KB
/
SorterCanvas.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.awt.*;
import java.util.ArrayList;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import java.util.Random;
public class SorterCanvas extends Canvas
{
Rect[] array;
int width = 600;
int wid;
int height = width+50;
int realWidth = width+80;
//ArrayList<Rectangle> rects = new ArrayList<Rectangle>();
int red, green;
int max = Integer.MAX_VALUE-2;
Random rand = new Random();
public SorterCanvas()
{
setSize(realWidth,height);
clearVals();
}
public void setRed(int r)
{
red = r;
}
public void setGreen(int g)
{
green = g;
}
public void clearVals()
{
green = max;
red = max;
}
public void paint(Graphics g)
{
//rects.clear();
g.setColor(Color.BLACK);
g.fillRect(0, 0, realWidth+20, height);
if(array.length != 0)
wid = (int)((realWidth/array.length));
for (int i = 0; i<array.length; i++)
{
//Rectangle r = new Rectangle(10+(wid)*i,height - array[i] , wid-1, array[i]);
array[i].setIndex(i);
array[i].setWidth(wid);
array[i].drawMe(g);
//rects.add(r);
}
}
}