1
1
package org .hydev .mcpm .client .interaction ;
2
2
3
- import java .util .Objects ;
4
-
5
3
import static java .lang .String .format ;
6
4
7
5
/**
@@ -14,26 +12,33 @@ public class ProgressRow
14
12
{
15
13
private final long total ;
16
14
private long completed ;
17
- private final String unit ;
18
-
19
- private long startTime ;
15
+ private String unit ;
20
16
private ProgressBar pb ;
17
+ private String desc ;
18
+ private int descLen ;
19
+ private String fmt ;
20
+
21
+ private final long startTime ;
21
22
22
- public ProgressRow (long total , String unit )
23
+ public ProgressRow (long total )
23
24
{
24
25
this .total = total ;
25
26
this .completed = 0 ;
26
-
27
- // Add leading space
28
- this .unit = (!unit .isBlank () && !unit .startsWith (" " )) ? " " + unit : unit ;
27
+ this .unit = " it" ;
28
+ this .desc = "" ;
29
+ this .descLen = 20 ;
30
+ this .fmt = "{desc}{speed} {eta} {prefix}{progbar}{suffix} {%done}" ;
29
31
30
32
// Record start time for speed estimation
31
33
this .startTime = System .nanoTime ();
32
34
}
33
35
34
- public ProgressRow (long total )
36
+ /**
37
+ * @return Elapsed time in seconds
38
+ */
39
+ private double elapsed ()
35
40
{
36
- this ( total , "it" ) ;
41
+ return ( System . nanoTime () - startTime ) / 1e9d ;
37
42
}
38
43
39
44
/**
@@ -87,4 +92,29 @@ public void set(long completed)
87
92
pb .update ();
88
93
if (completed >= total ) pb .finishBar (this );
89
94
}
95
+
96
+ public ProgressRow desc (String desc )
97
+ {
98
+ this .desc = desc ;
99
+ return this ;
100
+ }
101
+
102
+ public ProgressRow descLen (int descLen )
103
+ {
104
+ this .descLen = descLen ;
105
+ return this ;
106
+ }
107
+
108
+ public ProgressRow unit (String unit )
109
+ {
110
+ // Add leading space
111
+ this .unit = (!unit .isBlank () && !unit .startsWith (" " )) ? " " + unit : unit ;
112
+ return this ;
113
+ }
114
+
115
+ public ProgressRow fmt (String fmt )
116
+ {
117
+ this .fmt = fmt ;
118
+ return this ;
119
+ }
90
120
}
0 commit comments