Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-272 Improves annotation summary #273

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

gtache
Copy link
Contributor

@gtache gtache commented May 17, 2023

Closes #272
No actual implementation of import/export is available to avoid adding dependencies to the project just for this function.
Need to review / refactor this code given that it was developed 3 years ago.

@pcorless
Copy link
Owner

Do you think it would be possible to refactor the implementation to use RandomAccessFile instead of the wrapper FileSeekableStream?

@pcorless
Copy link
Owner

scrubber_annots.pdf
Here's a very wild test file, lot of annotation and not very well formed which can cause problems with new annoation work.

pcorless
pcorless previously approved these changes Nov 13, 2023
@pcorless
Copy link
Owner

I have a bit more testing to do but will try and get this in this week.

@gtache
Copy link
Contributor Author

gtache commented Jan 29, 2024

I replaced FileSeekableInputStream with BufferedInputStream, it should work without problems.

@pcorless
Copy link
Owner

pcorless commented Feb 1, 2024

Thanks. I was just testing with the file I posted above and I get a null pointer out the yCoordinates map in SummaryController. Is this still a draft pr?

@gtache
Copy link
Contributor Author

gtache commented Jun 12, 2024

I'll fix the NPE and the conflicts and then we should be good to remove the draft status.

@pcorless pcorless marked this pull request as ready for review June 13, 2024 03:02
@pcorless
Copy link
Owner

Seeing a few more stack traces when opening files with annotations.

SEVERE: Error getting /home/pcorless/dev/pdf-qa/annotations/annots/Invoice_text_box. java.nio.file.NoSuchFileException: /home/pcorless/dev/pdf-qa/annotations/annots/Invoice_text_box. at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219) at java.base/java.nio.file.Files.newByteChannel(Files.java:371) at java.base/java.nio.file.Files.newByteChannel(Files.java:422) at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420) at java.base/java.nio.file.Files.newInputStream(Files.java:156) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.mainpanel.SummaryController.getDefaultSummaryInputStream(SummaryController.java:540) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.mainpanel.SummaryController.tryImportSummaryFile(SummaryController.java:511) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.mainpanel.SummaryController.refreshDocumentInstance(SummaryController.java:507) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryFrame.refreshDocumentInstance(AnnotationSummaryFrame.java:75) at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.showAnnotationPreviewWindow(SwingController.java:4255) at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.actionPerformed(SwingController.java:5048) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967) at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308) at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279) at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297) at java.desktop/java.awt.Component.processMouseEvent(Component.java:6635) at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342) at java.desktop/java.awt.Component.processEvent(Component.java:6400) at java.desktop/java.awt.Container.processEvent(Container.java:2263) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

@pcorless
Copy link
Owner

Jun. 12, 2024 9:10:43 P.M. org.icepdf.ri.common.SwingController openDocument
FINE: Error opening document.
java.lang.NullPointerException
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.resetComponentColors(AnnotationSummaryBox.java:158)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.buildGUI(PopupAnnotationComponent.java:397)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.(PopupAnnotationComponent.java:141)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.(AnnotationSummaryBox.java:66)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.createSummaryBox(ColorLabelPanel.java:115)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.addAnnotation(ColorLabelPanel.java:94)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.addAnnotation(ColorLabelPanel.java:143)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.mainpanel.SummaryController$PropertiesListener.propertyChange(SummaryController.java:1179)
at java.desktop/java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:341)
at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:266)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.DocumentViewControllerImpl.firePropertyChange(DocumentViewControllerImpl.java:1301)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.DocumentViewControllerImpl.addNewAnnotation(DocumentViewControllerImpl.java:1336)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.MarkupAnnotationComponent.createPopupAnnotationComponent(MarkupAnnotationComponent.java:171)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.MarkupAnnotationComponent.getPopupAnnotationComponent(MarkupAnnotationComponent.java:108)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.PageViewComponentImpl.initializeAnnotationsComponent(PageViewComponentImpl.java:592)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.PageViewComponentImpl.getComponentFor(PageViewComponentImpl.java:239)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.findAnnotationComponent(PopupAnnotationComponent.java:1081)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.getAnnotationParentComponent(PopupAnnotationComponent.java:520)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.getAnnotationComponent(AnnotationSummaryBox.java:244)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.getColor(AnnotationSummaryBox.java:196)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.resetComponentColors(AnnotationSummaryBox.java:157)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.buildGUI(PopupAnnotationComponent.java:397)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.(PopupAnnotationComponent.java:141)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.(AnnotationSummaryBox.java:66)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.createSummaryBox(ColorLabelPanel.java:115)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.addAnnotation(ColorLabelPanel.java:94)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.addAnnotation(ColorLabelPanel.java:143)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.mainpanel.SummaryController.refreshDocumentInstance(SummaryController.java:496)
at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryFrame.refreshDocumentInstance(AnnotationSummaryFrame.java:75)
at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.commonNewDocumentHandling(SwingController.java:3023)
at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.openDocument(SwingController.java:2564)
at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.openFileInSomeViewer(SwingController.java:2401)
at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.openFile(SwingController.java:2382)
at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.openFile(SwingController.java:2317)
at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.actionPerformed(SwingController.java:4888)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:369)
at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:349)
at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Actions.actionPerformed(BasicMenuItemUI.java:975)
at java.desktop/javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1810)
at java.desktop/javax.swing.JComponent.processKeyBinding(JComponent.java:2900)
at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:699)
at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706)
at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706)
at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706)
at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706)
at java.desktop/javax.swing.JMenuBar.processKeyBinding(JMenuBar.java:677)
at java.desktop/javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:311)
at java.desktop/javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:297)
at java.desktop/javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2993)
at java.desktop/javax.swing.JComponent.processKeyBindings(JComponent.java:2985)
at java.desktop/javax.swing.JComponent.processKeyEvent(JComponent.java:2862)
at java.desktop/java.awt.Component.processEvent(Component.java:6412)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
at java.desktop/java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1950)
at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:870)
at java.desktop/java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1139)
at java.desktop/java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:1009)
at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:835)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4892)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

@gtache
Copy link
Contributor Author

gtache commented Jun 13, 2024

Everything should work now, I didn't think about testing the case when there are no defined labeled colors.

@pcorless
Copy link
Owner

pcorless commented Jun 18, 2024

Getting there. I was doing some testing tonight and I think I found a dispose issue with the summary windows ore maybe a memory leak, not sure exactly. Here are steps to reproduce.
Reopen issue

  1. open scrubber_annots.pdf
  2. sroll through the document, all pages,
  3. open the annotation summary window and close it.
  4. close the document
  5. open the document, crash dialog should appear.

Variation, might be slightly different issue related to page popups potentially not being created yet.

  1. open scrubber in a one page view.
  2. open the preview window, error dialog should show.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve annotation summary
2 participants