Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

graph
Class DataSet  view DataSet download DataSet.java

java.lang.Object
  extended bygraph.DataSet

public class DataSet
extends java.lang.Object

This class is designed to hold the data to be plotted. It is to be used in conjunction with the Graph class and Axis class for plotting 2D graphs.

Version:
$Revision: 2.31 $, $Date: 2001/05/29 09:36:38 $

Field Summary
private  boolean _dates_needed
           
private  BasicDrawer _drawer
          Drawer of price bars - e.g., tic bars or candles
private  boolean clipping
          Boolean to control clipping of the data window.
private  java.awt.Color color_
           
private  double[] data
           
protected  DateDrawer date_drawer
          Drawer of dates
protected  java.lang.String[] dates
           
private  double dxmax
          The data X maximum.
private  double dxmin
          The data X minimum.
private  double dymax
          The data Y maximum.
private  double dymin
          The data Y minimum.
private  Graph g2d_
          The Graphics canvas that is driving the whole show.
private  java.util.Vector hline_data
           
private  int increment
          The amount to increment the data array when the append method is being used.
private  java.awt.Color linecolor
          The color of the straight line segments
private  int marker
          The index of the marker to use at the data points.
private  java.awt.Color markercolor
          The marker color
private  double markerscale
          The scaling factor for the marker.
private  boolean range_set
           
private  TimeDrawer time_drawer
          Drawer of times
protected  java.lang.String[] times
           
private  int tuple_count
           
private  java.util.Vector vline_data
           
private  Axis xaxis_
          The Axis object the X data is attached to.
private  double xmax
          The current plottable X maximum of the data.
private  double xmin
          The current plottable X minimum of the data.
private  double xrange
          The X range of the clipped data
private  Axis yaxis_
          The Axis object the Y data is attached to.
private  double ymax
          The current plottable Y maximum of the data.
private  double ymin
          The current plottable Y minimum of the data.
private  double yrange
          The Y range of the clipped data
 
Constructor Summary
DataSet(BasicDrawer d)
          Instantiate an empty data set.
DataSet(double[] d, int n, BasicDrawer drawer)
          Instantiate a DataSet with the parsed data.
 
Method Summary
 void add_hline(DoublePair p)
           
 void add_vline(DoublePair p)
           
 java.awt.Color color()
           
 int count()
           
 int dataPoints()
          Return the number of data points in the DataSet
 boolean dates_needed()
           
 void draw_data(java.awt.Graphics g, java.awt.Rectangle bounds)
          Draw the straight line segments and/or the markers at the data points.
protected  void draw_dates(java.awt.Graphics g, java.awt.Rectangle w)
          Draw times, if they exist; otherwise date dates, if they exist.
 BasicDrawer drawer()
           
 double[] getClosestPoint(double x, double y)
          Return the data point that is closest to the parsed (x,y) position
 double[] getPoint(int index)
          get the data point at the parsed index.
 double getXmax()
          return the data X maximum.
 double getXmin()
          return the data X minimum.
 double getYmax()
          return the data Y maximum.
 double getYmin()
          return the data Y minimum.
protected  int length()
           
protected  void range()
          Calculate the range of the data.
 void set_color(java.awt.Color c)
           
 void set_dates_needed(boolean b)
           
 void set_dates(java.lang.String[] d)
           
 void set_drawer(BasicDrawer d)
           
protected  void set_g2d(Graph g)
           
 void set_reference_values_needed(boolean b)
           
 void set_times(java.lang.String[] t)
           
 void set_xaxis(Axis a)
           
 void set_yaxis(Axis a)
           
protected  int stride()
          Number of components in a data tuple - for example, 2 (x, y) for a simple point
protected  TemporalDrawer temporal_drawer()
           
 Axis xaxis()
          Public Methods
 Axis yaxis()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

g2d_

private Graph g2d_
The Graphics canvas that is driving the whole show.

See Also:
Graph

linecolor

private java.awt.Color linecolor
The color of the straight line segments


marker

private int marker
The index of the marker to use at the data points.

See Also:
Markers

markercolor

private java.awt.Color markercolor
The marker color


markerscale

private double markerscale
The scaling factor for the marker. Default value is 1.


xaxis_

private 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_

private Axis yaxis_
The Axis object the Y data is attached to.

See Also:
Axis

xmax

private 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

private 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

private 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

private 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

private boolean clipping
Boolean to control clipping of the data window. Default value is true, clip the data window.


data

private double[] data

dates

protected java.lang.String[] dates

times

protected java.lang.String[] times

color_

private java.awt.Color color_

_drawer

private BasicDrawer _drawer
Drawer of price bars - e.g., tic bars or candles


date_drawer

protected DateDrawer date_drawer
Drawer of dates


time_drawer

private TimeDrawer time_drawer
Drawer of times


dxmax

private double dxmax
The data X maximum. Once the data is loaded this will never change.


dxmin

private double dxmin
The data X minimum. Once the data is loaded this will never change.


dymax

private double dymax
The data Y maximum. Once the data is loaded this will never change.


dymin

private double dymin
The data Y minimum. Once the data is loaded this will never change.


hline_data

private java.util.Vector hline_data

vline_data

private java.util.Vector vline_data

xrange

private double xrange
The X range of the clipped data


yrange

private double yrange
The Y range of the clipped data


increment

private int increment
The amount to increment the data array when the append method is being used.


range_set

private boolean range_set

tuple_count

private int tuple_count

_dates_needed

private boolean _dates_needed
Constructor Detail

DataSet

public DataSet(BasicDrawer d)
Instantiate an empty data set.


DataSet

public DataSet(double[] d,
               int n,
               BasicDrawer drawer)
        throws java.lang.Error
Instantiate a DataSet with the parsed data. `d' contains a set of tuples flattened out into array elements - for example, for a 4-field tuple, d[0..3] are the fields of the # first tuple, d[4..7] are the fields of the second tuple, etc. The integer n is the number of data Points. This means that the length of the data array is t*n, where t is the number of fields in a tuple. Note: `d' is expected to take y-position (vertical) data only; x-positions will be calculated based on the position of each tuple in `d' - from 1 to d.length.

Method Detail

set_drawer

public void set_drawer(BasicDrawer d)

set_dates

public void set_dates(java.lang.String[] d)

set_times

public void set_times(java.lang.String[] t)

drawer

public BasicDrawer drawer()

dates_needed

public boolean dates_needed()

set_dates_needed

public void set_dates_needed(boolean b)

count

public int count()

xaxis

public Axis xaxis()
Public Methods


yaxis

public Axis yaxis()

color

public java.awt.Color color()

set_xaxis

public void set_xaxis(Axis a)

set_yaxis

public void set_yaxis(Axis a)

set_color

public void set_color(java.awt.Color c)

add_hline

public void add_hline(DoublePair p)

add_vline

public void add_vline(DoublePair p)

set_reference_values_needed

public void set_reference_values_needed(boolean b)

draw_data

public void draw_data(java.awt.Graphics g,
                      java.awt.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


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.


dataPoints

public int dataPoints()
Return the number of data points in the DataSet


getPoint

public double[] getPoint(int index)
get the data point at the parsed index. The first (x,y) pair is at index 0.


getClosestPoint

public double[] getClosestPoint(double x,
                                double y)
Return the data point that is closest to the parsed (x,y) position


set_g2d

protected void set_g2d(Graph g)

temporal_drawer

protected TemporalDrawer temporal_drawer()

draw_dates

protected void draw_dates(java.awt.Graphics g,
                          java.awt.Rectangle w)
Draw times, if they exist; otherwise date dates, if they exist. Precondition: temporal_drawer() != null implies temporal_drawer().main_data_processed()


range

protected void range()
Calculate the range of the data. This modifies dxmin,dxmax,dymin,dymax and xmin,xmax,ymin,ymax Precondition: tuple_count has been set


stride

protected int stride()
Number of components in a data tuple - for example, 2 (x, y) for a simple point


length

protected int length()