日期:2014-05-20 浏览次数:20660 次
int index = 1;
while (!donePrinting(index)) {
image = getPage(index);
if (image != null) {
saveImage(image, index);
image.flush();
image = null;
}
if (allImages.size() >= 5) {
try {
dialog = new BookPreviewUsingPics(allImages, getNumOfPages());
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
final int realIndex = index + 1;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
getLeftImages(realIndex);
}
});
return;
}
index++;
}
private void getLeftImages(int index) {
System.out.println("Start to getLastImages from index :" + index);
BufferedImage image = null;
while (!donePrinting(index)) {
image = getPage(index);
if (image != null) {
saveImageAndSend(image, index);
image.flush();
image = null;
}
index++;
}
image = getBackCoverPage();
if (image != null)
saveImageAndSend(image, getNumOfPages() + 1);
}
private void saveImageAndSend(BufferedImage image, int i) {
System.out.println("Start to saveImageAndSend for index :" + i + " image :" + image);
HashMap<Integer, BufferedImage> images = new HashMap<Integer, BufferedImage>();
images.put(i, image);
if (dialog != null) {
System.out.println("--> Start to sendBufferedImage for index :" + i);
dialog.sendBufferedImage(images);
}
}