|
JClass DesktopViews 6.3.0 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.klg.jclass.util.JCNumberUtil
JCNumberUtil
is a collection of static methods and static
variables that are used throughout
JCChart
and JCGauge
components.
Field Summary | |
static char |
DECIMAL
|
static double |
DEFAULT_FLOAT
Default floating point value. |
static int |
DEGREES
Angle unit enum value indicating angle unit is degrees. |
static int |
GRADS
Angle unit enum value indicating angle unit is gradians. |
static double |
LOG_TEN_BASE_E
Precalculated ln(10) is more accurate. |
static double |
M_2PI
Value of pi multiplied by 2. |
static double |
M_PI
Value of pi. |
static double |
M_PI_2
Value of pi divided by 2. |
static double |
M_SQRT2
Square root of 2. |
static int |
RADIANS
Angle unit enum value indicating angle unit is radians. |
static int |
XBYX1
pix_x lies outside x1. |
static int |
XBYX2
pix_x lies outside x2. |
static int |
XINSIDE
pix_x lies between (x1, x2). |
static int |
YBYORIGIN
pix_y lies by origin. |
static int |
YBYTOP
pix_y lies outside top line. |
static int |
YINSIDE
pix_y lies within top and bottom line. |
Constructor Summary | |
JCNumberUtil()
|
Method Summary | |
static double |
abs(double a)
Returns the absolute value of a floating point number. |
static int |
abs(int a)
Returns the absolute value of an integer number. |
static double |
boundAngle(int unit,
double angle)
Guarantees that an angle value lies within its valid range. |
static Color |
brighter(Color color)
Calculates the color even when it is saturated (for example, when it is black or white). |
static double |
calcError(int base)
Calculates an appropriate error based on a precision value. |
static double |
clamp(double x,
double lo,
double hi)
Ensures that a value is within a provided range. |
static int |
clamp(int x,
int lo,
int hi)
Ensures that a value is within a provided range. |
static long |
clamp(long x,
long lo,
long hi)
Ensures that a value is within a provided range. |
static boolean |
colorsNear(Color c1,
Color c2)
Determines whether two colors are close to the same color. |
static double |
convertAngle(int oldUnit,
int newUnit,
double angle)
Converts an angle value from one unit to another. |
static String |
convertFromSN(String s)
|
static int |
countInString(String token,
String target)
Counts the occurrences of String token within the larger target String. |
static Color |
darker(Color color)
Calculates the color even when it is saturated (for example, when it is black or white). |
static double |
degToRad(double d)
Converts degrees to radians. |
static int |
distance(int p,
int start,
int width)
Calculates the separation between an integer value and the nearest boundary of an integer range. |
static int |
distance(int x1,
int y1,
int x2,
int y2)
Calculates the distance between two points. |
static int |
distance(int x,
int y,
Rectangle rect)
Calculates the distance betwen a point and a rectangle. |
static long |
distTrap(int pix_x,
int pix_y,
int yorigin,
double x1,
double x2,
double y1,
double y2)
Finds the distance from the passed-in point to the specified trapezoid. |
static double |
fmod(double v1,
double v2)
Returns the floating-point remainder of the division of v1 by v2. |
static String |
format(double v,
int ndigit)
Formats a value for display. |
static void |
fudgeItalicLabel(Font font,
Dimension dim)
Fudges the size of a label with italic fonts by making it a little bigger so that all of the italicized font can be seen. |
static char |
getDecimalPointChar()
Gets the decimal point char. |
static int |
iceil(double val)
Takes the ceiling of a floating point value. |
static int |
ifloor(double val)
Takes the floor of a floating point value. |
static String |
internalFormat(double v,
int ndigit)
|
static int |
intLog10(double a)
Returns log10 of a value, rounded to the nearest integer value. |
static boolean |
isHTML(String s)
Deprecated. Use com.klg.jclass.util.swing.TextRenderer.isHTML() instead |
static int |
locateX(double x,
double lx,
double ux)
Locates an x value within given x bounds. |
static int |
locateXY(double x,
double y,
double lx,
double ux,
double ly,
double uy)
Locates a point within given x and y bounds. |
static int |
locateY(double y,
double ly,
double uy)
Locates a y value within given y bounds. |
static double |
log10(double a)
Java only provides a natural logarithm function, so this method is necessary to perform log10 operations. |
static String |
logFormat(int exponent)
Formats a value for display on a logarithmic axis. |
static double |
max(double a,
double b)
Returns the maximum of two floating point values. |
static double |
min(double a,
double b)
Returns the minimum of two floating point values. |
static int |
nicePrecision(double range)
Returns a nice precision value for this range. |
static Polygon |
pointsToPolygon(Point[] points)
Takes an array of points and converts it into a Polygon object. |
static double |
pow10(int x)
10x function that makes use of a predefined array ( tens_val ). |
static double |
precCeil(int prec,
double value)
Takes the ceiling of a number to the specified precision. |
static double |
precCorrect(int prec,
double value)
Rounds a number to the specified precision. |
static double |
precFloor(int prec,
double value)
Truncates a number to the specified precision. |
static double |
radToDeg(double r)
Converts radians to degrees. |
static int |
tickBasedPrecision(double numsp)
Returns a precision value based on the numspacing or tickspacing value of an axis. |
static void |
trace()
Debug method that displays a call stack at a particular point. |
static boolean |
validUnit(int unit)
Checks a value to see if it is part of the angle unit enum; DEGREES , RADIANS , or GRADS . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final double M_PI
public static final double M_PI_2
public static final double M_2PI
public static final double M_SQRT2
public static final int DEGREES
public static final int RADIANS
public static final int GRADS
public static final double DEFAULT_FLOAT
public static final double LOG_TEN_BASE_E
public static char DECIMAL
public static final int XINSIDE
pix_x
lies between (x1, x2).
public static final int XBYX1
pix_x
lies outside x1.
public static final int XBYX2
pix_x
lies outside x2.
public static final int YINSIDE
pix_y
lies within top and bottom line.
public static final int YBYTOP
pix_y
lies outside top line.
public static final int YBYORIGIN
pix_y
lies by origin.
Constructor Detail |
public JCNumberUtil()
Method Detail |
public static char getDecimalPointChar()
public static final double degToRad(double d)
d
- angle value in degrees
public static final double radToDeg(double r)
r
- angle value in radians
public static boolean validUnit(int unit)
DEGREES
, RADIANS
, or GRADS
.
unit
- enum representing an angle unit
true
if the unit enum is valid; false
otherwisepublic static double boundAngle(int unit, double angle)
unit
- unit for the angle valueangle
- angle value
public static double log10(double a)
a
- floating-point value
public static int intLog10(double a)
a
-
public static int nicePrecision(double range)
range
-
public static int tickBasedPrecision(double numsp)
numsp
-
public static double clamp(double x, double lo, double hi)
x
- value that requires clampinglo
- low value in the rangehi
- high value in the range
public static int clamp(int x, int lo, int hi)
x
- value that requires clampinglo
- low value in the rangehi
- high value in the range
public static long clamp(long x, long lo, long hi)
x
- value that requires clampinglo
- low value in the rangehi
- high value in the range
public static double precFloor(int prec, double value)
prec
- precision valuevalue
- value to truncate
public static double precCeil(int prec, double value)
prec
- precision valuevalue
- value to truncate
public static String logFormat(int exponent)
JCNumberUtil.format()
.
exponent
- exponent of log value
public static String format(double v, int ndigit)
sprintf(buffer, "%.*f", ndigit, v);
v
- value to formatndigit
- number of digits to appear in the formatted
String
public static String internalFormat(double v, int ndigit)
public static String convertFromSN(String s)
public static double convertAngle(int oldUnit, int newUnit, double angle)
DEGREES
, RADIANS
, or
GRADS
.
oldUnit
- unit of the provided angle valuenewUnit
- unit of the new angle valueangle
- angle value
public static double pow10(int x)
tens_val
).
x
- x in 10x
public static double precCorrect(int prec, double value)
prec
- requested precisionvalue
- number to be rounded
public static double max(double a, double b)
a
- first floating point valueb
- second floating point value
public static double min(double a, double b)
a
- first floating point valueb
- second floating point value
public static double abs(double a)
a
- floating point value
public static int abs(int a)
a
- floating point value
public static double fmod(double v1, double v2)
v1
- floating-point dividendv2
- floating-point divisor
public static void trace()
public static int distance(int x1, int y1, int x2, int y2)
x1
- first x pointy1
- first y pointx2
- second x pointy2
- second y point
public static int distance(int x, int y, Rectangle rect)
x
- x pointy
- y pointrect
- rectangle
public static int distance(int p, int start, int width)
p
- integer valuestart
- start point of rangewidth
- end point of range
public static long distTrap(int pix_x, int pix_y, int yorigin, double x1, double x2, double y1, double y2)
The trapezoid is defined by a top edge, two vertical sides, and a horizontal line at the origin of the y axis.
pix_x
- the x value of the pointpix_y
- the y value of the pointyorigin
- the origin of the y axisx1
- the x value of the first point that defines the
trapezoid's top edgex2
- the x value of the second point that defines the
trapezoid's top edgey1
- the y value of the first point that defines the
trapezoid's top edgey2
- the y value of the second point that defines the
trapezoid's top edge
public static Polygon pointsToPolygon(Point[] points)
Polygon
object.
points
- array of java.awt.Point
objects
public static Color brighter(Color color)
color
-
public static Color darker(Color color)
color
-
public static boolean colorsNear(Color c1, Color c2)
c1
- one color to checkc2
- the other color to check
true
if both colors are close; false
otherwise.public static int iceil(double val)
val
-
public static int ifloor(double val)
val
-
public static double calcError(int base)
base
-
public static int locateX(double x, double lx, double ux)
x
- the value to locatelx
- the lower bound to check againstux
- the upper bound to check against
public static int locateY(double y, double ly, double uy)
y
- the value to locately
- the lower bound to check againstuy
- the upper bound to check against
public static int locateXY(double x, double y, double lx, double ux, double ly, double uy)
x
- the x value of the point to locatey
- the y value of the point to locatelx
- the lower x bound to check againstux
- the upper x bound to check againstly
- the lower y bound to check againstuy
- the upper y bound to check against
public static boolean isHTML(String s)
javax.swing.plaf.basic.BasicHTML.isHTMLString()
. That call
cannot be used because the class isn't public, so it is repeated here.
For a String to be HTML-encoded, it needs to begin with "<html>".
s
- the String to check for HTML encoding.
true
if String is encoded in html; false
otherwisepublic static int countInString(String token, String target)
target
- token
-
public static void fudgeItalicLabel(Font font, Dimension dim)
dim
- font
-
|
Copyright © 2004 Quest Software Inc.. All rights reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |