All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.legrange.console.Percent Maven / Gradle / Ivy

The newest version!
package me.legrange.console;

import static java.lang.String.format;

final class Percent extends Animator {

    Percent() {
    }

    @Override
    String draw(N min, N max, N value) {
        return format("%.1f%%", calculate(min.doubleValue(), max.doubleValue(), value.doubleValue()));
    }

    private double calculate(double min, double max, double value) {
        value = Math.min(Math.max(value,min), max);
        return (value*100) / (max- min);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy