KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > awt > Point2DListModel


1 package JSci.awt;
2
3 import java.awt.geom.Point2D JavaDoc;
4 import java.util.List JavaDoc;
5
6 /**
7 * The Point2DListModel provides a convenient implementation of
8 * the Graph2DModel interface based upon a List of Point2D objects.
9 * @version 1.0
10 * @author Mark Hale
11 */

12 public final class Point2DListModel extends AbstractGraphModel implements Graph2DModel {
13         private List JavaDoc data;
14
15         public Point2DListModel() {}
16         /**
17         * Sets the list of points to be plotted.
18         */

19         public void setData(List JavaDoc points) {
20                 data = points;
21                 fireGraphDataChanged();
22         }
23
24 // Graph2DModel interface
25

26         public float getXCoord(int i) {
27                 Point2D JavaDoc p = (Point2D JavaDoc) data.get(i);
28                 return (float) p.getX();
29         }
30         public float getYCoord(int i) {
31                 Point2D JavaDoc p = (Point2D JavaDoc) data.get(i);
32                 return (float) p.getY();
33         }
34         public int seriesLength() {
35                 return data.size();
36         }
37         public void firstSeries() {}
38         public boolean nextSeries() {
39                 return false;
40         }
41 }
42
43
Popular Tags