4 import java.awt.image.*;
11 private int canvasWidth, canvasHeight;
12 private int x, y, width, height;
13 private double percent;
14 private long startTime;
16 private boolean showBar;
17 private boolean negativeProgress;
18 private static boolean autoHide;
20 private Color barColor = Color.gray;
21 private Color fillColor =
new Color(204,204,255);
22 private Color backgroundColor = ij.ImageJ.backgroundColor;
23 private Color frameBrighter = backgroundColor.brighter();
24 private Color frameDarker = backgroundColor.darker();
28 this.canvasWidth = canvasWidth;
29 this.canvasHeight = canvasHeight;
32 width = canvasWidth - 8;
33 height = canvasHeight - 7;
35 negativeProgress =
false;
40 void fill3DRect(Graphics g,
int x,
int y,
int width,
int height) {
41 g.setColor(fillColor);
42 g.fillRect(x+1, y+1, width-2, height-2);
43 g.setColor(frameDarker);
44 g.drawLine(x, y, x, y+height);
45 g.drawLine(x+1, y, x+width-1, y);
46 g.setColor(frameBrighter);
47 g.drawLine(x+1, y+height, x+width, y+height);
48 g.drawLine(x+width, y, x+width, y+height-1);
55 public void show(
int currentValue,
int finalValue) {
56 if (currentValue>=finalValue)
59 percent = Math.min((currentValue+1)/(
double)finalValue, 1.0);
69 public void show(
double percent) {
74 startTime = System.currentTimeMillis();
78 long time2 = System.currentTimeMillis();
80 if ((time2 - startTime)>=30)
84 negativeProgress = percent<this.percent;
85 this.percent = percent;
96 public void update(Graphics g) {
100 public void paint(Graphics g) {
102 fill3DRect(g, x-1, y-1, width+1, height+1);
105 g.setColor(backgroundColor);
106 g.fillRect(0, 0, canvasWidth, canvasHeight);
110 void drawBar(Graphics g) {
113 int barEnd = (int)(width*percent);
114 if (negativeProgress) {
115 g.setColor(fillColor);
116 g.fillRect(barEnd+2, y, width-barEnd, height);
118 g.setColor(barColor);
119 g.fillRect(x, y, barEnd, height);
123 public Dimension getPreferredSize() {
124 return new Dimension(canvasWidth, canvasHeight);