Class QuantityBucketSelectors

    • Method Detail

      • powerOf2

        public static <T extends Quantity<T>> BucketSelector<Quantity<T>> powerOf2​(int minPower,
                                                                                   Unit<T> baseUnit,
                                                                                   QuantityFactory<T> quantityFactory,
                                                                                   int numBuckets)
        Get a BucketSelector that has upper bound values that are Quantity<T> instances whose numeric component is part of an exponential series made up of consecutive whole-number powers of 2.

        Example: arguments minPower=2, baseUnit=Sievert, numBuckets=5 would generate upper bound values of 4 Sv, 8 Sv, 16 Sv, and 32 Sv.

        Type Parameters:
        T - The kind of quantity that the BucketSelector will bucket. Example: Temperature.
        Parameters:
        minPower - The smallest power of 2 to use when generating upper bound values.
        baseUnit - The base "ones" unit of measurement type T in the desired system of units. Example: kilogram, meter, square foot.
        quantityFactory - An object that can instantiate objects of type Quantity<T>.
        numBuckets - The number of buckets.
        Returns:
        A BucketSelector<Long> instance.
      • exponential

        public static <T extends Quantity<T>> BucketSelector<Quantity<T>> exponential​(double base,
                                                                                      Unit<T> baseUnit,
                                                                                      QuantityFactory<T> quantityFactory,
                                                                                      double minPower,
                                                                                      int numBuckets)
        Get a BucketSelector that has upper bound values that are Quantity<T> instances whose numeric component is part of an exponential series. Each bucket value's exponent is 1.0 plus the exponent of the previous bucket value.

        Example: arguments base=5.0, baseUnit=Acre, minPower=0.0, and numBuckets=5 would generate base and exponent values of 50 acres, 51 acres, 52 acres, and 53 acres, so the upper bound values would be 1 acre, 5 acres, 25 acres, and 125 acres.

        Type Parameters:
        T - The kind of quantity that the BucketSelector will bucket. Example: Temperature.
        Parameters:
        base - The base that will be raised to the specified exponents to generate upper bound values.
        baseUnit - The base "ones" unit of measurement type T in the desired system of units. Example: kilogram, meter, square foot.
        quantityFactory - An object that can instantiate objects of type Quantity<T>.
        minPower - The smallest exponent to use when generating upper bound values.
        numBuckets - The number of buckets into which values should be counted.
        Returns:
        A BucketSelector<Quantity<T>> instance.
      • linear

        public static <T extends Quantity<T>> BucketSelector<Quantity<T>> linear​(Unit<T> baseUnit,
                                                                                 QuantityFactory<T> quantityFactory,
                                                                                 Quantity<T> lowestUpperBound,
                                                                                 Quantity<T> highestUpperBound,
                                                                                 int numBuckets)
        Get a BucketSelector that has upper bound values that are evenly distributed between a smallest and largest value.

        arguments baseUnit=kilogram, lowestUpperBound=0, highestUpperBound=20, and numBuckets=6 would generate upper bound values 0, 5, 10, 15, and 20. Example: 0 kg, 5 kg, 10 kg, 15 kg, 20 kg.

        Type Parameters:
        T - The kind of quantity that the BucketSelector will bucket. Example: Temperature.
        Parameters:
        baseUnit - The base "ones" unit of measurement type T in the desired system of units. Example: kilogram, meter, square foot.
        quantityFactory - An object that can instantiate objects of type Quantity<T>.
        lowestUpperBound - The upper-bound value for the first bucket (index 0).
        highestUpperBound - The upper-bound value for the next-to-last bucket (index (numBuckets - 2)).
        numBuckets - The total number of buckets.
        Returns:
        A BucketSelector<Long> instance.