I have a spline graphic that get coordinates from InitP file. I plan to expand a code to make loading of graphics of several files (for each graphic there is the file with a set of coordinates).
On an input the line with names of files. In a cycle in each series for dataset coordinates for the appropriate diagram will be skidded. Difficulty arises in creation of new series, I don't know as to create a new series when reading the new file (I don't know how to create series2, series3 in cycle because I dont know how many series will be). There is a code for one graphic.
series1 = new XYSeries("Graph");
try {
Scanner s = new Scanner(new File("InitP"));
System.out.println("Open success!");
float xpol = 0, ypol = 0;
s.useLocale(Locale.US);
while (s.hasNext()) {
if (s.hasNextFloat()) {
xpol = s.nextFloat();
ypol = s.nextFloat();
System.out.println("x = " + xpol + ", y = " + ypol);
series1.add(xpol, ypol);
} else {
s.next();
}
}
dataset.addSeries(series1);
} catch (FileNotFoundException ex) {
System.out.println("Can't find file!");
}
XYSeriesCollection dataset = new XYSeriesCollection();