For java-programming I use Eclipse, a very nice, professional IDE. To show intermediate and final results I needed a plotting package. Just for fun I decided to write my own package. Let's try to plot a sine as a first test.
package plotSine;
public class MainGUI {
private Engine myEngine;
public MainGUI() {
myEngine = new Engine();
myEngine.plotSine();
}
static public void main(String args[]) {
new MainGUI();
}
}
|
package plotSine;
import util.ShowPlot2d;
public class Engine {
public void plotSine(){
// plot sine as a first simple experiment
double[] plotData = new double[19];
for (int i = 0; i < 19; i = i + 1)
{
int ix = i * 20;
double arg = 2 * Math.PI * ix / 360;
double y = Math.sin(arg);
plotData[i] = y;
}
int numberOfPlots = 1;
ShowPlot2d myPlot = new ShowPlot2d(numberOfPlots);
double scaleFactor = 150;
myPlot.add(plotData, scaleFactor, "just a sinewave");
myPlot.showFigure();
}
}
|