1
15
16 package gate.util;
17
18 import java.io.PrintStream;
19
20 import gate.event.ProgressListener;
21
22
23
27 public class ProgressPrinter implements ProgressListener {
28
29
31 private static final boolean DEBUG = false;
32
33
40 public ProgressPrinter(PrintStream out, int numberOfSteps) {
41 this.out = out;
42 this.numberOfSteps = numberOfSteps;
43 }
44
45
50 public ProgressPrinter(PrintStream out) {
51 this.out = out;
52 }
53
54 public void processFinished() {
55 for(int i = currentValue; i < numberOfSteps; i++) {
56 out.print("#");
57 }
58 out.println("]");
59 currentValue = 0;
60 started = false;
61 }
62
63 public void progressChanged(int newValue) {
64 if(!started){
65 out.print("[");
66 started = true;
67 }
68 newValue = newValue * numberOfSteps / 100;
69 if(newValue > currentValue){
70 for(int i = currentValue; i < newValue; i++) {
71 out.print("#");
72 }
73 currentValue = newValue;
74 }
75 }
76
77
79 int currentValue = 0;
80
81
83 int numberOfSteps = 70;
84
85
86 PrintStream out;
87
88
89 boolean started = false;
90
91 }