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