I’ve got some code here for printing that prints a block of information from an array one per page.
double x = pf.getImageableX() + 1;
double y = pf.getImageableY();
double xMax = pf.getImageableWidth();
double yMax = pf.getImageableHeight();
if ((pageIndex < generation.length)) {
//Graphics code
y += (height of index) + 10;
return PAGE_EXISTS;
} else {
return NO_SUCH_PAGE;
}
}
I want to have the index keep increasing, printing more objects per page, until y would exceed yMax. At that point, y would reset and I could continue printing objects on the next page.
The print() method itself is recursive, however; so if I tried to introduce a for loop, it would simply print the same entries over and over until (pageIndex < generation.length).
How do I print new pages when y > yMax, while also being able to print all the elements in my array?
I don’t fully understand how your recursion is working. Maybe seeing the calls would help.
If pageIndex at the moment represents what page you are on and where you are at in the array then it needs to be split.
You will need another case to know if you are still on the page or if the page has finished.
Again this might not be what you are looking for but it is my best guess based on your snippet.