org.mbari.siam.moos.utils.chart.graph
Class VectorSet

java.lang.Object
  extended by org.mbari.siam.moos.utils.chart.graph.DataSet
      extended by org.mbari.siam.moos.utils.chart.graph.VectorSet

public class VectorSet
extends DataSet

This class is designed to hold vectors to be plotted. It extends the DataSet class. The vectors are defined as (x,y,dx,dy) where (x,y) is the position of the vector tail and (dx,dy) is the relative position of the head. It is to be used in conjunction with the Graph2D class and Axis class for plotting 2D graphs.

Version:
$Revision: 1.2 $, $Date: 2011/08/17 19:09:20 $
Author:
Leigh Brookshaw

Field Summary
static int MAXIMUM
          A constant value flag used to specify if the max magnitude of the vectors is going to be used as the scaling variable
static int MEAN
          A constant value flag used to specify if the mean magnitude of the vectors is going to be used as the scaling variable
static int MINIMUM
          A constant value flag used to specify if the minimum magnitude of the vectors is going to be used as the scaling variable
 double scale
          This is the scaling to be used when drawing vectors.
protected  int scalingType
          The flag specifying which scaling variable to use
protected  int stride
          This is the stride of the data in the data array.
 
Fields inherited from class org.mbari.siam.moos.utils.chart.graph.DataSet
clipping, data, dxmax, dxmin, dymax, dymin, g2d, increment, legend_dx, legend_dy, legend_ix, legend_iy, legend_length, legend_text, length, LINE, linecolor, linestyle, marker, markercolor, markerscale, NOLINE, xaxis, xmax, xmin, xrange, yaxis, ymax, ymin, yrange
 
Constructor Summary
VectorSet()
          Instantiate an empty data set.
VectorSet(double scale)
          Instantiate an empty data set.
VectorSet(double[] d, int n)
          Instantiate a DataSet with the parsed data.
VectorSet(double[] d, int n, double scale)
          Instantiate a DataSet with the parsed data.
 
Method Summary
 void draw_data(java.awt.Graphics g, java.awt.Rectangle bounds)
          Draw the vectors at the data points.
protected  void draw_legend(java.awt.Graphics g, java.awt.Rectangle w)
          Draw a legend for this Vector set
protected  void drawVectors(java.awt.Graphics g, java.awt.Rectangle w)
           
 double getScaleFactor()
          return the current scaling factor.
 void legend()
          Draw a Vector legend in the graph window.
 void legend(double x, double y, java.lang.String text)
          Define a Vector legend in the graph window
 void legend(int x, int y, java.lang.String text)
          Define a Vector legend in the graph window
 void legend(java.lang.String text)
          Define a Vector legend in the graph window.
protected  void range(int stride)
          Calculate the range of the data and the magnitude of the vectors.
 void setScale(double scale)
          Set the scaling to use when drawing vectors
 void setScalingType(int type)
          Set the scaling type to use when drawing vectors
 
Methods inherited from class org.mbari.siam.moos.utils.chart.graph.DataSet
append, dataPoints, delete, deleteData, draw_lines, draw_markers, getClosestPoint, getPoint, getXmax, getXmin, getYmax, getYmin, inside, legendColor, legendFont
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MEAN

public static final int MEAN
A constant value flag used to specify if the mean magnitude of the vectors is going to be used as the scaling variable

See Also:
Constant Field Values

MINIMUM

public static final int MINIMUM
A constant value flag used to specify if the minimum magnitude of the vectors is going to be used as the scaling variable

See Also:
Constant Field Values

MAXIMUM

public static final int MAXIMUM
A constant value flag used to specify if the max magnitude of the vectors is going to be used as the scaling variable

See Also:
Constant Field Values

scale

public double scale
This is the scaling to be used when drawing vectors. The scaling is the fraction of the axis the mean vector magnitude will be scaled to.


stride

protected int stride
This is the stride of the data in the data array. For a vector set it will be 4.


scalingType

protected int scalingType
The flag specifying which scaling variable to use

Constructor Detail

VectorSet

public VectorSet()
          throws java.lang.Exception
Instantiate an empty data set.

Throws:
java.lang.Exception - A Generic exception if it fails to instantiate the the class with the correct stride.

VectorSet

public VectorSet(double[] d,
                 int n)
          throws java.lang.Exception
Instantiate a DataSet with the parsed data. The double array contains the data. The data is stored in the array in the sequence
             x,y,dx,dy,x,y,dx,dy,...
 
Where (x,y) is the position of the tail and (dx,dy) is the relative position of the head. This means that the length of the data array is 4*n.

Parameters:
d - Array containing the (x,y,dy,dx) vectors.
n - Number of (x,y) data pairs in the array.
Throws:
java.lang.Exception - A Generic exception if it fails to load the parsed array into the class.

VectorSet

public VectorSet(double scale)
          throws java.lang.Exception
Instantiate an empty data set.

Parameters:
scale - The scaling to use when plotting the vectors.
Throws:
java.lang.Exception - A Generic exception if it fails to instantiate the the class with the correct stride.

VectorSet

public VectorSet(double[] d,
                 int n,
                 double scale)
          throws java.lang.Exception
Instantiate a DataSet with the parsed data.

Parameters:
d - Array containing the (x,y,dy,dx) vectors.
n - Number of (x,y,dx,dy) vectors in the array.
Throws:
java.lang.Exception - A Generic exception if it fails to load the parsed array into the class.
Method Detail

setScale

public void setScale(double scale)
Set the scaling to use when drawing vectors

Parameters:
scale - The scaling to employ

setScalingType

public void setScalingType(int type)
Set the scaling type to use when drawing vectors

Parameters:
type - Either MEAN, MAXIMUM or MINIMUM.

getScaleFactor

public double getScaleFactor()
return the current scaling factor. That is the calculated scaling using the axis range the mean/max/min magnitude and the percentage scale.


legend

public void legend()
Draw a Vector legend in the graph window. The legend will be placed above the data window in the center


legend

public void legend(java.lang.String text)
Define a Vector legend in the graph window. The legend will be placed above the data window in the center

Parameters:
text - text to display in the legend

legend

public void legend(int x,
                   int y,
                   java.lang.String text)
Define a Vector legend in the graph window

Overrides:
legend in class DataSet
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,
                   java.lang.String text)
Define a Vector legend in the graph window

Overrides:
legend in class DataSet
Parameters:
x - data position of the legend.
y - data position of the legend.
text - text to display in the legend

draw_data

public void draw_data(java.awt.Graphics g,
                      java.awt.Rectangle bounds)
Draw the vectors 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

Overrides:
draw_data in class DataSet
Parameters:
g - Graphics state
bounds - The data window to draw into

draw_legend

protected void draw_legend(java.awt.Graphics g,
                           java.awt.Rectangle w)
Draw a legend for this Vector set

Overrides:
draw_legend in class DataSet
Parameters:
g - Graphics context
w - Data Window

drawVectors

protected void drawVectors(java.awt.Graphics g,
                           java.awt.Rectangle w)

range

protected void range(int stride)
Calculate the range of the data and the magnitude of the vectors. This modifies dxmin,dxmax,dymin,dymax and xmin,xmax,ymin,ymax

Overrides:
range in class DataSet


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.