JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart3d
Class Anno

java.lang.Object
  |
  +--com.klg.jclass.chart3d.Anno
All Implemented Interfaces:
Serializable

public class Anno
extends Object
implements Serializable

Internal class for JClass Chart 3D. This class calculates the annotation extents and also draws the annotation

See Also:
Serialized Form

Field Summary
protected  com.klg.jclass.chart3d.JCChart3dArea area
          The parent JCChart3dArea object
protected  Matrix4d axisMatrix
          A matrix that is computed once per edge for a given axis and used for each label on the axis.
protected  Matrix4d compMatrix
          Used to compute the annotation orientation for an axis (vertical or horizontal) based on whether the horizontal or vertical component of the axis is dominant.
static double CUBE_SCALE
          Used to translate font measurements to "cube" space (absolute space)
protected  boolean doPicking
          If true, label picking is done instead of drawing
protected  Matrix4d edgeMatrix
          The edge matrix is responsible for translating the annotation to the proper edge of the cube.
protected  Matrix4d justifyMatrix
          The justify matrix positions the annotation so that it will not conflict with the tick-marks and is properly centered on the tick mark.
protected  Matrix4d matrix
          A general utility matrix
static int NUM_POINTS
          Number of points in internal u point list
static int NUM_VECTORS
          Number of vectors in internal v vector list
protected  Matrix4d orientationMatrix
          Calculates the orientation matrix.
protected  Point pickPoint
          Point used for label picking
protected  Matrix4d planeMatrixInit
          The plane matrix is used to help find the best annotation plane.
protected  com.klg.jclass.chart3d.JCValueLabel selectedLabel
          The label that the pickPoint falls in (null if no label picked)
static double TICK_PAD_FACTOR
          The amount of space between the tick and the annotation as a fraction of the annotation height
protected  Point4d[] u
          List of points used during calculations
protected  Vector3d[] v
          List of vector objects used during calculations
 
Constructor Summary
Anno()
          No args constructor.
Anno(com.klg.jclass.chart3d.JCChart3dArea area)
          Contstructor which sets the parent JCChart3dArea.
 
Method Summary
 boolean adjustDataport(Graphics gc, com.klg.jclass.chart3d.JCAxis axis, com.klg.jclass.chart3d.JCBox dataport, int startEdge, double scale, boolean tight, com.klg.jclass.chart3d.Justify justify, double axisMin, double axisMax)
          Adjust the dataport for a given axis for annotation only if one of the four edges are annotated.
protected  void annoInit()
          Resets often used matrices to null so that they don't contain any info that might have come from previous use.
protected  void bound3dAxis(Graphics gc, com.klg.jclass.chart3d.JCAxis axis, Matrix4d ctm, com.klg.jclass.chart3d.Extents extents, com.klg.jclass.chart3d.JCBox dataport)
          Finds the extents of the given axis modifying the viewport bounds and dataport bounds as required.
protected  void boundBox(Matrix4d ctm, double height, double width, com.klg.jclass.chart3d.Extents extents)
          Finds the extents of the bounding box determined by the given height and width after it is transformed.
protected  void boundText(Graphics gc, com.klg.jclass.chart3d.JCAxis axis, Matrix4d ctm, String text, double offset, com.klg.jclass.chart3d.Extents extents, com.klg.jclass.chart3d.Justify justify)
          Binds the given text relative to the cube based on the axis font
protected  void boundTitle(Graphics gc, com.klg.jclass.chart3d.JCAxis axis, Matrix4d ctm, String text, com.klg.jclass.chart3d.Extents extents, com.klg.jclass.chart3d.Justify justify)
          Binds the given title text relative to the cube based on the title font.
protected  void calc2dAnno(Graphics gc, com.klg.jclass.chart3d.JCBox viewport, com.klg.jclass.chart3d.JCBox dataport)
          Calculates the extents of the annotation for 2D projection plots.
protected  void calc3dAnno(Graphics gc, com.klg.jclass.chart3d.JCBox viewport, com.klg.jclass.chart3d.JCBox dataport)
          Calculates annotation extents for 3D plots (drawn with the Java 2D api).
protected  void calcAnno(Graphics gc, com.klg.jclass.chart3d.JCBox viewport, com.klg.jclass.chart3d.JCBox dataport)
          Caculates annotation extents for either the 2D or 3D plots (drawn with the Java 2D api).
protected  void calcAxisBounds(com.klg.jclass.chart3d.JCAxis axis, double fontSize, double windowSize, double scale, boolean tight, double min, double max)
          Calculates the tick increment and axis min.
protected  void cubeDrawString(Graphics gc, com.klg.jclass.chart3d.JCAxis axis, Matrix4d m, String text, Color foreground, boolean isTitle)
          Transforms and draws string on the cube.
 double cubeTextWidth(Graphics gc, com.klg.jclass.chart3d.JCAxis axis, String text, boolean isTitle, boolean haveAnno)
          Finds the text width relative to the cube size.
 void determineVertical(int edge, com.klg.jclass.chart3d.Justify justify)
          Do we draw annotation parallel to the axis (vertical == false) or orthogonal to it (vertical == true)
protected  void draw2dAnno(Graphics gc)
          Draws annotation for 2d projection plots
protected  void draw2dAxis(Graphics gc, com.klg.jclass.chart3d.JCAxis axis, Matrix4d ctm)
          In 2d mode, draws the annotation for a given axis.
 void draw3dAnno(Graphics gc)
          Draws annotation for 3d plots (drawn with the Java 2D api).
protected  void draw3dAxis(Graphics gc, com.klg.jclass.chart3d.JCAxis axis, Matrix4d ctm)
          In 3d mode, draws the annotation for a given axis.
protected  void drawAnnotation(Graphics gc, com.klg.jclass.chart3d.JCAxis axis, Matrix4d ctm, com.klg.jclass.chart3d.JCValueLabel vLabel, com.klg.jclass.chart3d.Justify justify, double height, double width)
          Given a string and a transformation matrix, draws the tick and/or annotation based on information in the passed in value label.
 void extendAxisDataport(Graphics gc, com.klg.jclass.chart3d.JCAxis axis, com.klg.jclass.chart3d.JCBox dataport, double scale, boolean tight, boolean vertical, double axisMin, double axisMax)
          If the annotation method is ANNOTATION_VALUES, the axis may need to get extended if the annotation overhangs the end of the axis.
protected  Point2d findAxisDxDy(int edge)
          Finds the delta in x and y for a given edge based on an axis.
protected  Point2d findEdgeDxDy(int edge)
          Returns the delta in x and y for a given edge (based on the current transformation).
protected  String formatAnno(double value, int nfrac)
          Given a value and an integer specifying the number of fractional digits to be used, returns a formatted string based on the value.
 com.klg.jclass.chart3d.JCChart3dArea getChart3dArea()
          Gets the parent chart3d area.
 Matrix4d getEdgeMatrix(int edge)
          Returns an edge matrix based on the given edge of the cube.
 Matrix4d getJustifyMatrix(double height, double width, com.klg.jclass.chart3d.Justify justify)
          This method creates a justify matrix which positions the annotation so that it will not conflict with the tick-marks, etc.
 Matrix4d getOrientationMatrix(int edge, com.klg.jclass.chart3d.Justify justify)
          Calculates the orientation matrix.
protected  double guessLongestAnnotation(Graphics gc, com.klg.jclass.chart3d.JCAxis axis)
          Since the min/max values are not necessarily representative of the intermediate annotations, we assume that the step size will introduce at least 1 extra digit of precision.
protected  void initializePoints()
          Initialize internal point array
protected  com.klg.jclass.chart3d.JCValueLabel pickLabel(Graphics gc, Point p)
          Check if a label has been selected by going thru the drawing mechanism
 void setChart3dArea(com.klg.jclass.chart3d.JCChart3dArea area)
          Sets the parent chart3d area.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TICK_PAD_FACTOR

public static final double TICK_PAD_FACTOR
The amount of space between the tick and the annotation as a fraction of the annotation height

See Also:
Constant Field Values

CUBE_SCALE

public static final double CUBE_SCALE
Used to translate font measurements to "cube" space (absolute space)

See Also:
Constant Field Values

NUM_POINTS

public static final int NUM_POINTS
Number of points in internal u point list

See Also:
Constant Field Values

NUM_VECTORS

public static final int NUM_VECTORS
Number of vectors in internal v vector list

See Also:
Constant Field Values

orientationMatrix

protected Matrix4d orientationMatrix
Calculates the orientation matrix. This matrix orients the annotation plane so that it faces the viewer most.


edgeMatrix

protected Matrix4d edgeMatrix
The edge matrix is responsible for translating the annotation to the proper edge of the cube.


justifyMatrix

protected Matrix4d justifyMatrix
The justify matrix positions the annotation so that it will not conflict with the tick-marks and is properly centered on the tick mark.


planeMatrixInit

protected Matrix4d planeMatrixInit
The plane matrix is used to help find the best annotation plane. The planeMatrixInit matrix is the same for each plane matrix and thus needs to only be computed once.


compMatrix

protected Matrix4d compMatrix
Used to compute the annotation orientation for an axis (vertical or horizontal) based on whether the horizontal or vertical component of the axis is dominant.


matrix

protected Matrix4d matrix
A general utility matrix


axisMatrix

protected Matrix4d axisMatrix
A matrix that is computed once per edge for a given axis and used for each label on the axis.


u

protected Point4d[] u
List of points used during calculations


v

protected Vector3d[] v
List of vector objects used during calculations


doPicking

protected boolean doPicking
If true, label picking is done instead of drawing


pickPoint

protected Point pickPoint
Point used for label picking


selectedLabel

protected com.klg.jclass.chart3d.JCValueLabel selectedLabel
The label that the pickPoint falls in (null if no label picked)


area

protected com.klg.jclass.chart3d.JCChart3dArea area
The parent JCChart3dArea object

Constructor Detail

Anno

public Anno()
No args constructor. The parent JCChart3dArea is null. The Anno object should not be used if its parent is null.


Anno

public Anno(com.klg.jclass.chart3d.JCChart3dArea area)
Contstructor which sets the parent JCChart3dArea.

Parameters:
area - The parent JCChart3dArea
Method Detail

getChart3dArea

public com.klg.jclass.chart3d.JCChart3dArea getChart3dArea()
Gets the parent chart3d area.

Returns:
The parent JCChart3dArea object

setChart3dArea

public void setChart3dArea(com.klg.jclass.chart3d.JCChart3dArea area)
Sets the parent chart3d area.

Parameters:
area - The new JCChart3dArea

initializePoints

protected void initializePoints()
Initialize internal point array


formatAnno

protected String formatAnno(double value,
                            int nfrac)
Given a value and an integer specifying the number of fractional digits to be used, returns a formatted string based on the value.

Parameters:
value - The value to be formatted
nfrac - The number of fractional digits
Returns:
The formatted string

getEdgeMatrix

public Matrix4d getEdgeMatrix(int edge)
Returns an edge matrix based on the given edge of the cube. This matrix is responsible for translating the annotation to the proper edge and rotating from the x-axis to the y or z axis (all annotation is assumed to start out on the x-axis).

Parameters:
edge - The edge of the cube for which the edge Matrix is being calculated
Returns:
The computed edge matrix. Note that this matrix is also stored in the edgeMatrix attribute of the current object.

findEdgeDxDy

protected Point2d findEdgeDxDy(int edge)
Returns the delta in x and y for a given edge (based on the current transformation).

Parameters:
edge - The edge of the cube for which the deltas are to be calculated
Returns:
Return the x and y deltas in a Point2d object.

findAxisDxDy

protected Point2d findAxisDxDy(int edge)
Finds the delta in x and y for a given edge based on an axis.

Parameters:
edge - The edge of the cube for which the deltas are to be calculated
Returns:
Return the x and y deltas in a Point2d object.

getOrientationMatrix

public Matrix4d getOrientationMatrix(int edge,
                                     com.klg.jclass.chart3d.Justify justify)
Calculates the orientation matrix. This matrix orients the annotation plane so that it faces the viewer most. This plane is identified by finding which of the unit axes has the largest magnitude Z component after the perspective, rotation, and edgeMatrix transformations have been applied. Also computes, whether to rotate the annotation, whether its above or below the axis, whether to flip the annotation in the Y direction, and whether to spin the axis title. All this is stored in the justify object.

Parameters:
edge - The edge of the cube for which the orientation plane needs to be calculated
justify - The justify object where information computed by this method is stored.
Returns:
The computed orientation matrix. Note that this matrix is also stored in the orientationMatrix attribute of the current object.

getJustifyMatrix

public Matrix4d getJustifyMatrix(double height,
                                 double width,
                                 com.klg.jclass.chart3d.Justify justify)
This method creates a justify matrix which positions the annotation so that it will not conflict with the tick-marks, etc. The annotation has a height and a width. This routine expects to be called from a frame-of-reference where y is positive downwards (ie. screen system). The origin of the annotation string is on the left side of the string and at the midpoint in height. ie. 0 <= x <= width; -height/2 <= y <= height/2; TICK_PAD_FACTOR is intended to specify the amount of space between the tick and the annotation as a fraction of the annotation height. Note that the tick size is half of the annotation height. The easeway variable returns the scalar distance from the axis to the maximum extent of the annotation string.

Parameters:
height - The annotation height
width - The annotation width
justify - The object which stores information like whether the annotation is rotated, the annotation is above the axis, and if the annotation is flipped in the y direction. It also stores the computed easeway.
Returns:
The computed justify matrix. Note that this matrix is also stored in the justifyMatrix attribute of the current object.

cubeTextWidth

public double cubeTextWidth(Graphics gc,
                            com.klg.jclass.chart3d.JCAxis axis,
                            String text,
                            boolean isTitle,
                            boolean haveAnno)
Finds the text width relative to the cube size.

Parameters:
gc - The graphics object to use for drawing and getting font info
axis - The axis the text is on
text - The text whose width is to be computed
isTitle - Is this text from an axis title?
haveAnno - Have the annotations already been computed for this axis?
Returns:
The text width

cubeDrawString

protected void cubeDrawString(Graphics gc,
                              com.klg.jclass.chart3d.JCAxis axis,
                              Matrix4d m,
                              String text,
                              Color foreground,
                              boolean isTitle)
Transforms and draws string on the cube.

Parameters:
gc - The graphics object to use for drawing and getting font info
axis - The axis with which this string is associated
m - The matrix with which to transform the shape determined by the string
text - The string to draw
isTitle - Are we drawing the title?

drawAnnotation

protected void drawAnnotation(Graphics gc,
                              com.klg.jclass.chart3d.JCAxis axis,
                              Matrix4d ctm,
                              com.klg.jclass.chart3d.JCValueLabel vLabel,
                              com.klg.jclass.chart3d.Justify justify,
                              double height,
                              double width)
Given a string and a transformation matrix, draws the tick and/or annotation based on information in the passed in value label. It uses the justify object to position the label. This same method is called during picking. Instead of drawing the annotation the code computes whether the pick point falls within the label's boundary.

Parameters:
gc - The graphics object to use for drawing and getting font info
axis - The axis for which the annotation is to be drawn
ctm - Current transformation matrix (used to position the annotation)
vLabel - The JCValueLabel object which stores the label, its background and foreground colors, and other info on how to draw the label
justify - Object which has information about label positioning
height - The height of the annotation
width - The width of the annotation

boundBox

protected void boundBox(Matrix4d ctm,
                        double height,
                        double width,
                        com.klg.jclass.chart3d.Extents extents)
Finds the extents of the bounding box determined by the given height and width after it is transformed.

Parameters:
ctm - The current transformation matrix
height - The height of the original "box"
width - The width of the original "box"
extents - The Extents object that stores the current viewport extents

boundText

protected void boundText(Graphics gc,
                         com.klg.jclass.chart3d.JCAxis axis,
                         Matrix4d ctm,
                         String text,
                         double offset,
                         com.klg.jclass.chart3d.Extents extents,
                         com.klg.jclass.chart3d.Justify justify)
Binds the given text relative to the cube based on the axis font

Parameters:
gc - The graphics object to use for drawing and getting font info
axis - The axis that the given text is associated with
ctm - The current transformation matrix
text - The text to bound
offset - The position offset along the axis for this text
extents - The Extents object that stores the current viewport extents
justify - Used to compute the justification matrix for this text

boundTitle

protected void boundTitle(Graphics gc,
                          com.klg.jclass.chart3d.JCAxis axis,
                          Matrix4d ctm,
                          String text,
                          com.klg.jclass.chart3d.Extents extents,
                          com.klg.jclass.chart3d.Justify justify)
Binds the given title text relative to the cube based on the title font.

Parameters:
gc - The graphics object to use for drawing and getting font info
axis - The axis associated with this title
ctm - The current transformation matrix
text - The text for this title
extents - The Extents object that stores the current viewport extents
justify - The Justify object that store whether to flip the title in the X or Y direction.

guessLongestAnnotation

protected double guessLongestAnnotation(Graphics gc,
                                        com.klg.jclass.chart3d.JCAxis axis)
Since the min/max values are not necessarily representative of the intermediate annotations, we assume that the step size will introduce at least 1 extra digit of precision. The spaces included in the format strings basically reserve space for 2 extra characters.

Parameters:
gc - The graphics object to use for drawing and getting font info
axis - The axis to which the annotation belongs.

calcAxisBounds

protected void calcAxisBounds(com.klg.jclass.chart3d.JCAxis axis,
                              double fontSize,
                              double windowSize,
                              double scale,
                              boolean tight,
                              double min,
                              double max)
Calculates the tick increment and axis min. and max., given the font size, window size and range of data.

Parameters:
axis - The axis to which this annotation belongs
fontSize - The font size (unit coord)
windowSize - The window size (unit coord) in approp. dimension
scale - A scale for determining how many annotations on an axis. The bigger the value the less annotations.
tight - We want tight bounds in the Z direction for bars
min - The min value for this axis
max - The max value for this axis

determineVertical

public void determineVertical(int edge,
                              com.klg.jclass.chart3d.Justify justify)
Do we draw annotation parallel to the axis (vertical == false) or orthogonal to it (vertical == true)

Parameters:
edge - The edge/axis for which the annotation orientation is to be determined
justify - Stores the results of orientation determination

extendAxisDataport

public void extendAxisDataport(Graphics gc,
                               com.klg.jclass.chart3d.JCAxis axis,
                               com.klg.jclass.chart3d.JCBox dataport,
                               double scale,
                               boolean tight,
                               boolean vertical,
                               double axisMin,
                               double axisMax)
If the annotation method is ANNOTATION_VALUES, the axis may need to get extended if the annotation overhangs the end of the axis. Adjust the dataport to reflect this.

Parameters:
gc - The graphics object to use for drawing and getting font info
axis - The axis whose dataport might be extend
dataport - The object which stores the current dataport extents
scale - The axis normalized scale
tight - We want tight bounds in the Z direction for bars
vertical - Is the annotation orientation vertical or horizontal?
axisMin - The axis min value
axisMax - The axis max value

adjustDataport

public boolean adjustDataport(Graphics gc,
                              com.klg.jclass.chart3d.JCAxis axis,
                              com.klg.jclass.chart3d.JCBox dataport,
                              int startEdge,
                              double scale,
                              boolean tight,
                              com.klg.jclass.chart3d.Justify justify,
                              double axisMin,
                              double axisMax)
Adjust the dataport for a given axis for annotation only if one of the four edges are annotated.

Parameters:
gc - The graphics object to use for drawing and getting font info
axis - The axis whose dataport might be adjusted
dataport - The object which stores the current dataport extents
startEdge - The starting edge for this axis
scale - The axis normalized scale
tight - We want tight bounds in the Z direction for bars
justify - Justify object that has the anno orientation information we need
axisMin - The axis min value
axisMax - The axis max value

bound3dAxis

protected void bound3dAxis(Graphics gc,
                           com.klg.jclass.chart3d.JCAxis axis,
                           Matrix4d ctm,
                           com.klg.jclass.chart3d.Extents extents,
                           com.klg.jclass.chart3d.JCBox dataport)
Finds the extents of the given axis modifying the viewport bounds and dataport bounds as required.

Parameters:
gc - The graphics object to use for drawing and getting font info
axis - The axis to be bounded
ctm - The current transformation matrix
extents - The current viewport extents
dataport - The current cube dataport

draw3dAxis

protected void draw3dAxis(Graphics gc,
                          com.klg.jclass.chart3d.JCAxis axis,
                          Matrix4d ctm)
In 3d mode, draws the annotation for a given axis. The internal value labels, generated earlier, stores the annotation.

Parameters:
gc - The graphics object to use for drawing and getting font info
axis - The axis to be drawn
ctm - The current transformation matrix

draw2dAxis

protected void draw2dAxis(Graphics gc,
                          com.klg.jclass.chart3d.JCAxis axis,
                          Matrix4d ctm)
In 2d mode, draws the annotation for a given axis. The internal value labels, generated earlier, stores the annotation.

Parameters:
gc - The graphics object to use for drawing and getting font info
axis - The axis to be drawn
ctm - The current transformation matrix

annoInit

protected void annoInit()
Resets often used matrices to null so that they don't contain any info that might have come from previous use.


calcAnno

protected void calcAnno(Graphics gc,
                        com.klg.jclass.chart3d.JCBox viewport,
                        com.klg.jclass.chart3d.JCBox dataport)
Caculates annotation extents for either the 2D or 3D plots (drawn with the Java 2D api).

Parameters:
gc - The graphics object to use for drawing and getting font info
viewport - The rectangular viewport into which the graph is to be drawn
dataport - The cube's data extents

calc3dAnno

protected void calc3dAnno(Graphics gc,
                          com.klg.jclass.chart3d.JCBox viewport,
                          com.klg.jclass.chart3d.JCBox dataport)
Calculates annotation extents for 3D plots (drawn with the Java 2D api).

Parameters:
gc - The graphics object to use for drawing and getting font info
viewport - The rectangular viewport into which the graph is to be drawn
dataport - The cube's data extents

draw3dAnno

public void draw3dAnno(Graphics gc)
Draws annotation for 3d plots (drawn with the Java 2D api).

Parameters:
gc - The graphics object to use for drawing and getting font info

calc2dAnno

protected void calc2dAnno(Graphics gc,
                          com.klg.jclass.chart3d.JCBox viewport,
                          com.klg.jclass.chart3d.JCBox dataport)
Calculates the extents of the annotation for 2D projection plots.

Parameters:
gc - The graphics object to use for drawing and getting font info
viewport - The rectangular viewport into which the graph is to be drawn
dataport - The cube's data extents

draw2dAnno

protected void draw2dAnno(Graphics gc)
Draws annotation for 2d projection plots

Parameters:
gc - The graphics object to use for drawing and getting font info

pickLabel

protected com.klg.jclass.chart3d.JCValueLabel pickLabel(Graphics gc,
                                                        Point p)
Check if a label has been selected by going thru the drawing mechanism

Parameters:
p - The point to check against the labels
Returns:
The selected label (null if none was selected)

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