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:
- LB1.15 modified MCC 3/19/97
- Author:
- Leigh Brookshaw, modified by Michael Cross
-
clipping
- Boolean to control clipping of the data window.
-
data
- The array containing the actual data
-
dxmax
- The data X maximum.
-
dxmin
- The data X minimum.
-
dymax
- The data Y maximum.
-
dymin
- The data Y minimum.
-
g2d
-
The Graphics canvas that is driving the whole show.
-
increment
- The amount to increment the data array when the append method is being
used.
-
legend_dx
- The X data position of the data legend
-
legend_dy
- The Y data position of the data legend
-
legend_ix
- The X pixel position of the data legend
-
legend_iy
- The Y pixel position of the data legend
-
legend_length
- The length of the example line in the data legend.
-
legend_text
- The legend text
-
length
- The number of data points stored in the data array
-
LINE
- A constant value flag used to specify that a straight line segment
is to join the data points.
-
linecolor
- The color of the straight line segments
-
linestyle
- The linestyle to employ when joining the data points with
straight line segments.
-
marker
- The index of the marker to use at the data points.
-
markercolor
- The marker color
-
markerscale
- The scaling factor for the marker.
-
NOLINE
- A constant value flag used to specify no straight line segment
is to join the data points
-
previousPointLines
-
-
previousPointMarkers
-
-
stride
- The stride of the data.
-
xaxis
- The Axis object the X data is attached to.
-
xmax
- The current plottable X maximum of the data.
-
xmin
- The current plottable X minimum of the data.
-
xrange
- The X range of the clipped data
-
yaxis
- The Axis object the Y data is attached to.
-
ymax
- The current plottable Y maximum of the data.
-
ymin
- The current plottable Y minimum of the data.
-
yrange
- The Y range of the clipped data
-
DataSet()
- Instantiate an empty data set.
-
DataSet(double[], int)
- Instantiate a DataSet with the parsed data.
-
DataSet(double[], int, int)
- Instantiate a DataSet with the parsed data.
-
DataSet(int)
- Instantiate an empty data set.
-
append(double[], int)
- Append data to the data set.
-
appendPoint(double, double)
- Append single data point to the data set.
-
dataPoints()
- Return the number of data points in the DataSet
-
delete(int, int)
- Delete data from the data set (start and end are inclusive).
-
deleteData()
- Delete all the data from the data set.
-
draw_data(Graphics, Rectangle)
- Draw the straight line segments and/or the markers at the
data points.
-
draw_legend(Graphics, Rectangle)
- Draw a legend for this data set
-
draw_lines(Graphics, Rectangle)
- Draw into the data window the straight line segments joining the
data points.
-
draw_markers(Graphics, Rectangle)
- Draw the markers.
-
getClosestPoint(double, double)
- Return the data point that is closest to the parsed (x,y) position
-
getPoint(int)
- get the data point at the parsed index.
-
getXmax()
- return the data X maximum.
-
getXmin()
- return the data X minimum.
-
getYmax()
- return the data Y maximum.
-
getYmin()
- return the data Y minimum.
-
inside(double, double)
- Return true if the point (x,y) is inside the allowed data range.
-
legend(double, double, String)
- Define a data legend in the graph window
-
legend(int, int, String)
- Define a data legend in the graph window
-
legendColor(Color)
- Set the color for the legend text
-
legendFont(Font)
- Set the font to be used in the legend
-
plotAllPoints()
- Put previousPoints to -1 so all points are plotted
-
range(int)
- Calculate the range of the data.
NOLINE
public static final int NOLINE
- A constant value flag used to specify no straight line segment
is to join the data points
LINE
public static final int LINE
- A constant value flag used to specify that a straight line segment
is to join the data points.
g2d
public Graph2D g2d
- The Graphics canvas that is driving the whole show.
- See Also:
- Graph2D
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.
linecolor
public Color linecolor
- The color of the straight line segments
marker
public int marker
- The index of the marker to use at the data points.
- See Also:
- Markers
markercolor
public Color markercolor
- The marker color
markerscale
public double markerscale
- The scaling factor for the marker. Default value is 1.
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
yaxis
public Axis yaxis
- The Axis object the Y data is attached to.
- See Also:
- Axis
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.
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.
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.
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.
clipping
public boolean clipping
- Boolean to control clipping of the data window.
Default value is true, clip the data window.
dxmax
protected double dxmax
- The data X maximum.
Once the data is loaded this will never change.
dxmin
protected double dxmin
- The data X minimum.
Once the data is loaded this will never change.
dymax
protected double dymax
- The data Y maximum.
Once the data is loaded this will never change.
dymin
protected double dymin
- The data Y minimum.
Once the data is loaded this will never change.
data
protected double data[]
- The array containing the actual data
length
protected int length
- The number of data points stored in the data array
xrange
protected double xrange
- The X range of the clipped data
yrange
protected double yrange
- The Y range of the clipped data
legend_length
protected int legend_length
- The length of the example line in the data legend.
legend_text
protected TextLine legend_text
- The legend text
legend_ix
protected int legend_ix
- The X pixel position of the data legend
legend_iy
protected int legend_iy
- The Y pixel position of the data legend
legend_dx
protected double legend_dx
- The X data position of the data legend
legend_dy
protected double legend_dy
- The Y data position of the data legend
increment
protected int increment
- The amount to increment the data array when the append method is being
used.
previousPointLines
protected int previousPointLines
previousPointMarkers
protected int previousPointMarkers
stride
protected int stride
- The stride of the data. For data pairs (x,y) the stride is 2
DataSet
public DataSet()
- Instantiate an empty data set.
DataSet
public DataSet(int stride) throws Exception
- Instantiate an empty data set.
- Parameters:
- stride - the stride of the data set. The default stride is 2.
DataSet
public DataSet(double d[],
int n) throws Exception
- Instantiate a DataSet with the parsed data. Default stride is 2.
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.
DataSet
public DataSet(double d[],
int n,
int s) throws Exception
- Instantiate a DataSet with the parsed data.
The double array contains the data. The X data is expected to be in
indices i*stride where i=0,1,... The Y data is expected to be found
in indices i*stride+1 where i=0,1,2...
The integer n is the
number of data Points. This means that the length of the data
array is 2*stride.
- Parameters:
- d - Array containing the (x,y) data pairs.
- n - Number of (x,y) data pairs in the array.
- s - The stride of the data.
- Throws: Exception
- A Generic exception if it fails to load the
parsed array into the class.
append
public synchronized 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.
appendPoint
public synchronized void appendPoint(double x,
double y)
- Append single data point to the data set. Added by MCC 3/19/97. Useful
for animated plotting since reranging etc can be calculated more easily.
- Parameters:
- x - x-coord of point to be added
- y - y-coord of point to be added
delete
public synchronized 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.
deleteData
public synchronized void deleteData()
- Delete all the data from the data set.
draw_data
public synchronized 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
getXmax
public double getXmax()
- return the data X maximum.
getXmin
public double getXmin()
- return the data X minimum.
getYmax
public double getYmax()
- return the data Y maximum.
getYmin
public double getYmin()
- return the data Y minimum.
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
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
legendFont
public void legendFont(Font f)
- Set the font to be used in the legend
- Parameters:
- f - font
legendColor
public void legendColor(Color c)
- Set the color for the legend text
- Parameters:
- c - color
dataPoints
public int dataPoints()
- Return the number of data points in the DataSet
- Returns:
- number of (x,y0 points.
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.
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.
plotAllPoints
public void plotAllPoints()
- Put previousPoints to -1 so all points are plotted
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
inside
protected boolean inside(double x,
double y)
- Return true if the point (x,y) is inside the allowed data range.
draw_markers
protected void draw_markers(Graphics g,
Rectangle w)
- Draw the markers. (Modified by MCC 3/19/97)
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
draw_legend
protected void draw_legend(Graphics g,
Rectangle w)
- Draw a legend for this data set
- Parameters:
- g - Graphics context
- w - Data Window
range
protected void range(int stride)
- 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