Last Updated: 3/4/97
Class NFAxis

Class NFAxis

public final class NFAxis

The NFAxis object provides tic marks and labels along a given axis from (x1,y1) to (x2,y2), mapping a range of values between (min, max).

Tic spacing is determined by designating a number of tics, the stepsize between tics (in terms of min & max), or by assigning a NFSpacing object. If none of these parameters are defined, tics will be automatically generated based on the (min,max) values and the physical size of the axis.

Labels can be automatically generated based on the (min,max) values (default) or can be defined by a Vector of Strings. The rendering of tic labels is controlled using a NFLabel object.

Final Variables

Type Name Description
int AlignBottom Label below tic
int AlignCenter Label centered on tic
int AlignLeft Label left of tic
int AlignRight Label right of tic
int AlignTop Label above tic
int DATE Numeric label format
int FLOAT Numeric label format
int INTEGER Integer label format
int TicBottom Tic below axis
int TicDefault Use default tic position
int TicLeft Tic left of axis
int TicRight Tic right of axis
int TicTop Tic above axis

Constructors

Methods


NFAxis(int x1,
       int y1,
       int dx,
       int dy)
Create a NFAxis object, using the given screen coordinates for the rendering location.

static NFAxis defaultAxis (String name)
Create a default NFAxis object based on the name given, which can be either Top, Bottom, Left or Right.

void changeTicLabels(Vector labels)
changes the current tic labels.

void clearTicLabels()
clears the tic labels

NFSpacing copyPoints (int XOffset,
                      int YOffset)
Copy all tic points (in screen coordinates) into a new NFSpacing object and adjust them by the given amount (in screen coordinates).

void display (Graphics g)
Display the axis in the given graphics context.

Dimension getBounds (Graphics g)
Returns the amount of screen space required to display the axis, including all labels and tics.

boolean getChanged()
Returns true if the axis has changed and needs to be repainted

String getLabel (Object val)
Returns a string label for the given value, which can be any of the following types:
 	NFDate
 	NFTimeUnit
 	Number
The label is based on the current axis format settings.

String getLabel (double val)
Returns a string label for the given value, based on the current axis format settings.

double getMax()
return axis max value

double getMin()
return axis min value

Point getNthPoint (int i)
Returns the Nth tic position in screen coordinates.

Rectangle getRect (Graphics g)
Returns the rectangle that the Axis occupies, including all labels and tics.

NFSpacing getSpacing ()
Returns the current ticSpacing for the axis, which may be null.

NFLabel getTicLabel()
Gets the tic label attribute

int getTicLength()
returns the length of the tics used for this axis.

int getTicPosition ()
Returns the current tic position for this axis.

double getValue (Object obj)
Returns a numeric value of the object given, which may be any of the following types:
 	NFDate
 	NFTimeUnit
 	Number

Point mapValue (Object obj)
Returns a screen position based on the current (min,max) setting and the value of the object given, which may be any of the following types:
 	NFDate
 	NFTimeUnit
 	Number

Point mapValue (double v)
Returns a screen position along the axis corresponding to the given value, which may be within (min,max) or not. If the value is outside (min,max), then the screen position will be outside of the bounds of the axis.

void setAxis(int x1,
             int y1,
             int dx,
             int dy)
Specifies the screen coordinates for the axis. This allows an application to move the axis around without affecting any rendering attributes.

void setAxisColor(Color c)
Set the axis color

void setMinMax(double min,
               double max)
sets axis minimum and maximum values

void setScroll (boolean onoff)
Set scrolling mode on (true) or off (false)

void setScrollLimits (Object min,
                      Object max)
Sets the absolute min and max values over which the axis can scroll, based on the given objects, which can be any of the following types:
 	NFDate
 	NFTimeUnit
 	Number

void setScrollLimits (double min,
                      double max)
Sets the absolute min and max values over which the axis can scroll.

void setSpacing (NFSpacing spacing)
Defines the tic spacing using a NFSpacing object. The values generated by the NFSpacing object should be in the range (min,max).

void setTicDivisions (Object min,
                      Object max,
                      Object ticStepSize)
Computes tic labels and position based on the axis min, max and stepsize, given as any of the following types:
 	NFDate
 	NFTimeUnit
 	Number

void setTicDivisions(double min,
                     double max,
                     double ticStepSize)
computes tic labels and position based on the axis min, max and stepsize.

void setTicDivisions(double min,
                     double max,
                     int numTics)
computes tic labels and position based on the axis min, max and number of tics.

void setTicLabel(NFLabel ticLabel)
sets label parameters to be used for each of the axis labels.

void setTicLabelAlignment(int ticLabelAlignment)
sets the tic label alignment

void setTicLabelType(int ticLabelType)
sets the tic label type

void setTicLabels(Vector labels)
sets up the axis to display tic labels.

void setTicLength(int ticLength)
changes the length of the axis tics.

void setTicPosition(int ticPosition)
sets the tic position

void setup()
This method should be called whenever the variables affecting tic generation are modified. It is automatically called before displaying the axis.

void showAxis(boolean showAxis)
toggles the axis or axis line display.

void showAxisAndLine(boolean showAxis,
                     boolean showAxisLine)
toggles the axis or axis line display.

void showAxisLine(boolean showAxisLine)
toggles the axis line display.

void showTicLabels(boolean showTicLabels)
toggles the tic label display.

void showTics(boolean showTics)
toggles the tics display.

void showTicsAndLabels(boolean showTics,
                       boolean showTicLabels)
toggles the tics or tic label display.