All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.chart.JCChartUtil

java.lang.Object
   |
   +----jclass.chart.JCChartUtil

public class JCChartUtil
extends Object
JCChartUtil is a collection of static methods and static variables that are used throughout JCChart.


Variable Index

 o DEFAULT_FLOAT
Default floating point value
 o DEGREES
Angle unit enum value indicating angle unit is degrees
 o GRADS
Angle unit enum value indicating angle unit is gradians
 o M_2PI
Value of pi multiplied by 2
 o M_PI
Value of pi
 o M_PI_2
Value of pi divided by 2
 o M_SQRT2
Square root of 2
 o MAX_PRECISION
Maximum precision value
 o RADIANS
Angle unit enum value indicating angle unit is radians

Constructor Index

 o JCChartUtil()

Method Index

 o abs(double)
Returns the absolute value of a floating point number.
 o abs(int)
Returns the absolute value of an integer number.
 o boundAngle(int, double)
Guarantees that an angle value lies within its valid range.
 o brighter(Color)
Calculates the color even when it is saturated, for example, when it is black or white.
 o clamp(double, double, double)
Ensures that a value within a provided range
 o clamp(int, int, int)
Ensures that a value within a provided range
 o clamp(long, long, long)
Ensures that a value within a provided range
 o convertAngle(int, int, double)
Method to convert an angle value from one unit to another
 o darker(Color)
Calculates the color even when it is saturated, for example, when it is black or white.
 o degToRad(double)
Method to convert degrees to radians
 o format(double, int)
Formats a value for display.
 o log10(double)
Java only provides a natural logarithm function, so this method is necessary to perform log-base-10.
 o logFormat(int)
Formats a value for display on a logarithmic axis.
 o max(double, double)
Returns the maximum of two floating point values.
 o min(double, double)
Returns the minimum of two floating point values.
 o nicePrecision(double)
Returns a nice precision value for this range.
 o pow10(int)
10^x function that makes use of a predefined array (tens_val)
 o precCorrect(int, double)
Rounds a number to the specified precision.
 o radToDeg(double)
Method to convert radians to degrees
 o trace()
Debug method that displays a call stack at a particular point.
 o validUnit(int)
Checks a value to see if it is part of the angle unit enum; DEGREES, RADIANS or GRADS

Variables

 o M_PI
  public final static double M_PI
Value of pi

 o M_PI_2
  public final static double M_PI_2
Value of pi divided by 2

 o M_2PI
  public final static double M_2PI
Value of pi multiplied by 2

 o M_SQRT2
  public final static double M_SQRT2
Square root of 2

 o DEGREES
  public final static int DEGREES
Angle unit enum value indicating angle unit is degrees

 o RADIANS
  public final static int RADIANS
Angle unit enum value indicating angle unit is radians

 o GRADS
  public final static int GRADS
Angle unit enum value indicating angle unit is gradians

 o MAX_PRECISION
  public final static int MAX_PRECISION
Maximum precision value

 o DEFAULT_FLOAT
  public final static double DEFAULT_FLOAT
Default floating point value

Constructors

 o JCChartUtil
  public JCChartUtil()

Methods

 o degToRad
  public final static double degToRad(double d)
Method to convert degrees to radians

Parameters:
d - angle value in degrees
Returns:
converted value in radians
 o radToDeg
  public final static double radToDeg(double r)
Method to convert radians to degrees

Parameters:
d - angle value in radians
Returns:
converted value in degrees
 o validUnit
  public static boolean validUnit(int unit)
Checks a value to see if it is part of the angle unit enum; DEGREES, RADIANS or GRADS

Parameters:
unit - enum representing an angle unit
Returns:
true if the unit enum is valid, false otherwise.
 o boundAngle
  public static double boundAngle(int unit,
                                  double angle)
Guarantees that an angle value lies within its valid range. For example, all degree values should be between -360 and 360.

Parameters:
unit - unit for the angle value
angle - value
bound - angle value
 o log10
  public static double log10(double a)
Java only provides a natural logarithm function, so this method is necessary to perform log-base-10.

Parameters:
a - floating-point value
Returns:
log-base-10 of the provided value
 o nicePrecision
  public static int nicePrecision(double range)
Returns a nice precision value for this range. It does not take into account font size, window size, etc. Instead, use the log10 of the range.

 o clamp
  public static double clamp(double x,
                             double lo,
                             double hi)
Ensures that a value within a provided range

Parameters:
x - value that requires clamping
lo - low value in the range
hi - high value in the range
Returns:
clamped value that lies between lo and hi.
 o clamp
  public static int clamp(int x,
                          int lo,
                          int hi)
Ensures that a value within a provided range

Parameters:
x - value that requires clamping
lo - low value in the range
hi - high value in the range
Returns:
clamped value that lies between lo and hi.
 o clamp
  public static long clamp(long x,
                           long lo,
                           long hi)
Ensures that a value within a provided range

Parameters:
x - value that requires clamping
lo - low value in the range
hi - high value in the range
Returns:
clamped value that lies between lo and hi.
 o logFormat
  public static String logFormat(int exponent)
Formats a value for display on a logarithmic axis. Note that this routine currently calls JCChartUtil.format()

Parameters:
exponent - Exponent of log value
Returns:
formatted string
 o format
  public static String format(double v,
                              int ndigit)
Formats a value for display. Performs the equivalent of sprintf(buffer, "%.*f", ndigit, v);

Parameters:
v - value to format
ndigit - number of digits to appear in the formatted string
Returns:
formatted string
 o convertAngle
  public static double convertAngle(int oldUnit,
                                    int newUnit,
                                    double angle)
Method to convert an angle value from one unit to another

Parameters:
oldUnit - unit of the provided angle value
newUnit - unit of the new angle value
angle - angle value
Returns:
converted angle value
 o pow10
  public static double pow10(int x)
10^x function that makes use of a predefined array (tens_val)

Parameters:
x - x in 10 ^ x
Returns:
requested power of 10
 o precCorrect
  public static double precCorrect(int prec,
                                   double value)
Rounds a number to the specified precision.

Parameters:
prec - requested precision
value - number to be rounded
Returns:
rounded value
 o max
  public static double max(double a,
                           double b)
Returns the maximum of two floating point values. Faster than the naive Math.max()

Parameters:
a - first floating point value
b - second floating point value
Returns:
maximum of a and b
 o min
  public static double min(double a,
                           double b)
Returns the minimum of two floating point values. Faster than the naive Math.min()

Parameters:
a - first floating point value
b - second floating point value
Returns:
minimum of a and b
 o abs
  public static double abs(double a)
Returns the absolute value of a floating point number. than the naive Math.abs()

Parameters:
a - floating point value
Returns:
absolute value of a
 o abs
  public static int abs(int a)
Returns the absolute value of an integer number. than the naive Math.abs()

Parameters:
a - floating point value
Returns:
absolute value of a
 o trace
  public static void trace()
Debug method that displays a call stack at a particular point.

 o brighter
  public static Color brighter(Color color)
Calculates the color even when it is saturated, for example, when it is black or white.

 o darker
  public static Color darker(Color color)
Calculates the color even when it is saturated, for example, when it is black or white.


All Packages  Class Hierarchy  This Package  Previous  Next  Index