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
-
BAR
- Bar chart style.
-
BAR3D
- 3D bar chart style.
-
LINE
- Line graph style.
-
PIE
- Pie chart style.
-
PIE3D
- 3D pie chart style.
-
POINT
- Point graph style.
-
STACKBAR
- Stacked bar chart style.
-
STACKBAR3D
- Stacked 3D bar chart style.
-
Graph()
- Construct an empty graph.
-
Graph(Vector, Vector)
- Construct a Graph with x as the x axis values, and y as y axis
values.
-
Graph(Vector, Vector, int)
- Construct a Graph with x as the x axis values, and y as y axis
values.
-
addY(Vector)
- Add a data set to be displayed.
-
clearY()
- Clear all data sets.
-
getColors()
- Get the colors used by Graph for display each data sets.
-
minimumSize()
- Return the minimum size of Graph.
-
paint(Graphics)
- Paint the graph.
-
setColors(Color[])
- Set the colors to use for each data sets.
-
setStyle(int)
- Set the graph style to the specified type.
-
setValues(Vector, Vector)
- Set the data sets value.
-
update(Graphics)
- Overriden for double buffering.
LINE
public final static int LINE
- Line graph style.
POINT
public final static int POINT
- Point graph style.
BAR
public final static int BAR
- Bar chart style.
STACKBAR
public final static int STACKBAR
- Stacked bar chart style.
PIE
public final static int PIE
- Pie chart style.
BAR3D
public final static int BAR3D
- 3D bar chart style.
STACKBAR3D
public final static int STACKBAR3D
- Stacked 3D bar chart style.
PIE3D
public final static int PIE3D
- 3D pie chart style.
Graph
public Graph()
- Construct an empty graph. Caller must call setValues to pass in
the data sets for displaying.
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.
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.
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.
clearY
public void clearY()
- Clear all data sets.
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.
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.
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.
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.
minimumSize
public Dimension minimumSize()
- Return the minimum size of Graph.
- Returns:
- minimum size of graph.
- Overrides:
- minimumSize in class Component
paint
public void paint(Graphics g)
- Paint the graph.
- Parameters:
- g - Graphics context for this component.
- Overrides:
- paint in class Canvas
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