Package me.tongfei.progressbar
Class DefaultProgressBarRenderer
- java.lang.Object
-
- me.tongfei.progressbar.DefaultProgressBarRenderer
-
- All Implemented Interfaces:
ProgressBarRenderer
public class DefaultProgressBarRenderer extends java.lang.Object implements ProgressBarRenderer
Default progress bar renderer (seeProgressBarRenderer).- Since:
- 0.8.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Function<ProgressState,java.util.Optional<java.time.Duration>>etaprivate booleanisEtaShownprivate booleanisSpeedShownprivate java.text.DecimalFormatspeedFormatprivate java.time.temporal.ChronoUnitspeedUnitprivate ProgressBarStylestyleprivate java.lang.StringunitNameprivate longunitSize
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultProgressBarRenderer(ProgressBarStyle style, java.lang.String unitName, long unitSize, boolean isSpeedShown, java.text.DecimalFormat speedFormat, java.time.temporal.ChronoUnit speedUnit, boolean isEtaShown, java.util.function.Function<ProgressState,java.util.Optional<java.time.Duration>> eta)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringetaString(ProgressState progress)protected java.lang.Stringpercentage(ProgressState progress)protected intprogressFractionalPart(ProgressState progress, int length)protected intprogressIntegralPart(ProgressState progress, int length)protected java.lang.Stringratio(ProgressState progress)java.lang.Stringrender(ProgressState progress, int maxLength)Renders the current progress bar state as a string to be shown by a consumer.protected java.lang.Stringspeed(ProgressState progress)
-
-
-
Field Detail
-
style
private ProgressBarStyle style
-
unitName
private java.lang.String unitName
-
unitSize
private long unitSize
-
isSpeedShown
private boolean isSpeedShown
-
speedFormat
private java.text.DecimalFormat speedFormat
-
speedUnit
private java.time.temporal.ChronoUnit speedUnit
-
isEtaShown
private boolean isEtaShown
-
eta
private java.util.function.Function<ProgressState,java.util.Optional<java.time.Duration>> eta
-
-
Constructor Detail
-
DefaultProgressBarRenderer
protected DefaultProgressBarRenderer(ProgressBarStyle style, java.lang.String unitName, long unitSize, boolean isSpeedShown, java.text.DecimalFormat speedFormat, java.time.temporal.ChronoUnit speedUnit, boolean isEtaShown, java.util.function.Function<ProgressState,java.util.Optional<java.time.Duration>> eta)
-
-
Method Detail
-
progressIntegralPart
protected int progressIntegralPart(ProgressState progress, int length)
-
progressFractionalPart
protected int progressFractionalPart(ProgressState progress, int length)
-
etaString
protected java.lang.String etaString(ProgressState progress)
-
percentage
protected java.lang.String percentage(ProgressState progress)
-
ratio
protected java.lang.String ratio(ProgressState progress)
-
speed
protected java.lang.String speed(ProgressState progress)
-
render
public java.lang.String render(ProgressState progress, int maxLength)
Description copied from interface:ProgressBarRendererRenders the current progress bar state as a string to be shown by a consumer.- Specified by:
renderin interfaceProgressBarRenderer- Parameters:
progress- The current progress bar statemaxLength- The maximum length as dictated by the consumer- Returns:
- Rendered string to be consumed by the consumer
-
-