Last Updated: 3/4/97
Class NFDataChart

Class NFDataChart

public abstract class NFDataChart extends NFGraph

The NFDataChart is used to provide axes and grids and generalized functions for most types of charts. It is the superclass of all charts that have axes (NFBarchart, NFXYChart, etc). This class may not be instantiated directly.

Instance Variables

Type Name Description Default
int MaxDataSets 50
NFAxis XValuesAxis a "pointer" to one of the above axes indicating which should be used for labels, etc.
NFAxis YValuesAxis a "pointer" to one of the above axes indicating which should be used for labels, etc.
Vector axes axes vector new Vector()
NFAxis bottomAxis
Graphics clipRect null
Vector dataSeries data series vector new Vector()
int defaultDepth 0
int depth graph depth 0
int depth3D 3D bar depth DEFAULT
int grid3D 3D grid depth DEFAULT
Vector grids grids vector new Vector()
NFAxis leftAxis
NFAxis rightAxis
NFAxis topAxis

Final Variables

Type Name Description
int BARSET Bar Data Set
int BOTH horiz and vertical
int BOTTOM Bottom Axis
int BOXSET Box Data Set
int DEFAULT Use default 3D depth
int GRID2D grid is 2D
int GRID3D grid is 3D
int HORIZONTAL horizontal
int LEFT Left Axis
int LINESET Line Data Set
int NONE no grid lines
int RIGHT Right Axis
int STOCKSET Stock Data Set
int TASKSET Task Data Set
int TOP Top Axis
int VERTICAL vertical

Constructors

Methods


NFDataChart (Applet a,
             int x,
             int y,
             int w,
             int h)
Constructor for NFDataChart class. Used for direct instantiations.

NFDataChart()
Default constructor for NFDataChart class.

protected void autoscaleAxis (NFAxis axis)
Autoscales the min, max and step values for the given axis, based on the min and max values for all datasets THAT ACTUALLY USE THE GIVEN AXIS FOR MAPPING.
This should be overridden by higher level charts to determine the appropriate scaling, given all the data set types.

protected void autoscaleAxis (NFAxis axis,
                              double minmax[])
Autoscales the min, max and step values for the given axis, based on the min and max values given in the array.

protected boolean clipLine (double x1,
                            double y1,
                            double x2,
                            double y2,
                            double xmin,
                            double xmax,
                            double ymin,
                            double ymax)
Returns true if the given line (x1,y1) to (x2,y2) is COMPLETELY outside the given region.

protected boolean clipPoint (double vx,
                             double vy,
                             double xmin,
                             double xmax,
                             double ymin,
                             double ymax)
Returns true if the given point (vx,vy) is outside the given region.

protected void defineDataAxisParams (NFParam param,
                                     String paramName)
Defines the parameters needed to specify an X & Y axis for each data set for a specific data type.

    protected void defineParams ()
This method extends the NFGraph.defineParams() method to define additional HTML parameters, namely:
 	BottomAxis	BottomLabels
 	LeftAxis	LeftLabels
 	TopAxis		TopLabels
 	RightAxis	RightLabels

protected void deleteAllDataSets ()
Deletes all data sets from all internal lists

protected void deleteAllDataSets (int type)
Deletes all data sets of the given type from all internal lists. The type may be one of BARSET, LINESET, STOCKSET, TASKSET, or BOXSET.

void displayAxes(Graphics g)
updates each of the axes in the axes list.

void displayGrids(Graphics g)
updates each of the grids in the grids list.

protected void drawArea (Graphics g,
                         NFDataSet dataset,
                         int dataOffset,
                         int size,
                         NFAxis XAxis,
                         NFAxis YAxis)
Draws the area graph for an area data series. The dataOffset and size parameters indicated how much of the dataset should be drawn. The XAxis and YAxis are the axes used when mapping X and Y values.

protected abstract void drawData (Graphics g);
This must be over-ridden by a sub-class in order to draw the data in the given graphics context.

protected void drawDataLite (Graphics g)
This must be over-ridden by a sub-class in order to draw the data in the given graphics context for an incremental update.

protected void drawGraph(Graphics g,
                         Rectangle r)
This method is called by the NFGraph object whenever an update or paint of the chart is requested. Graph components are drawn in the following order: Grids Data Axes
 	NoteSets

protected void drawGraphLite(Graphics g)
This is a lightweight method for updating the graph if ONLY the data has changed. If any of the axes or titles have changed, drawGraph should be called instead.

protected void drawPoints (Graphics g,
                           NFDataSeries ds)
Draws the points in a line/symbol/area data series. The NFDataSeries structure contains information on any possible line, graph symbol, or fill color.

protected void drawPoints (Graphics g,
                           NFDataSeries ds,
                           int dataOffset,
                           NFAxis XAxis,
                           NFAxis YAxis)
Draws the points in a line/symbol/area data series. The NFDataSeries structure contains information on any possible line, graph symbol, or fill color. "dataOffset" is used to advance into the data array and only plot the points requested. The XAxis and YAxis are the axes that are used when mapping X and Y values.

protected int get3DDepth (boolean estimate)
This should be over-ridden by a sub-class in order to account for the depth of a graph.

protected Point getBaseLine (NFAxis axis)
Returns a baseline pixel position along the given axis that is suitable for the base of a bar display.

protected int getDataSetSize (NFDataSeries ds)
Returns the number of data values in the given data set. This method should be overridden if the dataset structure is not used to stored data values.

int getMaxBars (NFAxis axis)
Get the max number of bars in all data sets that use the given axis as the XAxis

protected double[] getMinMax (NFAxis axis)
Determine the max/min values for all data sets that use the given axis. The min value is returned in the first array element, the max in the second.
This method calls getMinMax (NFDataSeries, NFAxis, double[]) to get the min/max values for a given data set

protected double[] getMinMax (NFDataSeries ds,
                              NFAxis axis,
                              double minmax[])
Updates the min/max values for the given data set, along the given axis. This method should be overridden by higher level objects to deal with different data set types.

protected void initChart()
initializes the left and bottom axes and creates a grid.

protected synchronized void loadParams () throws Exception
loads the NFDataChart parameters

boolean mouseDown (Event evt,
                   int x,
                   int y)
Overrides NFGraph mouseDown. Used to check axes for any scrollbar or zoom activity

boolean mouseDrag (Event evt,
                   int x,
                   int y)
Overrides NFGraph mouseDrag. Used to check axes for any scrollbar activity.

boolean mouseUp (Event evt,
                 int x,
                 int y)
Overrides NFGraph mouseUp. Used to check axes for any scrollbar activity

protected synchronized void setAxes (Graphics g,
                                     Rectangle r)
This method is called if the graph layout has changed such that axes position and size must be computed for proper placement in the graph window. The passed in Rectangle represents the total graph area less the headers, footers, left title, right title, and legend. This method also creates the clipRect graphics object which is used by data drawing routines to insure that data does not draw outside of the axes.

void setDefaultAxis (NFAxis axis)
Setup the given axis. If the autoscale flag is set, the determine the tic divisions based on the current min and max.
NOTE: When the user scrolls/zoom an axis, autoscaling is disabled and NFAxis is responsible for assigning appropriate tic spacing.

void setDefaultGrid()
Configures the data chart's default grid.