return;
}
//Stop existing page decodes in pageFlow
if (decode_pdf.getDisplayView() == Display.PAGEFLOW) {
Display d = ((Display)decode_pdf.getExternalHandler(Options.Display));
d.stopGeneratingPage();
d.drawBorder();
}
if (!commonValues.isProcessing()) { //lock to stop multiple accesses
/**if in range update count and decode next page. Decoded pages are cached so will redisplay
* almost instantly*/
if (updatedTotal <= commonValues.getPageCount()) {
if(commonValues.isMultiTiff()){
//Update page number and draw new page
tiffImageToLoad = (lastPageDecoded-1) + count;
drawMultiPageTiff();
//Update Tiff page
commonValues.setCurrentPage(updatedTotal);
lastPageDecoded=tiffImageToLoad+1;
currentGUI.setPageNumber();
//Display new page
decode_pdf.repaint();
}else{
/**
* adjust for double jump on facing
*/
if(decode_pdf.getDisplayView() == Display.FACING || decode_pdf.getDisplayView() == Display.CONTINUOUS_FACING){
if (pages.separateCover || decode_pdf.getDisplayView() != Display.FACING) {
updatedTotal++;
if(updatedTotal>commonValues.getPageCount())
updatedTotal = commonValues.getPageCount();
if((updatedTotal & 1)==1 && updatedTotal!=1)
updatedTotal--;
if (decode_pdf.getDisplayView() == Display.FACING)
count = ((updatedTotal)/2) - ((commonValues.getCurrentPage())/2);
} else {
updatedTotal++;
if ((updatedTotal & 1)==0)
updatedTotal--;
count = ((updatedTotal+1)/2) - ((commonValues.getCurrentPage()+1)/2);
}
}
/**
* animate if using drag in facing
*/
if (count == 1 && pages.turnoverOn &&
decode_pdf.getPageCount() != 2 &&
currentGUI.getPageTurnScalingAppropriate() &&
decode_pdf.getDisplayView() == Display.FACING &&
updatedTotal/2 != commonValues.getCurrentPage()/2 &&
!decode_pdf.getPdfPageData().hasMultipleSizes() &&
!((DefaultActionHandler)decode_pdf.getFormRenderer().getActionHandler()).getSwingMouseHandler().getPageTurnAnimating()) {
float pageW = decode_pdf.getPdfPageData().getCropBoxWidth(1);
float pageH = decode_pdf.getPdfPageData().getCropBoxHeight(1);
if (decode_pdf.getPdfPageData().getRotation(1)%180==90) {
float temp = pageW;
pageW = pageH;
pageH = temp;
}
final Point corner = new Point();
corner.x = (int)((decode_pdf.getVisibleRect().getWidth()/2)-pageW);
corner.y = (int)(decode_pdf.getInsetH()+pageH);
final Point cursor = new Point();
cursor.x = (int)((decode_pdf.getVisibleRect().getWidth()/2)+pageW);
cursor.y = (int)(decode_pdf.getInsetH()+pageH);
final int newPage = updatedTotal;
Thread animation = new Thread() {
public void run() {
// Fall animation
int velocity = 1;
//ensure cursor is not outside expected range
if (cursor.x <= corner.x)
cursor.x = corner.x-1;
//Calculate distance required
double distX = (corner.x-cursor.x);
//Loop through animation
while (cursor.getX() >= corner.getX()) {
//amount to move this time
double xMove = velocity*distX*0.001;
//make sure always moves at least 1 pixel in each direction
if (xMove > -1)
xMove = -1;
cursor.setLocation(cursor.getX() + xMove, cursor.getY());
decode_pdf.setUserOffsets((int)cursor.getX(), (int)cursor.getY(), org.jpedal.external.OffsetOptions.INTERNAL_DRAG_CURSOR_BOTTOM_RIGHT);
//Double speed til moving 32/frame
if (velocity < 32)
velocity = velocity*2;
//sleep til next frame
try {
Thread.currentThread().sleep(50);
} catch (Exception e) {
e.printStackTrace();
}
}
//change page
commonValues.setCurrentPage(newPage);
currentGUI.setPageNumber();
decode_pdf.setPageParameters(currentGUI.getScaling(), commonValues.getCurrentPage());
currentGUI.decodePage(false);
//unlock corner drag
((DefaultActionHandler)decode_pdf.getFormRenderer().getActionHandler()).getSwingMouseHandler().setPageTurnAnimating(false);
//hide turnover
decode_pdf.setUserOffsets(0, 0,org.jpedal.external.OffsetOptions.INTERNAL_DRAG_BLANK);
}
};
//lock corner drag
((DefaultActionHandler)decode_pdf.getFormRenderer().getActionHandler()).getSwingMouseHandler().setPageTurnAnimating(true);
animation.start();
} else {
commonValues.setCurrentPage(updatedTotal);
currentGUI.setPageNumber();
if(decode_pdf.getDisplayView() == Display.CONTINUOUS ||
decode_pdf.getDisplayView() == Display.CONTINUOUS_FACING ||
decode_pdf.getDisplayView() == Display.PAGEFLOW){
currentGUI.decodePage(false);
return ;
}
currentGUI.resetStatusMessage("Loading Page "+commonValues.getCurrentPage());
/**reset as rotation may change!*/
decode_pdf.setPageParameters(currentGUI.getScaling(), commonValues.getCurrentPage());
//decode the page
if(commonValues.isPDF())
currentGUI.decodePage(false);
//if scaling to window reset screen to fit rotated page
// if(currentGUI.getSelectedComboIndex(Commands.SCALING)<3)
// currentGUI.zoom();
}
}
}
}else
currentGUI.showMessageDialog(Messages.getMessage("PdfViewerDecodeWait.message"));
}else{
//if loading on linearized thread, see if we can actually display
if(!decode_pdf.isPageAvailable(updatedTotal)){
currentGUI.showMessageDialog("Page "+updatedTotal+" is not yet loaded");
return;
}
//Stop existing page decodes in pageFlow
if (decode_pdf.getDisplayView() == Display.PAGEFLOW) {
Display d = ((Display)decode_pdf.getExternalHandler(Options.Display));
d.stopGeneratingPage();
d.drawBorder();
}
if (!commonValues.isProcessing()) { //lock to stop multiple accesses
/**