Class graph.DataSet
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class graph.DataSet

java.lang.Object
   |
   +----graph.DataSet

public class DataSet
extends Object
This class is designed to hold the data to be plotted. It is to be used in conjunction with the Graph2D class and Axis class for plotting 2D graphs.
Version:
$Revision: 1.12 $, $Date: 1996/07/05 07:29:46 $
Author:
Leigh Brookshaw

Variable Index

 o data
The array containing the actual data
 o dxmax
The data X maximum.
 o dxmin
The data X minimum.
 o dymax
The data Y maximum.
 o dymin
The data Y minimum.
 o g2d
The Graphics canvas that is driving the whole show.
 o increment
The amount to increment the data array when the append method is being used.
 o legend_dx
The X data position of the data legend
 o legend_dy
The Y data position of the data legend
 o legend_ix
The X pixel position of the data legend
 o legend_iy
The Y pixel position of the data legend
 o legend_length
The length of the example line in the data legend.
 o legend_text
The legend text
 o length
The number of data points stored in the data array
 o LINE
A constant value flag used to specify that a straight line segment is to join the data points.
 o linecolor
The color of the straight line segments
 o linestyle
The linestyle to employ when joining the data points with straight line segments.
 o marker
The index of the marker to use at the data points.
 o markercolor
The marker color
 o markerscale
The scaling factor for the marker.
 o NOLINE
A constant value flag used to specify no straight line segment is to join the data points
 o xaxis
The Axis object the X data is attached to.
 o xmax
The current plottable X maximum of the data.
 o xmin
The current plottable X minimum of the data.
 o xrange
The X range of the clipped data
 o yaxis
The Axis object the Y data is attached to.
 o ymax
The current plottable Y maximum of the data.
 o ymin
The current plottable Y minimum of the data.
 o yrange
The Y range of the clipped data

Constructor Index

 o DataSet()
Instantiate an empty data set.
 o DataSet(double[], int)
Instantiate a DataSet with the parsed data.

Method Index

 o append(double[], int)
Append data to the data set.
 o dataPoints()
Return the number of data points in the DataSet
 o delete(int, int)
Delete data from the data set (start and end are inclusive).
 o deleteData()
Delete all the data from the data set.
 o draw_data(Graphics, Rectangle)
Draw the straight line segments and/or the markers at the data points.
 o draw_legend(Graphics, Rectangle)
Draw a legend for this data set
 o draw_lines(Graphics, Rectangle)
Draw into the data window the straight line segments joining the data points.
 o draw_markers(Graphics, Rectangle)
Draw the markers.
 o getClosestPoint(double, double)
Return the data point that is closest to the parsed (x,y) position
 o getPoint(int)
get the data point at the parsed index.
 o getXmax()
return the data X maximum.
 o getXmin()
return the data X minimum.
 o getYmax()
return the data Y maximum.
 o getYmin()
return the data Y minimum.
 o inside(double, double)
Return true if the point (x,y) is inside the allowed data range.
 o legend(double, double, String)
Define a data legend in the graph window
 o legend(int, int, String)
Define a data legend in the graph window
 o legendColor(Color)
Set the color for the legend text
 o legendFont(Font)
Set the font to be used in the legend
 o range()
Calculate the range of the data.

Variables

 o NOLINE
  public final static int NOLINE
A constant value flag used to specify no straight line segment is to join the data points
 o LINE
  public final static int LINE
A constant value flag used to specify that a straight line segment is to join the data points.
 o g2d
  public Graph2D g2d
The Graphics canvas that is driving the whole show.
See Also:
Graph2D
 o linestyle
  public int linestyle
The linestyle to employ when joining the data points with straight line segments. Currently only solid and no line are supported.
 o linecolor
  public Color linecolor
The color of the straight line segments
 o marker
  public int marker
The index of the marker to use at the data points.
See Also:
Markers
 o markercolor
  public Color markercolor
The marker color
 o markerscale
  public double markerscale
The scaling factor for the marker. Default value is 1.
 o xaxis
  public Axis xaxis
The Axis object the X data is attached to. From the Axis object the scaling for the data can be derived.
See Also:
Axis
 o yaxis
  public Axis yaxis
The Axis object the Y data is attached to.
See Also:
Axis
 o xmax
  public double xmax
The current plottable X maximum of the data. This can be very different from true data X maximum. The data is clipped when plotted.
 o xmin
  public double xmin
The current plottable X minimum of the data. This can be very different from true data X minimum. The data is clipped when plotted.
 o ymax
  public double ymax
The current plottable Y maximum of the data. This can be very different from true data Y maximum. The data is clipped when plotted.
 o ymin
  public double ymin
The current plottable Y minimum of the data. This can be very different from true data Y minimum. The data is clipped when plotted.
 o dxmax
  protected double dxmax
The data X maximum. Once the data is loaded this will never change.
 o dxmin
  protected double dxmin
The data X minimum. Once the data is loaded this will never change.
 o dymax
  protected double dymax
The data Y maximum. Once the data is loaded this will never change.
 o dymin
  protected double dymin
The data Y minimum. Once the data is loaded this will never change.
 o data
  protected double data[]
The array containing the actual data
 o length
  protected int length
The number of data points stored in the data array
 o xrange
  protected double xrange
The X range of the clipped data
 o yrange
  protected double yrange
The Y range of the clipped data
 o legend_length
  protected int legend_length
The length of the example line in the data legend.
 o legend_text
  protected TextLine legend_text
The legend text
 o legend_ix
  protected int legend_ix
The X pixel position of the data legend
 o legend_iy
  protected int legend_iy
The Y pixel position of the data legend
 o legend_dx
  protected double legend_dx
The X data position of the data legend
 o legend_dy
  protected double legend_dy
The Y data position of the data legend
 o increment
  protected int increment
The amount to increment the data array when the append method is being used.

Constructors

 o DataSet
  public DataSet()
Instantiate an empty data set.
 o DataSet
  public DataSet(double d[],
                 int n) throws Exception
Instantiate a DataSet with the parsed data. The double array contains the data. The X data is expected in the even indices, the y data in the odd. The integer n is the number of data Points. This means that the length of the data array is 2*n.
Parameters:
d - Array containing the (x,y) data pairs.
n - Number of (x,y) data pairs in the array.
Throws: Exception
A Generic exception if it fails to load the parsed array into the class.

Methods

 o append
  public void append(double d[],
                     int n) throws Exception
Append data to the data set.
Parameters:
d - Array containing (x,y) pairs to append
n - Number of (x,y) data pairs in the array.
Throws: Exception
A generic exception if it fails to load the parsed array into the class.
 o delete
  public void delete(int start,
                     int end)
Delete data from the data set (start and end are inclusive). The first (x,y) pair in the data set start at index 0.
Parameters:
start - The start (x,y) pair index.
end - The end (x,y) pair index.
 o deleteData
  public void deleteData()
Delete all the data from the data set.
 o draw_data
  public void draw_data(Graphics g,
                        Rectangle bounds)
Draw the straight line segments and/or the markers at the data points. If this data has been attached to an Axis then scale the data based on the axis maximum/minimum otherwise scale using the data's maximum/minimum
Parameters:
g - Graphics state
bounds - The data window to draw into
 o getXmax
  public double getXmax()
return the data X maximum.
 o getXmin
  public double getXmin()
return the data X minimum.
 o getYmax
  public double getYmax()
return the data Y maximum.
 o getYmin
  public double getYmin()
return the data Y minimum.
 o legend
  public void legend(int x,
                     int y,
                     String text)
Define a data legend in the graph window
Parameters:
x - pixel position of the legend.
y - pixel position of the legend.
text - text to display in the legend
 o legend
  public void legend(double x,
                     double y,
                     String text)
Define a data legend in the graph window
Parameters:
x - data position of the legend.
y - data position of the legend.
text - text to display in the legend
 o legendFont
  public void legendFont(Font f)
Set the font to be used in the legend
Parameters:
f - font
 o legendColor
  public void legendColor(Color c)
Set the color for the legend text
Parameters:
c - color
 o dataPoints
  public int dataPoints()
Return the number of data points in the DataSet
Returns:
number of (x,y0 points.
 o getPoint
  public double[] getPoint(int index)
get the data point at the parsed index. The first (x,y) pair is at index 0.
Parameters:
index - Data point index
Returns:
array containing the (x,y) pair.
 o getClosestPoint
  public double[] getClosestPoint(double x,
                                  double y)
Return the data point that is closest to the parsed (x,y) position
Parameters:
y - (x,y) position in data space.
Returns:
array containing the closest data point.
 o draw_lines
  protected void draw_lines(Graphics g,
                            Rectangle w)
Draw into the data window the straight line segments joining the data points.
Parameters:
g - Graphics context
w - Data window
 o inside
  protected boolean inside(double x,
                           double y)
Return true if the point (x,y) is inside the allowed data range.
 o draw_markers
  protected void draw_markers(Graphics g,
                              Rectangle w)
Draw the markers. Only markers inside the specified range will be drawn. Also markers close the edge of the clipping region will be clipped.
Parameters:
g - Graphics context
w - data window
See Also:
Markers
 o draw_legend
  protected void draw_legend(Graphics g,
                             Rectangle w)
Draw a legend for this data set
Parameters:
g - Graphics context
w - Data Window
 o range
  protected void range()
Calculate the range of the data. This modifies dxmin,dxmax,dymin,dymax and xmin,xmax,ymin,ymax

All Packages  Class Hierarchy  This Package  Previous  Next  Index