From f5b6b43aec905fd2171b83d852e4e4befbc6f0e4 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 27 Aug 2018 11:37:22 +0300 Subject: [PATCH] Added a progress bar utility --- .../utilities/html/graphs/ProgressBar.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ProgressBar.java 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