RED-4129: Fixed imported redactions annotations intersection calculation
This commit is contained in:
parent
2301849815
commit
363f0d7f12
@ -76,7 +76,8 @@ public class ImportedRedactionService {
|
|||||||
var importedRedactionsOnPage = importedRedactions.getImportedRedactions().get(rectangle.getPage());
|
var importedRedactionsOnPage = importedRedactions.getImportedRedactions().get(rectangle.getPage());
|
||||||
for (ImportedRedaction importedRedaction : importedRedactionsOnPage) {
|
for (ImportedRedaction importedRedaction : importedRedactionsOnPage) {
|
||||||
for (Rectangle importedRedactionPosition : importedRedaction.getPositions()) {
|
for (Rectangle importedRedactionPosition : importedRedaction.getPositions()) {
|
||||||
if (rectOverlap(normalizedRectangle, normalize(importedRedactionPosition))) {
|
var normalizedImportedRedactionPos = normalize(importedRedactionPosition);
|
||||||
|
if (rectOverlap(normalizedRectangle, normalizedImportedRedactionPos)) {
|
||||||
if (redactionLogEntry.getImportedRedactionIntersections() == null) {
|
if (redactionLogEntry.getImportedRedactionIntersections() == null) {
|
||||||
redactionLogEntry.setImportedRedactionIntersections(new HashSet<>());
|
redactionLogEntry.setImportedRedactionIntersections(new HashSet<>());
|
||||||
}
|
}
|
||||||
@ -109,13 +110,18 @@ public class ImportedRedactionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean contains(Rectangle rect, Rectangle other) {
|
||||||
|
return rect.getPage() == other.getPage() && rect.getTopLeft().getX() <= other.getTopLeft().getX() && rect.getTopLeft().getX() + rect.getWidth() >= other.getTopLeft().getX() + other.getWidth() && rect.getTopLeft().getY() <= other.getTopLeft().getY() && rect.getTopLeft().getY() + rect.getHeight() >= other.getTopLeft().getY() + other.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private Rectangle normalize(Rectangle rectangle) {
|
private Rectangle normalize(Rectangle rectangle) {
|
||||||
|
|
||||||
Rectangle r = new Rectangle();
|
Rectangle r = new Rectangle();
|
||||||
Point p = new Point();
|
Point p = new Point();
|
||||||
|
|
||||||
if (rectangle.getWidth() < 0) {
|
if (rectangle.getWidth() < 0) {
|
||||||
p.setX(rectangle.getTopLeft().getX() - rectangle.getWidth());
|
p.setX(rectangle.getTopLeft().getX() + rectangle.getWidth());
|
||||||
r.setWidth(Math.abs(rectangle.getWidth()));
|
r.setWidth(Math.abs(rectangle.getWidth()));
|
||||||
} else {
|
} else {
|
||||||
p.setX(rectangle.getTopLeft().getX());
|
p.setX(rectangle.getTopLeft().getX());
|
||||||
@ -127,6 +133,7 @@ public class ImportedRedactionService {
|
|||||||
r.setHeight(Math.abs(rectangle.getHeight()));
|
r.setHeight(Math.abs(rectangle.getHeight()));
|
||||||
} else {
|
} else {
|
||||||
p.setY(rectangle.getTopLeft().getY());
|
p.setY(rectangle.getTopLeft().getY());
|
||||||
|
r.setHeight(rectangle.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
r.setTopLeft(p);
|
r.setTopLeft(p);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user