Last Updated: 3/4/97
Class NFGraph

Class NFGraph

public class NFGraph extends Panel implements Observer

The NFGraph class is an generic class used for different kinds of data graphs. It must be sub-classed in order to generate a graph.

Instance Variables

Type Name Description Default
private NFRegion background
Applet a the associated Applet
NFActiveRegion dwell If non-null, handles dwell label displaying null
int dwellOffset pixels around a dwell point. 20
boolean dwellOn used to determine if default dwell parameters should be generated. false
boolean graphChanged Set true when the graph has changed and needs to be displayed false
boolean incrementalUpdate Set true when the only the last point should be drawn false
boolean layoutChanged used internally to determine if certain graph items need to be recalculated false
NFLegend legend Legend object new NFLegend()
boolean legendChanged Set true when the legend has changed and needs to be displayed false
boolean legendDisplayed set to true if a legend was actually displayed false
NFParam param Used for parameter parsing null

Methods


Color defaultColor (int i)
Get a default color for the given index

protected void defineParams ()
Defines all HTML parameters supported by NFGraph. This method may be overridden by subclasses to define additional parameters. In such cases, this method should be executed first.

protected void display (Graphics g)
Display all graph parts, calling sub-class methods as necessary.

protected void display (boolean forceGraph)
If <forceGraph> is true, force a redraw of the graph. Otherwise, the saved image is redisplayed.

protected void display()
Display all graph parts, calling sub-class methods as necessary.

protected void drawGraph (Graphics g,
                          Rectangle r)
This method must be overridden by sub-classes in order to display data sets. It is called by the display() method after all headers, titles and legends have been displayed.
The data displayed should be contained within the given rectangle, in the given graphics context, in order to prevent any overwriting of other graph elements.

protected void drawGraphLite (Graphics g)
This method must be overridden by sub-classes in order to display data sets. It is called by the display() method after all headers, titles and legends have been displayed.
This drawGraph routine indicates only the last point should be drawn and no grids or axes need be updated.

NFParam getParam()
Returns the graphs parameter structure.

void initGraph (Applet a)
Initialize the NFGraph object

protected synchronized void loadParams () throws Exception
Loads all HTML parameters supported by NFGraph. This method may be overridden by subclasses to load additional parameters. In such cases, this method should be executed first.

synchronized final void loadParams (Applet app) throws Exception
Loads applet parameters from the HTML file that invoked the applet. This method may not be overridden by sub-classes.

synchronized final void loadParams (String expr) throws Exception
Loads application parameters defined by the given parameter expression. This method may not be overridden by sub-classes.

synchronized final void loadParams (String hostname,
                                    int port,
                                    String args) throws Exception
Loads application parameters from the NFParamServer designated by the <host> and <port> arguments. When connected, the <args> string will be sent to the server, followed by a newline. All parameters generated by the server will be parsed by a background thread. See NFParam for further details about NFParamServer processing.

synchronized final void loadParams (URL url) throws Exception
Loads application parameters defined by a URL. This method may not be overridden by sub-classes. See NFUtil.getFileURL() for a convenient method for getting a URL for a local disk file.

boolean mouseDown (Event evt,
                   int x,
                   int y)
Keeps track of mouse movement over the graph

boolean mouseMove (Event evt,
                   int x,
                   int y)
Keeps track of mouse movement over the graph

void paint(Graphics g)
handle the paint

protected void reset()
The reset method may be overridden in order to provide a routine that computes display parameters without actually displaying the data.

void setBackground (NFRegion region)
Set the graph background. By default, no background is displayed.

void setFooter (NFLabel footer)
Set the graph footer. By default, no footer is displayed.

void setHeader (NFLabel header)
Set the graph header. By default, no header is displayed.

void setLeftTitle (NFLabel title)
Set the graph left title. By default, no left title is displayed.

void setRightTitle (NFLabel title)
Set the graph right title. By default, no right title is displayed.