JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart3d
Class JCChart3dUtil

java.lang.Object
  |
  +--com.klg.jclass.util.JCNumberUtil
        |
        +--com.klg.jclass.chart3d.JCChart3dUtil

public class JCChart3dUtil
extends JCNumberUtil

JCChartUtil is a collection of static methods and static variables that are used throughout JClass Chart 3D.


Field Summary
static double roundOffEpsilon
          Value to add to values to combat round off error.
 
Fields inherited from class com.klg.jclass.util.JCNumberUtil
DECIMAL, DEFAULT_FLOAT, DEGREES, GRADS, LOG_TEN_BASE_E, M_2PI, M_PI, M_PI_2, M_SQRT2, RADIANS, XBYX1, XBYX2, XINSIDE, YBYORIGIN, YBYTOP, YINSIDE
 
Constructor Summary
JCChart3dUtil()
           
 
Method Summary
static boolean backfacing(int[] xPoints, int[] yPoints)
          Determines if the convex polygon is backfacing.
static double biLinearInterp(com.klg.jclass.chart3d.Chart3dGridData data, int xIndex, int yIndex, double x, double y)
          Performs bi-linear interpolation within a grid facet to return the z value.
static void booleanfill(boolean[] array, boolean value)
          Uses the system method arraycopy to copy over larger blocks of values to fill a boolean array efficiently.
static double ceil(double value)
          Returns the ceiling of this value.
static Rectangle computeBoundingRectangle(Rectangle r1, Rectangle r2)
          Computes the bounding rectangle for two Rectangles.
static Point4d[] constructBarPlane(com.klg.jclass.chart3d.Chart3dGridData data, int x, int y)
          Calculates the x/y extents of the bar (in data space) constuct a flat plane of these values.
static double distanceToEye(com.klg.jclass.chart3d.JCChart3d chart3d, double x, double y, double z)
          Finds the distance of the point (x, y, z) to the eye position.
static double floor(double value)
          Returns the floor of this value.
static void getScreenPoint(com.klg.jclass.chart3d.JCChart3d chart3d, double x, double y, double z, double zAlternate, com.klg.jclass.chart3d.ScreenPoint screenPoint)
          Transforms the point (x, y, z) based on the current transformation defined in the chart.
static boolean gridBackfacing(com.klg.jclass.chart3d.ScreenPoint p1, com.klg.jclass.chart3d.ScreenPoint p2, com.klg.jclass.chart3d.ScreenPoint p3)
          Computes whether the plane defined by the three screen points is backfacing.
static boolean holeInFacet(com.klg.jclass.chart3d.Chart3dGridData data, int x, int y)
          Is there a hole in the facet with bottom-left corner (x, y)? There is a hole if any of the four corners (x,y), (x,y+1), (x+1, y), (x+1,y+1), have a z value which is the hole value.
static int max4(int a, int b, int c, int d)
          Finds the max of the four given integers.
static int min4(int a, int b, int c, int d)
          Finds the min of the four given integers.
static int nDigits(double value)
          Returns the number of decimal places after the decimal point the significant digit occurs.
static double niceNum(double x, boolean round)
          The following two routines implement Heckbert's algorithm for finding 'nice' numbers for labelling graphs (see Graphics Gems, "Nice Numbers for Graph Labels" by Paul Heckbert).
protected static void printAxisExtents(com.klg.jclass.chart3d.JCAxis axis)
          Prints the min/max, the anno min/max, and the dataport min/max for a given axis.
static void printMatrix(Matrix4d m)
          Utility debugging function that prints a given 4D matrix.
 
Methods inherited from class com.klg.jclass.util.JCNumberUtil
abs, abs, boundAngle, brighter, calcError, clamp, clamp, clamp, colorsNear, convertAngle, convertFromSN, countInString, darker, degToRad, distance, distance, distance, distTrap, fmod, format, fudgeItalicLabel, getDecimalPointChar, iceil, ifloor, internalFormat, intLog10, isHTML, locateX, locateXY, locateY, log10, logFormat, max, min, nicePrecision, pointsToPolygon, pow10, precCeil, precCorrect, precFloor, radToDeg, tickBasedPrecision, trace, validUnit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

roundOffEpsilon

public static final double roundOffEpsilon
Value to add to values to combat round off error.

See Also:
Constant Field Values
Constructor Detail

JCChart3dUtil

public JCChart3dUtil()
Method Detail

backfacing

public static boolean backfacing(int[] xPoints,
                                 int[] yPoints)
Determines if the convex polygon is backfacing.

Parameters:
xPoints - the xPoints array of the polygon
yPoints - the yPoints array of the polygon
Returns:

gridBackfacing

public static boolean gridBackfacing(com.klg.jclass.chart3d.ScreenPoint p1,
                                     com.klg.jclass.chart3d.ScreenPoint p2,
                                     com.klg.jclass.chart3d.ScreenPoint p3)
Computes whether the plane defined by the three screen points is backfacing.

Parameters:
p1 - the first point
p2 - the second point
p3 - the third point
Returns:

getScreenPoint

public static void getScreenPoint(com.klg.jclass.chart3d.JCChart3d chart3d,
                                  double x,
                                  double y,
                                  double z,
                                  double zAlternate,
                                  com.klg.jclass.chart3d.ScreenPoint screenPoint)
Transforms the point (x, y, z) based on the current transformation defined in the chart. Stores the result in the screen point.
If the z value is a hole, use the zAlternate value to do the tranformation.

Parameters:
chart3d - the chart which has the transformation
x - the x coordinate of the point
y - the y coordinate of the point
z - the z coordinate of the point
zAlternate - the alternate z value to use if a hole is encountered
screenPoint - the screen point to store the transformed value

distanceToEye

public static double distanceToEye(com.klg.jclass.chart3d.JCChart3d chart3d,
                                   double x,
                                   double y,
                                   double z)
Finds the distance of the point (x, y, z) to the eye position.
Note: The eye position is in absolute space and first needs to be tranformed to graph coordinates.

Parameters:
chart3d - the chart for which the distance to eye is needed
x - the x coordinate of the point
y - the y coordinate of the point
z - the z coordinate of the point
Returns:

printMatrix

public static void printMatrix(Matrix4d m)
Utility debugging function that prints a given 4D matrix.

Parameters:
m - the matrix to be printed

printAxisExtents

protected static void printAxisExtents(com.klg.jclass.chart3d.JCAxis axis)
Prints the min/max, the anno min/max, and the dataport min/max for a given axis.

Parameters:
axis - the axis for which the extents are to be printed

booleanfill

public static void booleanfill(boolean[] array,
                               boolean value)
Uses the system method arraycopy to copy over larger blocks of values to fill a boolean array efficiently.

Parameters:
array - the array to fill
value - the value with which to fill it

min4

public static int min4(int a,
                       int b,
                       int c,
                       int d)
Finds the min of the four given integers.

Parameters:
a - the first integer
b - the second integer
c - the third integer
d - the fourth integer
Returns:

max4

public static int max4(int a,
                       int b,
                       int c,
                       int d)
Finds the max of the four given integers.

Parameters:
a - the first integer
b - the second integer
c - the third integer
d - the fourth integer
Returns:

floor

public static double floor(double value)
Returns the floor of this value. Math library function floor does most of the work, but we add roundOffEpsilon to it to combat round off near integers.

Parameters:
value - the value for which to find the floor
Returns:

ceil

public static double ceil(double value)
Returns the ceiling of this value. Math library function ceil does most of the work, but we subtract roundOffEpsilon from it to combat round off near integers.

Parameters:
value - the value for which to find the ceil
Returns:

nDigits

public static int nDigits(double value)
Returns the number of decimal places after the decimal point the significant digit occurs. Negative numbers mean powers of 10. Watch out for zero (return Integer.MAX_VALUE/2), because we could use anything we want that would not easily cause an overflow later on.

Parameters:
value - the value for which to find the significant digits
Returns:

niceNum

public static double niceNum(double x,
                             boolean round)
The following two routines implement Heckbert's algorithm for finding 'nice' numbers for labelling graphs (see Graphics Gems, "Nice Numbers for Graph Labels" by Paul Heckbert). It has been implemented more or less directly.

Parameters:
x - the number for which a nice number is needed
round - if true, do rounding
Returns:

constructBarPlane

public static Point4d[] constructBarPlane(com.klg.jclass.chart3d.Chart3dGridData data,
                                          int x,
                                          int y)
Calculates the x/y extents of the bar (in data space) constuct a flat plane of these values. This means that the z value is arbitrary and should be set elsewhere.

Parameters:
data - the internal grid data source
x - the x grid coordinate
y - the y grid coordinate
Returns:

holeInFacet

public static boolean holeInFacet(com.klg.jclass.chart3d.Chart3dGridData data,
                                  int x,
                                  int y)
Is there a hole in the facet with bottom-left corner (x, y)? There is a hole if any of the four corners (x,y), (x,y+1), (x+1, y), (x+1,y+1), have a z value which is the hole value.

Parameters:
data - the grid data source
x - the x coordinate of the bottom left corner
y - the y coordinate of the bottom left corner
Returns:

biLinearInterp

public static double biLinearInterp(com.klg.jclass.chart3d.Chart3dGridData data,
                                    int xIndex,
                                    int yIndex,
                                    double x,
                                    double y)
Performs bi-linear interpolation within a grid facet to return the z value.

Parameters:
data - the internal grid data object
xIndex - the index of the x grid value for this facet
yIndex - the index of the y grid value for this facet
x - the x location in data space
y - the y location in data space
Returns:
the interpolated z value for the given (x, y)

computeBoundingRectangle

public static Rectangle computeBoundingRectangle(Rectangle r1,
                                                 Rectangle r2)
Computes the bounding rectangle for two Rectangles. Needed because Rectangle.union does not work for rectangles whose position has negative values.

Parameters:
r1 - the first rectangle
r2 - the second rectangle
Returns:
the bounding rectangle

Copyright © 2004 Quest Software Inc..
All rights reserved.