Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into GH-311.fraction.sca…
Browse files Browse the repository at this point in the history
…ling.compensation
  • Loading branch information
Patrick Corless committed Nov 25, 2023
2 parents 2dc9bca + 50c8d60 commit 3f933da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,14 @@ public int print(Graphics printGraphics, PageFormat pageFormat, int pageIndex) {
Dimension dim = pageDim.toDimension();
Rectangle2D.Float rect = new Rectangle2D.Float(0, 0, dim.width, dim.height);
List<Annotation> annotations = currentPage.getAnnotations();
for (Annotation annot : annotations) {
Rectangle2D.union(
rect,
annot.calculatePageSpaceRectangle(currentPage, Page.BOUNDARY_MEDIABOX, rotation, zoomFactor),
rect);
if (annotations != null) {
for (Annotation annot : annotations) {
Rectangle2D.union(
rect,
annot.calculatePageSpaceRectangle(currentPage, Page.BOUNDARY_MEDIABOX, rotation,
zoomFactor),
rect);
}
}

// Get location of imageable area from PageFormat object
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package org.icepdf.ri.common.views;

import org.icepdf.core.pobjects.*;
import org.icepdf.core.pobjects.Catalog;
import org.icepdf.core.pobjects.Destination;
import org.icepdf.core.pobjects.NameTree;
import org.icepdf.core.pobjects.Page;
import org.icepdf.core.pobjects.PageTree;
import org.icepdf.core.pobjects.Reference;
import org.icepdf.core.pobjects.annotations.Annotation;
import org.icepdf.core.pobjects.annotations.ChoiceWidgetAnnotation;
import org.icepdf.core.pobjects.annotations.FreeTextAnnotation;
Expand Down Expand Up @@ -43,7 +48,7 @@ public class PageViewComponentImpl extends AbstractPageViewComponent implements
// annotations component for this pageViewComp.
protected final Object annotationComponentsLock = new Object();
protected ArrayList<AbstractAnnotationComponent> annotationComponents;
protected Map<Annotation, AnnotationComponent> annotationToComponent;
protected Map<Reference, AnnotationComponent> annotationToComponent;
protected ArrayList<DestinationComponent> destinationComponents;
private Set<SearchHitComponent> searchHitComponents = new HashSet<>();

Expand Down Expand Up @@ -230,7 +235,7 @@ public AnnotationComponent getComponentFor(Annotation annot) {
if (annotationToComponent == null) {
initializeAnnotationsComponent(getPage());
}
return annotationToComponent.get(annot);
return annotationToComponent.get(annot.getPObjectReference());
}

/**
Expand Down Expand Up @@ -440,7 +445,7 @@ public void addAnnotation(AnnotationComponent annotation) {
annotationToComponent = new HashMap<>();
}
annotationComponents.add((AbstractAnnotationComponent) annotation);
annotationToComponent.put(annotation.getAnnotation(), annotation);
annotationToComponent.put(annotation.getAnnotation().getPObjectReference(), annotation);
if (annotation instanceof PopupAnnotationComponent) {
addPopupAnnotationComponent((PopupAnnotationComponent) annotation);
} else if (annotation instanceof MarkupAnnotationComponent) {
Expand All @@ -463,7 +468,7 @@ public void addAnnotation(AnnotationComponent annotation) {
public void removeAnnotation(AnnotationComponent annotationComp) {
annotationComponents.remove(annotationComp);
if (annotationComp.getAnnotation() != null) {
annotationToComponent.remove(annotationComp.getAnnotation());
annotationToComponent.remove(annotationComp.getAnnotation().getPObjectReference());
} else {
annotationToComponent.entrySet().stream().filter(e -> e.getValue().equals(annotationComp)).findFirst()
.ifPresent(e -> annotationToComponent.remove(e.getKey()));
Expand Down Expand Up @@ -560,7 +565,7 @@ private void initializeAnnotationsComponent(Page page) {
if (comp != null) {
// add for painting
annotationComponents.add(comp);
annotationToComponent.put(annotation, comp);
annotationToComponent.put(annotation.getPObjectReference(), comp);
// add to layout
if (comp instanceof PopupAnnotationComponent) {
PopupAnnotationComponent popupAnnotationComponent = (PopupAnnotationComponent) comp;
Expand Down

0 comments on commit 3f933da

Please sign in to comment.