KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > awt > ArgandDiagramModel


1 package JSci.awt;
2
3 import JSci.maths.*;
4
5 /**
6 * The ArgandDiagramModel provides a convenient implementation of
7 * the Graph2DModel interface for creating Argand diagrams using
8 * the LineGraph component.
9 * @version 1.0
10 * @author Mark Hale
11 */

12 public final class ArgandDiagramModel extends AbstractGraphModel implements Graph2DModel {
13         private Complex data[] = new Complex[0];
14
15         public ArgandDiagramModel() {}
16         /**
17         * Sets the list of complex numbers to be plotted.
18         */

19         public void setData(Complex z[]) {
20                 if(data.length!=z.length)
21                         data=new Complex[z.length];
22                 System.arraycopy(z,0,data,0,z.length);
23                 fireGraphDataChanged();
24         }
25
26 // Graph2DModel interface
27

28         public float getXCoord(int i) {
29                 return (float)data[i].real();
30         }
31         public float getYCoord(int i) {
32                 return (float)data[i].imag();
33         }
34         public int seriesLength() {
35                 return data.length;
36         }
37         public void firstSeries() {}
38         public boolean nextSeries() {
39                 return false;
40         }
41 }
42
43
Popular Tags