diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ProgressBar.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ProgressBar.java new file mode 100644 index 000000000..a29ebc932 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ProgressBar.java @@ -0,0 +1,39 @@ +package com.djrapitops.plan.utilities.html.graphs; + +import com.djrapitops.plan.data.store.mutators.formatting.Formatters; + +/** + * Utility for creating ProgressBars. + * + * @author Rsl1122 + */ +public class ProgressBar { + + private final int obtained; + private final int max; + + private final String color; + + public ProgressBar(int obtained, int max) { + this(obtained, max, "teal"); + } + + public ProgressBar(int obtained, int max, String color) { + this.obtained = obtained; + this.max = max; + this.color = color; + } + + public String toHtml() { + double percentage = obtained * 1.0 / max; + int percentageRounded = (int) percentage; + + return "
" + + obtained + " / " + max + " (" + Formatters.percentage().apply(percentage) + ")" + + "
"; + } + +} \ No newline at end of file