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.
-
DEFAULT_FLOAT
- Default floating point value
-
DEGREES
- Angle unit enum value indicating angle unit is degrees
-
GRADS
- Angle unit enum value indicating angle unit is gradians
-
M_2PI
- Value of pi multiplied by 2
-
M_PI
- Value of pi
-
M_PI_2
- Value of pi divided by 2
-
M_SQRT2
- Square root of 2
-
MAX_PRECISION
- Maximum precision value
-
RADIANS
- Angle unit enum value indicating angle unit is radians
-
JCChartUtil()
-
-
abs(double)
- Returns the absolute value of a floating point number.
-
abs(int)
- Returns the absolute value of an integer number.
-
boundAngle(int, double)
- Guarantees that an angle value lies within its valid range.
-
brighter(Color)
- Calculates the color even when it is saturated, for example,
when it is black or white.
-
clamp(double, double, double)
- Ensures that a value within a provided range
-
clamp(int, int, int)
- Ensures that a value within a provided range
-
clamp(long, long, long)
- Ensures that a value within a provided range
-
convertAngle(int, int, double)
- Method to convert an angle value from one unit to another
-
darker(Color)
- Calculates the color even when it is saturated, for example,
when it is black or white.
-
degToRad(double)
- Method to convert degrees to radians
-
format(double, int)
- Formats a value for display.
-
log10(double)
- Java only provides a natural logarithm function, so this
method is necessary to perform log-base-10.
-
logFormat(int)
- Formats a value for display on a logarithmic axis.
-
max(double, double)
- Returns the maximum of two floating point values.
-
min(double, double)
- Returns the minimum of two floating point values.
-
nicePrecision(double)
- Returns a nice precision value for this range.
-
pow10(int)
- 10^x function that makes use of a predefined array (tens_val)
-
precCorrect(int, double)
- Rounds a number to the specified precision.
-
radToDeg(double)
- Method to convert radians to degrees
-
trace()
- Debug method that displays a call stack at a particular
point.
-
validUnit(int)
- Checks a value to see if it is part of the angle unit
enum; DEGREES, RADIANS or GRADS
M_PI
public final static double M_PI
- Value of pi
M_PI_2
public final static double M_PI_2
- Value of pi divided by 2
M_2PI
public final static double M_2PI
- Value of pi multiplied by 2
M_SQRT2
public final static double M_SQRT2
- Square root of 2
DEGREES
public final static int DEGREES
- Angle unit enum value indicating angle unit is degrees
RADIANS
public final static int RADIANS
- Angle unit enum value indicating angle unit is radians
GRADS
public final static int GRADS
- Angle unit enum value indicating angle unit is gradians
MAX_PRECISION
public final static int MAX_PRECISION
- Maximum precision value
DEFAULT_FLOAT
public final static double DEFAULT_FLOAT
- Default floating point value
JCChartUtil
public JCChartUtil()
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
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
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.
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
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
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.
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.
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.
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.
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
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
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
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
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
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
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
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
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
trace
public static void trace()
- Debug method that displays a call stack at a particular
point.
brighter
public static Color brighter(Color color)
- Calculates the color even when it is saturated, for example,
when it is black or white.
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