1 31 package org.pdfbox.pdfviewer; 32 33 import java.awt.Dimension ; 34 import java.awt.event.MouseEvent ; 35 import java.awt.event.MouseMotionListener ; 36 import java.io.IOException ; 37 38 import javax.swing.JPanel ; 39 40 import org.pdfbox.PDFReader; 41 import org.pdfbox.pdmodel.PDPage; 42 43 49 public class PageWrapper implements MouseMotionListener 50 { 51 private JPanel pageWrapper = new JPanel (); 52 private PDFPagePanel pagePanel = null; 53 private PDFReader reader = null; 54 55 private static final int SPACE_AROUND_DOCUMENT = 20; 56 57 64 public PageWrapper( PDFReader aReader ) throws IOException 65 { 66 reader = aReader; 67 pagePanel = new PDFPagePanel(); 68 pageWrapper.setLayout( null ); 69 pageWrapper.add( pagePanel ); 70 pagePanel.setLocation( SPACE_AROUND_DOCUMENT, SPACE_AROUND_DOCUMENT ); 71 pageWrapper.setBorder( javax.swing.border.LineBorder.createBlackLineBorder() ); 72 pagePanel.addMouseMotionListener( this ); 73 } 74 75 80 public void displayPage( PDPage page ) 81 { 82 pagePanel.setPage( page ); 83 pagePanel.setPreferredSize( pagePanel.getSize() ); 84 Dimension d = pagePanel.getSize(); 85 d.width+=(SPACE_AROUND_DOCUMENT*2); 86 d.height+=(SPACE_AROUND_DOCUMENT*2); 87 88 pageWrapper.setPreferredSize( d ); 89 pageWrapper.validate(); 90 } 91 92 97 public JPanel getPanel() 98 { 99 return pageWrapper; 100 } 101 102 105 public void mouseDragged(MouseEvent e) 106 { 107 } 109 110 113 public void mouseMoved(MouseEvent e) 114 { 115 reader.getBottomStatusPanel().getStatusLabel().setText( e.getX() + "," + e.getY() ); 117 } 118 } | Popular Tags |