Package org.jpedal.utils.repositories

Examples of org.jpedal.utils.repositories.Vector_Rectangle


                    Rectangle rectangle = new Rectangle(wx1, wy2, wx2 - wx1, wy1 - wy2);

                    int seperator = (int) co_ords[ii + 4];

                    if (seperator == linkedSearchAreas) {
                        Vector_Rectangle vr = new Vector_Rectangle();
                        vr.addElement(rectangle);
                        while (seperator == linkedSearchAreas) {
                            ii = ii + 5;
                            wx1 = (int) co_ords[ii];
                            wy1 = (int) co_ords[ii + 1];
                            wx2 = (int) co_ords[ii + 2];
                            wy2 = (int) co_ords[ii + 3];
                            seperator = (int) co_ords[ii + 4];
                            rectangle = new Rectangle(wx1, wy2, wx2 - wx1, wy1 - wy2);
                            vr.addElement(rectangle);
                        }
                        vr.trim();
                        list.add(vr.get());
                    } else {
                        list.add(rectangle);
                    }
                }
            }
View Full Code Here


    this.pageNumber = pageNumber;
    this.objectStoreRef = newObjectRef;
    this.addBackground = addBackground;

    //setupArrays(defaultSize);
    areas = new Vector_Rectangle(defaultSize);
  }
View Full Code Here

              Rectangle[] finalHighlight;
              Rectangle highlight = (Rectangle) searchFrame.getTextRectangles().get(key);
             
              if((Integer) currPage != nextPage)
                if(allHighlightsShown){
                  Vector_Rectangle storageVector = new Vector_Rectangle();

                  Integer kInteger;
                 
                  //Integer allKeys = new Integer(id);
                  for(int k=0; k!=results.getModel().getSize(); k++){

                    kInteger= k;
                    //int currentPage = ((Integer)newPage).intValue();
                    if((Integer) results.getTextPages().get(kInteger) ==nextPage){

                      Object h= searchFrame.getTextRectangles().get(kInteger);

                      if(h instanceof Rectangle){
                        storageVector.addElement((Rectangle)h);
                      }
                      if(h instanceof Rectangle[]){
                        Rectangle[] areas = (Rectangle[])h;
                        for(int i=0; i!=areas.length; i++){
                          storageVector.addElement(areas[i]);
                        }
                      }
                    }
                  }

                  storageVector.trim();
                  finalHighlight = storageVector.get();
                  decode_pdf.getTextLines().addHighlights(finalHighlight, true,nextPage);
                }
             
             

              //draw rectangle
              //int scrollInterval = decode_pdf.getScrollInterval();
              //previous one to revert back to but other more accurate
//              decode_pdf.scrollRectToVisible(new Rectangle((int)((highlight.x*scaling)+scrollInterval),(int)(mediaGUI.cropH-((highlight.y-currentGUI.cropY)*scaling)-scrollInterval*2),scrollInterval*4,scrollInterval*6));

              //int x = (int)((highlight.x-currentGUI.cropX)*scaling)+inset;
              //int y = (int)((currentGUI.cropH-(highlight.y-currentGUI.cropY))*scaling)+inset;
              //int w = (int)(highlight.width*scaling);
              //int h = (int)(highlight.height*scaling);

              //Rectangle view = decode_pdf.getVisibleRect();
//              if(decode_pdf.getDisplayView()==Display.SINGLE_PAGE){
//                decode_pdf.scrollRectToVisible(highlight);
//              }else{
//                decode_pdf.scrollRectToHighlight(highlight);
//              }
              scrollRectToHighlight(highlight,commonValues.getCurrentPage());

              if(!allHighlightsShown)
                decode_pdf.getTextLines().addHighlights(new Rectangle[]{highlight}, true, nextPage);
             
              pages.refreshDisplay();
              decode_pdf.repaint();

            }
          }
        }
                currentGUI.hideRedundentNavButtons();
      }
     
      if(commonValues.getCurrentPage()==searchFrame.getFirstPageWithResults() &&
          results.getSelectedIndex()==0){
        status = FIRST_DOCUMENT_SEARCH_RESULT_NOW_SHOWN;
      }
     
      break;

    case NEXTRESULT:
      if(args==null){
        final boolean boeingDebug = false;
        status = null;
       
        if(results==null)
          results = searchFrame.getResults(commonValues.getCurrentPage());
       
        int index = results.getSelectedIndex();
       
        if(boeingDebug){
          System.out.println("Next result called");
          System.out.println("Index=="+index);
        }
        if(index<0){
          index=0;
          results.setSelectedIndex(index);
          if(boeingDebug){
            System.out.println("Index invalid. Index changed to "+index);
          }
        }
       
//        Object currPage = results.getTextPages().get(new Integer(index));
        Object currPage = commonValues.getCurrentPage();
       
        if(boeingDebug){
          System.out.println("Current results count == "+results.getResultCount());
        }
       
        if(index==results.getResultCount()-1 ||
            results.getResultCount()==0){
          index=0;
          int currentPage = commonValues.getCurrentPage()+1;
          if(boeingDebug){
            System.out.println("Compare current page with page count");
            System.out.println("Current Page == "+currentPage);
            System.out.println("Page Count=="+commonValues.getPageCount());
          }
         
          if(currentPage>commonValues.getPageCount()){
            if(boeingDebug){
              System.out.println("Out of page range. Resetting to page 1");
            }
            currentPage = 1;
          }
         
          results = searchFrame.getResults(currentPage);
         
          while(results.getResultCount()<1 && currentPage<commonValues.getPageCount()+1 &&
              searchFrame.getStyle()==SwingSearchWindow.SEARCH_MENU_BAR){
            results = searchFrame.getResults(currentPage);
            if(boeingDebug){
              System.out.println("No Results on page "+currentPage);
            }
            currentPage++;
          }

          if(results.getResultCount()<1 &&
              currentPage==commonValues.getPageCount()+1){
            if(boeingDebug){
              System.out.println("Reached end of document, return to page 1");
            }
            currentPage=1;
            status = SEARCH_RETURNED_TO_START;
            while(results.getResultCount()<1 && currentPage<=commonValues.getCurrentPage() &&
                searchFrame.getStyle()==SwingSearchWindow.SEARCH_MENU_BAR){
              results = searchFrame.getResults(currentPage);
              if(boeingDebug){
                System.out.println("No results on page "+currentPage);
              }
              currentPage++;
            }
           
            if(results.getResultCount()<1){
              if(boeingDebug){
                System.out.println("No results found in document");
              }
              status = SEARCH_NOT_FOUND;
            }
          }
        }else{
          if(boeingDebug){
            System.out.println("Next results on page "+commonValues.getCurrentPage());
          }
          index++;
        }

        results.setSelectedIndex(index);

                //@kieran - altered by Mark so search can display
        if (1==1 || !commonValues.isProcessing()) {// {if(!event.getValueIsAdjusting()){
          float scaling = currentGUI.getScaling();
          //int inset = currentGUI.getPDFDisplayInset();

          int id = results.getSelectedIndex();

          if(!allHighlightsShown)
            decode_pdf.getTextLines().clearHighlights();

          if (id != -1) {
            Integer key = id;
            Object newPage = results.getTextPages().get(key);

            if (newPage != null) {
              int nextPage = (Integer) newPage;
              // move to new page
              if (commonValues.getCurrentPage() != nextPage) {
                commonValues.setCurrentPage(nextPage);

                currentGUI.resetStatusMessage(Messages.getMessage("PdfViewer.LoadingPage") + ' ' + commonValues.getCurrentPage());

                /** reset as rotation may change! */
                decode_pdf.setPageParameters(scaling, commonValues.getCurrentPage());

               
                // decode the page
                currentGUI.decodePage(false);
               
                decode_pdf.invalidate();
              }
             
              while(commonValues.isProcessing()){
                                try {
                                    Thread.sleep(500);
                                } catch (InterruptedException e) {
                                    e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                                }
                                //Ensure page has been processed else highlight may be incorrect
              }
             
              Rectangle[] finalHighlight;
              Rectangle highlight = (Rectangle)results.textAreas().get(key);
              //int pageOfHighlight = ((Integer) results.getTextPages().get(key)).intValue();

                            //@kieran - added by Mark to trap null
              if(currPage!=null && (Integer) currPage != nextPage)
                if(allHighlightsShown){
                  Vector_Rectangle storageVector = new Vector_Rectangle();

                 
                  //Integer allKeys = new Integer(id)
                  Integer kInteger;
                  for(int k=0; k!=results.getModel().getSize(); k++){

                    kInteger= k;
                    //int currentPage = ((Integer)newPage).intValue();
                    if((Integer) results.getTextPages().get(kInteger) ==nextPage){

                      Object h= searchFrame.getTextRectangles().get(kInteger);

                      if(h instanceof Rectangle){
                        storageVector.addElement((Rectangle)h);
                      }
                      if(h instanceof Rectangle[]){
                        Rectangle[] areas = (Rectangle[])h;
                        for(int i=0; i!=areas.length; i++){
                          storageVector.addElement(areas[i]);
                        }
                      }
                    }
                  }

                  storageVector.trim();
                  finalHighlight = storageVector.get();
                  decode_pdf.getTextLines().addHighlights(finalHighlight, true, nextPage);
                }
             
              // draw rectangle

View Full Code Here

        current.width=lines[selectedLine].width;
        current.height=lines[selectedLine].height;

        boolean foundTop = true;
        boolean foundBottom = true;
        Vector_Rectangle selected = new Vector_Rectangle(0);
        selected.addElement(lines[selectedLine]);

        while(foundTop){
          foundTop = false;
          for(int i=0; i!=lines.length; i++){
            if(lines[i].contains(left, cy+h) || lines[i].contains(cx, cy+h) || lines[i].contains(right, cy+h)){
              selected.addElement(lines[i]);
              foundTop = true;
              cy = lines[i].getCenterY();
              h = lines[i].height;

              if(current.x>lines[i].x){
                current.width = (current.x+current.width)-lines[i].x;
                current.x = lines[i].x;
              }
              if((current.x+current.width)<(lines[i].x+lines[i].width))
                current.width = (lines[i].x+lines[i].width)-current.x;
              if(current.y>lines[i].y){
                current.height = (current.y+current.height)-lines[i].y;
                current.y = lines[i].y;
              }
              if((current.y+current.height)<(lines[i].y+lines[i].height)){
                current.height = (lines[i].y+lines[i].height)-current.y;
              }

              break;
            }
          }
        }

        //Return to selected item else we have duplicate highlights
        left = lines[selectedLine].x;
        cx = lines[selectedLine].getCenterX();
        right = lines[selectedLine].x+lines[selectedLine].width;
        cy = lines[selectedLine].getCenterY();
        h = lines[selectedLine].height;

        while(foundBottom){
          foundBottom = false;
          for(int i=0; i!=lines.length; i++){
            if(lines[i].contains(left, cy-h) || lines[i].contains(cx, cy-h) || lines[i].contains(right, cy-h)){
              selected.addElement(lines[i]);
              foundBottom = true;
              cy = lines[i].getCenterY();
              h = lines[i].height;

              if(current.x>lines[i].x){
                current.width = (current.x+current.width)-lines[i].x;
                current.x = lines[i].x;
              }
              if((current.x+current.width)<(lines[i].x+lines[i].width))
                current.width = (lines[i].x+lines[i].width)-current.x;
              if(current.y>lines[i].y){
                current.height = (current.y+current.height)-lines[i].y;
                current.y = lines[i].y;
              }
              if((current.y+current.height)<(lines[i].y+lines[i].height)){
                current.height = (lines[i].y+lines[i].height)-current.y;
              }

              break;
            }
          }
        }
        selected.trim();
        addHighlights(selected.get(), true, page);
        return current;
      }
      return null;
    }
    return null;
View Full Code Here

                                current.decodePageContent(pdfObject);

                                //All data loaded so now get all line areas for page
                                if(textLines!=null){
                                    Vector_Rectangle vr = (Vector_Rectangle) current.getObjectValue(ValueTypes.TextAreas);
                                    vr.trim();
                                    Rectangle[] pageTextAreas = vr.get();

                                    Vector_Int vi =  (Vector_Int) current.getObjectValue(ValueTypes.TextDirections);
                                    vi.trim();
                                    int[] pageTextDirections = vi.get();
View Full Code Here

        this.addBackground = addBackground;
        this.cropBox = cropBox;
        this.midPoint = midPoint;

        //setupArrays(defaultSize);
        areas = new Vector_Rectangle(defaultSize);

    }
View Full Code Here

                   */
                  if((searchTypeParameters & SearchType.HIGHLIGHT_ALL_RESULTS)== SearchType.HIGHLIGHT_ALL_RESULTS){

//                    PdfHighlights.clearAllHighlights(decode_pdf);
                    Rectangle[] showAllOnPage;
                    Vector_Rectangle storageVector = new Vector_Rectangle();
                    int lastPage = -1;
                    for(int k=0; k!=resultsList.getModel().getSize(); k++){
                      Object page=textPages.get(k);

                      if(page!=null){

                        int currentPage = (Integer) page;
                        if(currentPage!=lastPage){
                          storageVector.trim();
                          showAllOnPage = storageVector.get();
                         
                          for(int p=0; p!=showAllOnPage.length; p++){
                                      System.out.println(showAllOnPage[p]);
                                    }
                         
                          decode_pdf.getTextLines().addHighlights(showAllOnPage, true, lastPage);
                          lastPage = currentPage;
                          storageVector = new Vector_Rectangle();
                        }

                        Object highlight= textRectangles.get(k);

                        if(highlight instanceof Rectangle){
                          storageVector.addElement((Rectangle)highlight);
                        }
                        if(highlight instanceof Rectangle[]){
                          Rectangle[] areas = (Rectangle[])highlight;
                          for(int i=0; i!=areas.length; i++){
                            storageVector.addElement(areas[i]);
                          }
                        }
                        //decode_pdf.addToHighlightAreas(decode_pdf, storageVector, currentPage);
//                        }
                      }
                    }
                    storageVector.trim();
                    showAllOnPage = storageVector.get();
                   
                    decode_pdf.getTextLines().addHighlights(showAllOnPage, true, lastPage);
                  }else{
//                    PdfHighlights.clearAllHighlights(decode_pdf);
                    Object page=textPages.get(key);
                    int currentPage = (Integer) page;
                   
                    Vector_Rectangle storageVector = new Vector_Rectangle();
                    Rectangle scroll = null;
                    Object highlight= textRectangles.get(key);
                    if(highlight instanceof Rectangle){
                      storageVector.addElement((Rectangle)highlight);
                      scroll=(Rectangle)highlight;
                    }
                   
                    if(highlight instanceof Rectangle[]){
                      Rectangle[] areas = (Rectangle[])highlight;
                      scroll=areas[0];
                      for(int i=0; i!=areas.length; i++){
                        storageVector.addElement(areas[i]);
                      }
                    }
                    currentGUI.currentCommands.scrollRectToHighlight(scroll,currentPage);
                    storageVector.trim();
                    decode_pdf.getTextLines().addHighlights(storageVector.get(), true, currentPage);
                    //PdfHighlights.addToHighlightAreas(decode_pdf, storageVector, currentPage);
                   
                  }

                  decode_pdf.invalidate();
View Full Code Here

               * Highlight all search results on page.
               */
             
              if((searchTypeParameters & SearchType.HIGHLIGHT_ALL_RESULTS)== SearchType.HIGHLIGHT_ALL_RESULTS){
                Rectangle[] showAllOnPage;
                Vector_Rectangle storageVector = new Vector_Rectangle();
                int lastPage = -1;
                int currentPage = 0;
//                System.out.println("size = "+getSize());
                for(int k=0; k!=textPages.size(); k++){
                  Object page=textPages.get(k);

                  if(page!=null){
                    currentPage = (Integer) page;
                    if(currentPage!=lastPage && lastPage!=-1){
                      storageVector.trim();
                      showAllOnPage = storageVector.get();
                      decode_pdf.getTextLines().addHighlights(showAllOnPage, true, lastPage);
                      lastPage = currentPage;
                      storageVector = new Vector_Rectangle();
                    }

                      Object highlight= textRectangles.get(k);

                      if(highlight instanceof Rectangle){
                        storageVector.addElement((Rectangle)highlight);
                      }
                      if(highlight instanceof Rectangle[]){
                        Rectangle[] areas = (Rectangle[])highlight;
                        for(int i=0; i!=areas.length; i++){
                          storageVector.addElement(areas[i]);
                        }
                      }
                      //decode_pdf.addToHighlightAreas(decode_pdf, storageVector, currentPage);
//                    }
                  }
                }
                storageVector.trim();
                showAllOnPage = storageVector.get();
                decode_pdf.getTextLines().addHighlights(showAllOnPage, true, currentPage);
               
              }else{

                Object highlight= textRectangles.get(key);
View Full Code Here

TOP

Related Classes of org.jpedal.utils.repositories.Vector_Rectangle

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.