JSci.swing.JLineGraph Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsci Show documentation
Show all versions of jsci Show documentation
JSci is a set of open source Java packages. The aim is to encapsulate scientific methods/principles in the most natural way possible. As such they should greatly aid the development of scientific based software.
It offers: abstract math interfaces, linear algebra (support for various matrix and vector types), statistics (including probability distributions), wavelets, newtonian mechanics, chart/graph components (AWT and Swing), MathML DOM implementation, ...
Note: some packages, like javax.comm, for the astro and instruments package aren't listed as dependencies (not available).
The newest version!
package JSci.swing;
import java.awt.*;
import JSci.awt.*;
/**
* A line graph Swing component.
* There is some support for the handling of NaN values.
* @version 1.4
* @author Mark Hale
*/
public class JLineGraph extends JGraph2D {
/**
* Constructs a line graph.
*/
public JLineGraph(Graph2DModel gm) {
super(gm);
}
/**
* Draws the graph data.
* Override this method to change how the graph data is plotted.
*/
protected void drawData(Graphics g) {
// lines
Point p1, p2;
int i;
model.firstSeries();
if(model.seriesLength() > 0) {
g.setColor(seriesColor[0]);
drawSeries(g);
}
for(int n=1;model.nextSeries();n++) {
if(model.seriesLength() > 0) {
g.setColor(seriesColor[n]);
drawSeries(g);
}
}
super.drawData(g);
}
private void drawSeries(Graphics g) {
Point p1 = null;
for(int i=0; i