All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.eou.toolkit.util.Normalizer

java.lang.Object
   |
   +----com.ibm.eou.toolkit.util.Normalizer

public class Normalizer
extends Object
This class contains methods to map values from one range to another in several different ways


Constructor Index

 o Normalizer()

Method Index

 o normalize(long, long, long, double, double)
Compute a value in a new range corresponding to the given value in the given range.
 o normalizeBalanced(long, long, long, int, int)
A version of normalizeBalanced where the new range and the return value has type int rather than long.
 o normalizeBalanced(long, long, long, long, long)
Compute a value in a new range corresponding to the given value in the given range.
 o normalizeDown(long, long, long, int, int)
A version of normalizeDown where the new range and the return value has type int rather than long.
 o normalizeDown(long, long, long, long, long)
Compute a value in a new range corresponding to the given value in the given range.
 o normalizeNearest(double, double, double, int, int)
A version of normalizeNearest where the range and value have type double rather than long, and the new range and the return value have type int rather than long.
 o normalizeNearest(double, double, double, long, long)
A version of normalizeNearest where the range and value have type double rather than long.
 o normalizeNearest(long, long, long, int, int)
A version of normalizeNearest where the new range and the return value have type int rather than long.
 o normalizeNearest(long, long, long, long, long)
Compute a value in a new range corresponding to the given value in the given range.
 o normalizeUp(long, long, long, int, int)
A version of normalizeUp where the new range and the return value has type int rather than long
 o normalizeUp(long, long, long, long, long)
Compute a value in a new range corresponding to the given value in the given range.
 o unNormalizeBalanced(long, long, long, long, long)
Compute a value in a new range corresponding to the given value in the given range.

Constructors

 o Normalizer
 protected Normalizer()

Methods

 o normalizeNearest
 public static long normalizeNearest(long min,
                                     long max,
                                     long value,
                                     long newMin,
                                     long newMax)
Compute a value in a new range corresponding to the given value in the given range. The new range and the returned value are of type long, and the rounding is done to give the nearest value in the new range corresponding to the given value in the original range.

For example, when mapping from the range [0,100] into the range [0,3], this function returns values as follows:
0-16gives0
17-49gives1
50-83gives2
84-100gives3

When mapping from the range [0,3] into the range [0,100], this function returns values as follows:
0gives0
1gives33
2gives66
3gives100

Parameters:
min - start of the original range
max - end of the original range
value - given value in the original range
newMin - start of the new range
newMax - end of the new range
Returns:
corresponding value in the new range
See Also:
normalizeDown, normalizeUp, normalize
 o normalizeNearest
 public static int normalizeNearest(long min,
                                    long max,
                                    long value,
                                    int newMin,
                                    int newMax)
A version of normalizeNearest where the new range and the return value have type int rather than long.

See Also:
normalizeNearest
 o normalizeNearest
 public static long normalizeNearest(double min,
                                     double max,
                                     double value,
                                     long newMin,
                                     long newMax)
A version of normalizeNearest where the range and value have type double rather than long.

See Also:
normalizeNearest
 o normalizeNearest
 public static int normalizeNearest(double min,
                                    double max,
                                    double value,
                                    int newMin,
                                    int newMax)
A version of normalizeNearest where the range and value have type double rather than long, and the new range and the return value have type int rather than long.

See Also:
normalizeNearest
 o normalizeBalanced
 public static long normalizeBalanced(long min,
                                      long max,
                                      long value,
                                      long newMin,
                                      long newMax)
Compute a value in a new range corresponding to the given value in the given range. The new range and the returned value are of type long, and the rounding is done in a balanced fashion to give the nearest value in the new range corresponding to the given value in the original range.

For example, when mapping from the range [0,100] into the range [0,3], this function returns values as follows:
0-25gives0
26-50gives1
51-75gives2
76-100gives3

When mapping from the range [0,3] into the range [0,100], this function returns values as follows:
0gives0
1gives25
2gives50
3gives75

The inverse of this mapping is done by the unNormalizeBalanced method.

Parameters:
min - start of the original range
max - end of the original range
value - given value in the original range
newMin - start of the new range
newMax - end of the new range
Returns:
corresponding value in the new range
See Also:
unNormalizeBalanced, normalizeDown, normalizeUp, normalize
 o unNormalizeBalanced
 public static long unNormalizeBalanced(long min,
                                        long max,
                                        long value,
                                        long newMin,
                                        long newMax)
Compute a value in a new range corresponding to the given value in the given range. The new range and the returned value are of type long, and the rounding is done in an exotic fashion intended to provide an inverse to the normalizeBalanced method.

For example, when mapping from the range [0,3] into the range [0,100], this function returns values as follows:
0gives0
1gives26
2gives51
3gives76

When mapping from the range [0,100] into the range [0,3], this function returns values as follows:
0gives0
1-25gives1
26-50gives2
51-75gives3
76-100gives4

Parameters:
min - start of the original range
max - end of the original range
value - given value in the original range
newMin - start of the new range
newMax - end of the new range
Returns:
corresponding value in the new range
See Also:
normalizeBalanced, normalizeUp, normalizeDown, normalize
 o normalizeDown
 public static long normalizeDown(long min,
                                  long max,
                                  long value,
                                  long newMin,
                                  long newMax)
Compute a value in a new range corresponding to the given value in the given range. The new range and the returned value are of type long, and the rounding is done downwards.

For example, when mapping from the range [0,100] into the range [0,3], this function returns values as follows:
0-33gives0
34-66gives1
67-99gives2
100gives3

When mapping from the range [0,3] into the range [0,100], this function returns values as follows:
0gives0
1gives33
2gives66
3gives100

Parameters:
min - start of the original range
max - end of the original range
value - given value in the original range
newMin - start of the new range
newMax - end of the new range
Returns:
corresponding value in the new range
See Also:
normalizeBalanced, normalizeUp, normalize
 o normalizeUp
 public static long normalizeUp(long min,
                                long max,
                                long value,
                                long newMin,
                                long newMax)
Compute a value in a new range corresponding to the given value in the given range. The new range and the returned value are of type long, and the rounding is done upwards.

For example, when mapping from the range [0,100] into the range [0,3], this function returns values as follows:
0gives0
1-33gives1
34-66gives2
67-100gives3

When mapping from the range [0,3] into the range [0,100], this function returns values as follows:
0gives0
1gives34
2gives67
3gives100

Parameters:
min - start of the original range
max - end of the original range
value - given value in the original range
newMin - start of the new range
newMax - end of the new range
Returns:
corresponding value in the new range
See Also:
normalizeBalanced, normalizeDown, normalize
 o normalizeBalanced
 public static int normalizeBalanced(long min,
                                     long max,
                                     long value,
                                     int newMin,
                                     int newMax)
A version of normalizeBalanced where the new range and the return value has type int rather than long.

See Also:
normalizeBalanced
 o normalizeDown
 public static int normalizeDown(long min,
                                 long max,
                                 long value,
                                 int newMin,
                                 int newMax)
A version of normalizeDown where the new range and the return value has type int rather than long.

See Also:
normalizeDown
 o normalizeUp
 public static int normalizeUp(long min,
                               long max,
                               long value,
                               int newMin,
                               int newMax)
A version of normalizeUp where the new range and the return value has type int rather than long

See Also:
normalizeUp
 o normalize
 public static double normalize(long min,
                                long max,
                                long value,
                                double newMin,
                                double newMax)
Compute a value in a new range corresponding to the given value in the given range. The new range and the returned value are of type double, and so there is no rounding done.

Parameters:
min - start of the original range
max - end of the original range
value - given value in the original range
newMin - start of the new range
newMax - end of the new range
Returns:
corresponding value in the new range
See Also:
normalizeBalanced, normalizeDown, normalizeUp, unNormalizeBalanced

All Packages  Class Hierarchy  This Package  Previous  Next  Index