Timer timer = new Timer();
final int numPlots = plotsx * plotsy;
final Axis[] xAxes = new Axis[numPlots];
final Axis[] yAxes = new Axis[numPlots];
final SimpleXYDataset[][] datasets = new SimpleXYDataset[numPlots][linesPerPlot];
SlopeLine slopeLine = new SlopeLine();
slopeLine.setForeground(Color.white);
for(int i = 0; i < numPlots; i++) {
final XYPlot plot = new XYPlot();
final XYAxis xAxis = new LinearXYAxis(XYDimension.X);
final XYAxis yAxis = new LinearXYAxis(XYDimension.Y);
xAxis.setPreferredSize(new Dimension(1, 30));
yAxis.setPreferredSize(new Dimension(40, 1));
xAxis.setForeground(Color.white);
yAxis.setForeground(Color.white);
xAxis.setTextMargin(10);
yAxis.setTextMargin(10);
plot.add(xAxis);
plot.add(yAxis);
plot.setXAxis(xAxis);
plot.setYAxis(yAxis);
plot.setBackground(Color.darkGray);
XYGrid grid = new XYGrid(xAxis, yAxis);
grid.setForeground(Color.lightGray);
XYPlotContents contents = new XYPlotContents();
contents.setBackground(Color.black);
plot.add(contents);
contents.add(grid);
plot.setPreferredSize(new Dimension(150, 100));
new DefaultXYLayoutGenerator().generateLayout(plot);
for(int j = 0; j < linesPerPlot; j++) {
final LinearXYPlotLine line = new LinearXYPlotLine(xAxis, yAxis, XYDimension.X);
line.setForeground(Color.white);
final SimpleXYDataset d = new SimpleXYDataset(line);
d.setMaxCapacity(1000);
d.setXData(line.getXData());
d.setYData(line.getYData());
contents.add(line);
for(int x = 0; x < 900; x++) {
double x2 = x / 10.0;
double y2 = Math.sin(x2 / 10.0 + Math.PI * j / (double) linesPerPlot);
d.add(x2, y2);
}
datasets[i][j] = d;
}
slopeLine.attach(plot);
yAxis.setStart(-1.2);
yAxis.setEnd(1.2);
xAxis.setStart(0);
xAxis.setEnd(10);