Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into GH-314.redaction
Browse files Browse the repository at this point in the history
# Conflicts:
#	viewer/viewer-awt/src/main/java/org/icepdf/ri/common/tools/TextSelectionPageHandler.java
#	viewer/viewer-awt/src/main/java/org/icepdf/ri/common/views/annotations/TextMarkupAnnotationComponent.java
  • Loading branch information
Patrick Corless committed Feb 5, 2024
2 parents f3b43bc + eea10fc commit 348671d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public String getHexString() {
* <p>Gets a hexadecimal StringBuffer representation of this object's data,
* which is in fact the raw data contained in this object.</p>
*
* @return a StringBufffer representation of the objects data in hexadecimal.
* @return a StringBuffer representation of the objects data in hexadecimal.
*/
public StringBuilder getHexStringBuffer() {
return stringData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected PageViewComponentImpl isOverPageComponent(Container container, MouseEv
if (comp instanceof PageViewComponentImpl) {
return (PageViewComponentImpl) comp;
} else if (comp instanceof MarkupGlueComponent) {
comp = comp.getParent();
comp = ((MarkupGlueComponent) comp).getMarkupAnnotationComponent().getPageViewComponent();
if (comp instanceof PageViewComponentImpl) return (PageViewComponentImpl) comp;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,7 @@ public void setParentPageComponent(AbstractPageViewComponent pageViewComponent)
parentPageViewComponent = pageViewComponent;
}

public MarkupAnnotationComponent getMarkupAnnotationComponent() {
return markupAnnotationComponent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import org.icepdf.core.pobjects.annotations.TextMarkupAnnotation;
import org.icepdf.ri.common.views.AbstractPageViewComponent;
import org.icepdf.ri.common.views.DocumentViewController;
import org.icepdf.ri.common.views.DocumentViewModel;

import java.awt.*;
import java.awt.geom.AffineTransform;
import java.util.logging.Logger;

/**
Expand All @@ -45,6 +47,33 @@ public void resetAppearanceShapes() {
annotation.resetAppearanceStream(getToPageSpaceTransform());
}

@Override
public boolean contains(int x, int y) {
// avoid interference if text selection tool is selected
int toolMode = documentViewController.getDocumentViewModel().getViewToolMode();
if (toolMode == DocumentViewModel.DISPLAY_TOOL_TEXT_SELECTION) return false;

boolean contains = super.contains(x, y);
if (contains && annotation != null && annotation.getMarkupPath() != null) {
// page space
AffineTransform pageTransform = getPageSpaceTransform();
shape = annotation.getMarkupPath().createTransformedShape(pageTransform);

// offset for annotation space
Rectangle compBounds = getBounds();
AffineTransform af = new AffineTransform(1, 0, 0, 1, -compBounds.x, -compBounds.y);
shape = af.createTransformedShape(shape);
Rectangle rect = shape.getBounds();

// bail if the markup shape and comp bounds don't line up at all
if (!rect.intersects(new Rectangle(0, 0, compBounds.width, compBounds.height))) {
return true;
}
return rect.contains(x, y);
}
return contains;
}

Shape shape;

public void paintComponent(Graphics g) {
Expand Down

0 comments on commit 348671d

Please sign in to comment.