Package org.jpedal

Examples of org.jpedal.Display


            }
    }
   
    //scroll to 'location'
        if (location != null) {
            Display pages=(org.jpedal.SingleDisplay) decode_pdf.getExternalHandler(org.jpedal.external.Options.Display);

            double scaling = decode_pdf.getScaling();
            double x = ((decode_pdf.getPdfPageData().getMediaBoxWidth(page) - ((Rectangle)location).getX())*scaling) + pages.getXCordForPage(page);
            double y = ((decode_pdf.getPdfPageData().getCropBoxHeight(page) - ((Rectangle)location).getY())*scaling) + pages.getYCordForPage(page);

            location = new Rectangle((int)x, (int)y, (int)decode_pdf.getVisibleRect().getWidth(), (int)decode_pdf.getVisibleRect().getHeight());

            decode_pdf.scrollRectToVisible((Rectangle) location);
        }
View Full Code Here


        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

        /**
 
View Full Code Here

    return new Point(x, y);
  }

  private Point getPageCoordsInContinuousDisplayMode(int x, int y, int page){

        Display pages=(SingleDisplay) decode_pdf.getExternalHandler(Options.Display);

        //<start-adobe>
    if (currentGUI.useNewLayout) {
      int[] flag = new int[2];

      flag[0] = SwingGUI.CURSOR;
      flag[1]=0;

      //In continuous pages are centred so we need make
      int xAdjustment = (decode_pdf.getWidth()/2) - (decode_pdf.getPdfPageData().getScaledCropBoxWidth(page)/2);
      if(xAdjustment<0)
        xAdjustment = 0;
      else{
        //This adjustment is the correct position.
        //Offset removed to that when used later we get either offset unaltered or correct position
        xAdjustment = xAdjustment-pages.getXCordForPage(page);
      }
      Rectangle pageArea = new Rectangle(pages.getXCordForPage(page)+xAdjustment,
          pages.getYCordForPage(page),
          decode_pdf.getPdfPageData().getScaledCropBoxWidth(page),
          decode_pdf.getPdfPageData().getScaledCropBoxHeight(page));
      if(pageArea.contains(x,y)){
        //set displayed
        flag[1] = 1;
      }



      if(flag[1]==0){
        if(y<pageArea.y && page>1){
          while(flag[1]==0 && page>1){
            page--;
            pageArea = new Rectangle(pages.getXCordForPage(page)+xAdjustment,
                pages.getYCordForPage(page),
                decode_pdf.getPdfPageData().getScaledCropBoxWidth(page),
                decode_pdf.getPdfPageData().getScaledCropBoxHeight(page));
            if(pageArea.contains(x,y)){
              //set displayed
              flag[1] = 1;
            }
          }
        }else{
          if(y>pageArea.getMaxY() && page<commonValues.getPageCount()){
            while(flag[1]==0 && page<commonValues.getPageCount()){
              page++;
              pageArea = new Rectangle(pages.getXCordForPage(page)+xAdjustment,
                                    pages.getYCordForPage(page),
                  decode_pdf.getPdfPageData().getScaledCropBoxWidth(page),
                  decode_pdf.getPdfPageData().getScaledCropBoxHeight(page));
              if(pageArea.contains(x,y)){
                //set displayed
                flag[1] = 1;
              }
            }
          }
        }
      }
     
      //Set highlighting page
      if(pageOfHighlight==-1 && startHighlighting){
        pageOfHighlight = page;
      }
     
      //Keep track of page mouse is over at all times
      pageMouseIsOver = page;
     
      //Tidy coords for multipage views
      y= ((pages.getYCordForPage(page)+decode_pdf.getPdfPageData().getScaledCropBoxHeight(page))+decode_pdf.getInsetH())-y;
     
      currentGUI.setMultibox(flag);
     
//      if(flag[1]==1 && (findPageToHighlight && commonValues.getCurrentHighlightedPage()==-1)){
//        commonValues.setCurrentHighlightedPage(page);
View Full Code Here

  }

  private Point getPageCoordsInContinuousFacingDisplayMode(int x, int y, int page){
    //<start-adobe>

        Display pages=(SingleDisplay) decode_pdf.getExternalHandler(Options.Display);

        if (currentGUI.useNewLayout) {
      int[] flag = new int[2];

      flag[0] = SwingGUI.CURSOR;
      flag[1]=0;
     
      //Check if we are in the region of the left or right pages
      if(page != 1 && x>(decode_pdf.getWidth()/2) && page<commonValues.getPageCount()){// && x>pageArea.x){
        page++;
      }

      //Set the adjustment for page position
      int xAdjustment = (decode_pdf.getWidth()/2) - (decode_pdf.getPdfPageData().getScaledCropBoxWidth(page))-(decode_pdf.getInsetW());

      //Unsure if this is needed. Still checking
      if(xAdjustment<0){
        System.err.println("x adjustment is less than 0");
        xAdjustment = 0;
      }
     
      //Check to see if pagearea contains the mouse
      Rectangle pageArea = new Rectangle(pages.getXCordForPage(page)+xAdjustment,
                    pages.getYCordForPage(page),
          decode_pdf.getPdfPageData().getScaledCropBoxWidth(page),
          decode_pdf.getPdfPageData().getScaledCropBoxHeight(page));
      if(pageArea.contains(x,y)){
        //set displayed
        flag[1] = 1;
      }

     
      //If neither of the two current pages contain the mouse start checking the other pages
      //Could be improved to minimise on the loops and calls to decode_pdf.getPageOffsets(page)
      if(flag[1]==0){
        if(y<pageArea.y && page>1){
          while(flag[1]==0 && page>1){
            page--;
            xAdjustment = (decode_pdf.getWidth()/2) - (decode_pdf.getPdfPageData().getScaledCropBoxWidth(page))-(decode_pdf.getInsetW());
            if(xAdjustment<0)
              xAdjustment = 0;
            pageArea = new Rectangle(pages.getXCordForPage(page)+xAdjustment,
                                pages.getYCordForPage(page),
                decode_pdf.getPdfPageData().getScaledCropBoxWidth(page),
                decode_pdf.getPdfPageData().getScaledCropBoxHeight(page));
            if(pageArea.contains(x,y)){
              //set displayed
              flag[1] = 1;
            }

          }
        }else{
          if(y>pageArea.getMaxY() && page<commonValues.getPageCount()){
            while(flag[1]==0 && page<commonValues.getPageCount()){
              page++;
              xAdjustment = (decode_pdf.getWidth()/2) - (decode_pdf.getPdfPageData().getScaledCropBoxWidth(page))-(decode_pdf.getInsetW());
              if(xAdjustment<0)
                xAdjustment = 0;
              pageArea = new Rectangle(pages.getXCordForPage(page)+xAdjustment,
                                    pages.getYCordForPage(page),
                  decode_pdf.getPdfPageData().getScaledCropBoxWidth(page),
                  decode_pdf.getPdfPageData().getScaledCropBoxHeight(page));
              if(pageArea.contains(x,y)){
                //set displayed
                flag[1] = 1;
              }

            }
          }
        }
      }
     
      //Set highlighting page
      if(pageOfHighlight==-1 && startHighlighting){
        pageOfHighlight = page;
      }
     
      //Keep track of page mouse is over at all times
      pageMouseIsOver = page;
     
      //Tidy coords for multipage views
      y= (((pages.getYCordForPage(page)+decode_pdf.getPdfPageData().getScaledCropBoxHeight(page))+decode_pdf.getInsetH()))-y;

      x = x - ((pages.getXCordForPage(page))-decode_pdf.getInsetW());
     
      currentGUI.setMultibox(flag);
     
    }
    //<end-adobe>
View Full Code Here

TOP

Related Classes of org.jpedal.Display

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.