Class tea.set.Graph
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.Graph

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----tea.set.Graph

public class Graph
extends Canvas
Graph widget supports the drawing of different types of graphs for multiple data sets. The labels for X axis must be supplied by the caller. The labels for Y axis will be generated automatically using the values supplied for drawing. The type of the graph can be changed dynamically after the graph is created.

For PIE and PIE3D types, only one dataset is displayed. If more than one dataset is added to the graph, only the first dataset is shown. To display multiple datasets using Pie charts, simply create a Panel or tea.set.Grid and create one Graph instance for each dataset.

See Also:
Grid

Variable Index

 o BAR
Bar chart style.
 o BAR3D
3D bar chart style.
 o LINE
Line graph style.
 o PIE
Pie chart style.
 o PIE3D
3D pie chart style.
 o POINT
Point graph style.
 o STACKBAR
Stacked bar chart style.
 o STACKBAR3D
Stacked 3D bar chart style.

Constructor Index

 o Graph()
Construct an empty graph.
 o Graph(Vector, Vector)
Construct a Graph with x as the x axis values, and y as y axis values.
 o Graph(Vector, Vector, int)
Construct a Graph with x as the x axis values, and y as y axis values.

Method Index

 o addY(Vector)
Add a data set to be displayed.
 o clearY()
Clear all data sets.
 o getColors()
Get the colors used by Graph for display each data sets.
 o minimumSize()
Return the minimum size of Graph.
 o paint(Graphics)
Paint the graph.
 o setColors(Color[])
Set the colors to use for each data sets.
 o setStyle(int)
Set the graph style to the specified type.
 o setValues(Vector, Vector)
Set the data sets value.
 o update(Graphics)
Overriden for double buffering.

Variables

 o LINE
  public final static int LINE
Line graph style.
 o POINT
  public final static int POINT
Point graph style.
 o BAR
  public final static int BAR
Bar chart style.
 o STACKBAR
  public final static int STACKBAR
Stacked bar chart style.
 o PIE
  public final static int PIE
Pie chart style.
 o BAR3D
  public final static int BAR3D
3D bar chart style.
 o STACKBAR3D
  public final static int STACKBAR3D
Stacked 3D bar chart style.
 o PIE3D
  public final static int PIE3D
3D pie chart style.

Constructors

 o Graph
  public Graph()
Construct an empty graph. Caller must call setValues to pass in the data sets for displaying.
 o Graph
  public Graph(Vector x,
               Vector y)
Construct a Graph with x as the x axis values, and y as y axis values. The x Vector can be a vector of any object. The string representation of the x objects are printed as x labels. The y vector must be a vector of Number. If multiple data sets need to be displayed, y can be a vector of vectors of Number. The same effect can be achieved by repeatitively calling addY() method. @see java.lang.Number
Parameters:
x - a vector of x axis labels.
y - a vector of java.lang.Number for y axis values.
 o Graph
  public Graph(Vector x,
               Vector y,
               int style)
Construct a Graph with x as the x axis values, and y as y axis values. The x Vector can be a vector of any object. The string representation of the x objects are printed as x labels. The y vector must be a vector of Number. If multiple data sets need to be displayed, y can be a vector of vectors of Number. The same effect can be achieved by repeatitively calling addY() method. The style parameter specifies the style of the Graph. It must be one of the style values defined in Graph.
Parameters:
x - a vector of x axis labels.
y - a vector of java.lang.Number for y axis values.
style - graph style.

Methods

 o setValues
  public void setValues(Vector x,
                        Vector y)
Set the data sets value. The parameters are the same as the constructor.
Parameters:
x - a vector of x axis labels.
y - a vector of java.lang.Number for y axis values.
 o clearY
  public void clearY()
Clear all data sets.
 o addY
  public void addY(Vector y)
Add a data set to be displayed. This method can be used to display multiple data sets in one graph. The parameter can either be a Vector of Numbers, or a Vector of Vector of Numbers. In the later case each vector is a dataset.
Parameters:
y - a vector of java.lang.Number for y axis values.
 o setStyle
  public void setStyle(int style)
Set the graph style to the specified type. The default style is LINE. This causes a repaint of the graph if style is different from the current one.
Parameters:
style - graph style.
 o getColors
  public Color[] getColors()
Get the colors used by Graph for display each data sets. The colors are chosen in the insertion order of data sets.
Returns:
an array of colors used by graph to display data sets.
 o setColors
  public void setColors(Color colors[])
Set the colors to use for each data sets.
Parameters:
colors - an arrow of colors used by graph to display data sets.
 o minimumSize
  public Dimension minimumSize()
Return the minimum size of Graph.
Returns:
minimum size of graph.
Overrides:
minimumSize in class Component
 o paint
  public void paint(Graphics g)
Paint the graph.
Parameters:
g - Graphics context for this component.
Overrides:
paint in class Canvas
 o update
  public void update(Graphics g)
Overriden for double buffering.
Parameters:
g - Graphics context for this component.
Overrides:
update in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index