Pull request #408: RED-4114: Added all missing cases for text rotations
Merge in RED/redaction-service from RED-4114 to master * commit 'dacd7b725d1bcdd17193aaefa045bd9555b8528a': RED-4114: Added all missing cases for text rotations
This commit is contained in:
commit
02a264d586
@ -34,6 +34,7 @@ public class TextPositionSequence implements CharSequence {
|
|||||||
private float x1;
|
private float x1;
|
||||||
private float x2;
|
private float x2;
|
||||||
|
|
||||||
|
|
||||||
public TextPositionSequence(int page) {
|
public TextPositionSequence(int page) {
|
||||||
|
|
||||||
this.page = page;
|
this.page = page;
|
||||||
@ -261,7 +262,8 @@ public class TextPositionSequence implements CharSequence {
|
|||||||
@JsonAttribute(ignore = true)
|
@JsonAttribute(ignore = true)
|
||||||
public Rectangle getRectangle() {
|
public Rectangle getRectangle() {
|
||||||
|
|
||||||
log.debug("Page: '{}', Word: '{}', Rotation: '{}', textRotation {}", page, toString(), textPositions.get(0).getRotation(), textPositions.get(0).getDir());
|
log.debug("Page: '{}', Word: '{}', Rotation: '{}', textRotation {}", page, toString(), textPositions.get(0)
|
||||||
|
.getRotation(), textPositions.get(0).getDir());
|
||||||
|
|
||||||
float height = getTextHeight();
|
float height = getTextHeight();
|
||||||
|
|
||||||
@ -270,26 +272,24 @@ public class TextPositionSequence implements CharSequence {
|
|||||||
float posYInit;
|
float posYInit;
|
||||||
float posYEnd;
|
float posYEnd;
|
||||||
|
|
||||||
if (textPositions.get(0).getRotation() == 90 && textPositions.get(0).getDir() != 0.0f) {
|
if (textPositions.get(0).getRotation() == 0 && textPositions.get(0).getDir() == 90f) {
|
||||||
posXEnd = textPositions.get(0).getYDirAdj() + 2;
|
|
||||||
posYInit = getY1();
|
|
||||||
posYEnd = textPositions.get(textPositions.size() - 1).getXDirAdj() - height + 4;
|
|
||||||
|
|
||||||
} else if (textPositions.get(0).getRotation() == 270 && textPositions.get(0).getDir() == 270.0f) {
|
posYInit = getX1();
|
||||||
posYInit = textPositions.get(0).getPageHeight() - getX1();
|
posYEnd = getX2() + textPositions.get(0).getWidthDirAdj() - textPositions.get(textPositions.size() - 1)
|
||||||
posYEnd = textPositions.get(0).getPageHeight() - getX2() - textPositions.get(0)
|
.getWidthDirAdj() - 3;
|
||||||
.getWidth() - textPositions.get(textPositions.size() - 1).getWidth() - 1;
|
posXInit = textPositions.get(0).getYDirAdj() + 2;
|
||||||
posXInit = textPositions.get(0).getPageWidth() - textPositions.get(0).getYDirAdj() - 2;
|
posXEnd = textPositions.get(textPositions.size() - 1).getYDirAdj() - height;
|
||||||
posXEnd = textPositions.get(0).getPageWidth() - textPositions.get(textPositions.size() - 1)
|
|
||||||
.getYDirAdj() + height;
|
|
||||||
|
|
||||||
} else if (textPositions.get(0).getRotation() == 270 && textPositions.get(0).getDir() == 0.0f) {
|
} else if (textPositions.get(0).getRotation() == 0 && textPositions.get(0).getDir() == 180f) {
|
||||||
posYInit = textPositions.get(0).getPageHeight() - textPositions.get(0).getYDirAdj() - 2;
|
|
||||||
posYEnd = posYInit + 1;
|
posXInit = textPositions.get(0).getPageWidth() - getX1() + 1;
|
||||||
posXInit = textPositions.get(0).getXDirAdj();
|
posXEnd = textPositions.get(0).getPageWidth() - getX2() + textPositions.get(0)
|
||||||
posXEnd = textPositions.get(textPositions.size() - 1).getXDirAdj() + textPositions.get(textPositions.size() - 1).getWidthDirAdj() + 0.1f;
|
.getWidthDirAdj() - textPositions.get(textPositions.size() - 1).getWidthDirAdj() - 3;
|
||||||
|
posYInit = textPositions.get(0).getYDirAdj() - height + 2;
|
||||||
|
posYEnd = textPositions.get(textPositions.size() - 1).getYDirAdj() - height + 2;
|
||||||
|
|
||||||
} else if (textPositions.get(0).getRotation() == 0 && textPositions.get(0).getDir() == 270f) {
|
} else if (textPositions.get(0).getRotation() == 0 && textPositions.get(0).getDir() == 270f) {
|
||||||
|
|
||||||
posYInit = textPositions.get(0).getPageHeight() - getX1();
|
posYInit = textPositions.get(0).getPageHeight() - getX1();
|
||||||
posYEnd = textPositions.get(0).getPageHeight() - getX2() - textPositions.get(0)
|
posYEnd = textPositions.get(0).getPageHeight() - getX2() - textPositions.get(0)
|
||||||
.getWidthDirAdj() - textPositions.get(textPositions.size() - 1).getWidthDirAdj() - 3;
|
.getWidthDirAdj() - textPositions.get(textPositions.size() - 1).getWidthDirAdj() - 3;
|
||||||
@ -298,6 +298,7 @@ public class TextPositionSequence implements CharSequence {
|
|||||||
.getYDirAdj() + height;
|
.getYDirAdj() + height;
|
||||||
|
|
||||||
} else if (textPositions.get(0).getRotation() == 90 && textPositions.get(0).getDir() == 0.0f) {
|
} else if (textPositions.get(0).getRotation() == 90 && textPositions.get(0).getDir() == 0.0f) {
|
||||||
|
|
||||||
posXInit = textPositions.get(textPositions.size() - 1)
|
posXInit = textPositions.get(textPositions.size() - 1)
|
||||||
.getXDirAdj() + textPositions.get(textPositions.size() - 1).getHeightDir();
|
.getXDirAdj() + textPositions.get(textPositions.size() - 1).getHeightDir();
|
||||||
posXEnd = textPositions.get(0).getXDirAdj();
|
posXEnd = textPositions.get(0).getXDirAdj();
|
||||||
@ -305,30 +306,93 @@ public class TextPositionSequence implements CharSequence {
|
|||||||
posYEnd = textPositions.get(0).getPageHeight() - textPositions.get(textPositions.size() - 1)
|
posYEnd = textPositions.get(0).getPageHeight() - textPositions.get(textPositions.size() - 1)
|
||||||
.getYDirAdj() + 2;
|
.getYDirAdj() + 2;
|
||||||
|
|
||||||
} else if (textPositions.get(0).getRotation() == 0 && textPositions.get(0).getDir() == 90f) {
|
} else if (textPositions.get(0).getRotation() == 90 && textPositions.get(0).getDir() == 90.0f) {
|
||||||
|
posXEnd = textPositions.get(0).getYDirAdj() + 2;
|
||||||
|
posYInit = getY1();
|
||||||
|
posYEnd = textPositions.get(textPositions.size() - 1).getXDirAdj() - height + 4;
|
||||||
|
|
||||||
|
} else if (textPositions.get(0).getRotation() == 90 && textPositions.get(0).getDir() == 180.0f) {
|
||||||
|
|
||||||
|
posXInit = textPositions.get(0).getPageWidth() - textPositions.get(textPositions.size() - 1)
|
||||||
|
.getXDirAdj() - 4;
|
||||||
|
posXEnd = textPositions.get(0).getPageWidth() - textPositions.get(0).getXDirAdj();
|
||||||
|
posYInit = textPositions.get(0).getYDirAdj() - 2 - textPositions.get(textPositions.size() - 1)
|
||||||
|
.getHeightDir();
|
||||||
|
posYEnd = textPositions.get(textPositions.size() - 1)
|
||||||
|
.getYDirAdj() - textPositions.get(textPositions.size() - 1).getHeightDir();
|
||||||
|
|
||||||
|
} else if (textPositions.get(0).getRotation() == 90 && textPositions.get(0).getDir() == 270.0f) {
|
||||||
|
|
||||||
|
posXInit = textPositions.get(0).getPageWidth() - getX1();
|
||||||
|
posXEnd = textPositions.get(0).getPageWidth() - textPositions.get(0).getYDirAdj() - 2;
|
||||||
|
posYInit = textPositions.get(0).getPageHeight() - getY1();
|
||||||
|
posYEnd = textPositions.get(0).getPageHeight() - textPositions.get(textPositions.size() - 1)
|
||||||
|
.getXDirAdj() - height - 4;
|
||||||
|
|
||||||
|
} else if (textPositions.get(0).getRotation() == 180 && textPositions.get(0).getDir() == 0f) {
|
||||||
|
|
||||||
|
posXEnd = textPositions.get(textPositions.size() - 1)
|
||||||
|
.getXDirAdj() + textPositions.get(textPositions.size() - 1).getWidthDirAdj() + 1;
|
||||||
|
posYInit = textPositions.get(0).getPageHeight() - textPositions.get(0).getYDirAdj() - 2;
|
||||||
|
posYEnd = textPositions.get(0).getPageHeight() - textPositions.get(textPositions.size() - 1)
|
||||||
|
.getYDirAdj() + 2;
|
||||||
|
|
||||||
|
} else if (textPositions.get(0).getRotation() == 180 && textPositions.get(0).getDir() == 90f) {
|
||||||
|
|
||||||
posYInit = getX1();
|
posYInit = getX1();
|
||||||
posYEnd = getX2() + textPositions.get(0).getWidthDirAdj() - textPositions.get(textPositions.size() - 1)
|
posYEnd = getX2() - 3;
|
||||||
.getWidthDirAdj() - 3;
|
|
||||||
posXInit = textPositions.get(0).getYDirAdj() + 2;
|
posXInit = textPositions.get(0).getYDirAdj() + 2;
|
||||||
posXEnd = textPositions.get(textPositions.size() - 1).getYDirAdj() - height;
|
posXEnd = textPositions.get(textPositions.size() - 1).getYDirAdj() - height;
|
||||||
|
|
||||||
} else if (textPositions.get(0).getRotation() == 180 && textPositions.get(0).getDir() == 180f) {
|
} else if (textPositions.get(0).getRotation() == 180 && textPositions.get(0).getDir() == 180f) {
|
||||||
posXInit = textPositions.get(0).getPageWidth() - getX1() + 1;
|
|
||||||
posXEnd = textPositions.get(0).getPageWidth() - getX2() + textPositions.get(0).getWidthDirAdj() - textPositions.get(textPositions.size() - 1)
|
|
||||||
.getWidthDirAdj() - 3;
|
|
||||||
posYInit = textPositions.get(0).getYDirAdj() - height + 2;
|
|
||||||
posYEnd = textPositions.get(textPositions.size() - 1)
|
|
||||||
.getYDirAdj() - height + 2;
|
|
||||||
|
|
||||||
} else if (textPositions.get(0).getRotation() == 0 && textPositions.get(0).getDir() == 180f) {
|
|
||||||
posXInit = textPositions.get(0).getPageWidth() - getX1() + 1;
|
posXInit = textPositions.get(0).getPageWidth() - getX1() + 1;
|
||||||
posXEnd = textPositions.get(0).getPageWidth() - getX2() + textPositions.get(0).getWidthDirAdj() - textPositions.get(textPositions.size() - 1)
|
posXEnd = textPositions.get(0).getPageWidth() - getX2() + textPositions.get(0)
|
||||||
.getWidthDirAdj() - 3;
|
.getWidthDirAdj() - textPositions.get(textPositions.size() - 1).getWidthDirAdj() - 3;
|
||||||
posYInit = textPositions.get(0).getYDirAdj() - height + 2;
|
posYInit = textPositions.get(0).getYDirAdj() - height + 2;
|
||||||
posYEnd = textPositions.get(textPositions.size() - 1)
|
posYEnd = textPositions.get(textPositions.size() - 1).getYDirAdj() - height + 2;
|
||||||
.getYDirAdj() - height + 2;
|
|
||||||
|
} else if (textPositions.get(0).getRotation() == 180 && textPositions.get(0).getDir() == 270.0f) {
|
||||||
|
|
||||||
|
posYInit = textPositions.get(0).getPageHeight() - getX1();
|
||||||
|
posYEnd = textPositions.get(0).getPageHeight() - getX2() - textPositions.get(0)
|
||||||
|
.getWidthDirAdj() - textPositions.get(textPositions.size() - 1).getWidthDirAdj();
|
||||||
|
posXInit = textPositions.get(0).getPageWidth() - textPositions.get(0).getYDirAdj() - 2;
|
||||||
|
posXEnd = textPositions.get(0).getPageWidth() - textPositions.get(textPositions.size() - 1)
|
||||||
|
.getYDirAdj() + height;
|
||||||
|
|
||||||
|
} else if (textPositions.get(0).getRotation() == 270 && textPositions.get(0).getDir() == 0.0f) {
|
||||||
|
|
||||||
|
posYInit = textPositions.get(0).getPageHeight() - textPositions.get(0).getYDirAdj() - 2;
|
||||||
|
posYEnd = posYInit + 1;
|
||||||
|
posXInit = textPositions.get(0).getXDirAdj();
|
||||||
|
posXEnd = textPositions.get(textPositions.size() - 1)
|
||||||
|
.getXDirAdj() + textPositions.get(textPositions.size() - 1).getWidthDirAdj() + 0.1f;
|
||||||
|
|
||||||
|
} else if (textPositions.get(0).getRotation() == 270 && textPositions.get(0).getDir() == 90.0f) {
|
||||||
|
|
||||||
|
posYInit = getX1();
|
||||||
|
posYEnd = getX2() - height;
|
||||||
|
posXInit = textPositions.get(0).getYDirAdj() + 2;
|
||||||
|
posXEnd = textPositions.get(textPositions.size() - 1).getYDirAdj() - height;
|
||||||
|
|
||||||
|
} else if (textPositions.get(0).getRotation() == 270 && textPositions.get(0).getDir() == 180.0f) {
|
||||||
|
|
||||||
|
posXInit = textPositions.get(0).getPageWidth() - getX1() + 1;
|
||||||
|
posXEnd = textPositions.get(0).getPageWidth() - getX2() - 4;
|
||||||
|
posYInit = textPositions.get(0).getYDirAdj() - height + 2;
|
||||||
|
posYEnd = textPositions.get(textPositions.size() - 1).getYDirAdj() - height + 2;
|
||||||
|
|
||||||
|
} else if (textPositions.get(0).getRotation() == 270 && textPositions.get(0).getDir() == 270.0f) {
|
||||||
|
|
||||||
|
posYInit = textPositions.get(0).getPageHeight() - getX1();
|
||||||
|
posYEnd = textPositions.get(0).getPageHeight() - getX2() - height;
|
||||||
|
posXInit = textPositions.get(0).getPageWidth() - textPositions.get(0).getYDirAdj() - 2;
|
||||||
|
posXEnd = textPositions.get(0).getPageWidth() - textPositions.get(textPositions.size() - 1)
|
||||||
|
.getYDirAdj() + height;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// page rotation = 0 and text direction = 0
|
||||||
posXEnd = textPositions.get(textPositions.size() - 1)
|
posXEnd = textPositions.get(textPositions.size() - 1)
|
||||||
.getXDirAdj() + textPositions.get(textPositions.size() - 1).getWidthDirAdj() + 1;
|
.getXDirAdj() + textPositions.get(textPositions.size() - 1).getWidthDirAdj() + 1;
|
||||||
posYInit = textPositions.get(0).getPageHeight() - textPositions.get(0).getYDirAdj() - 2;
|
posYInit = textPositions.get(0).getPageHeight() - textPositions.get(0).getYDirAdj() - 2;
|
||||||
|
|||||||
@ -813,7 +813,7 @@ public class RedactionIntegrationTest {
|
|||||||
System.out.println("testTableRedaction");
|
System.out.println("testTableRedaction");
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
AnalyzeRequest request = prepareStorage("files/new/RotateTestfile.pdf");
|
AnalyzeRequest request = prepareStorage("files/new/RotateTestFile.pdf");
|
||||||
analyzeService.analyzeDocumentStructure(new StructureAnalyzeRequest(request.getDossierId(), request.getFileId()));
|
analyzeService.analyzeDocumentStructure(new StructureAnalyzeRequest(request.getDossierId(), request.getFileId()));
|
||||||
AnalyzeResult result = analyzeService.analyze(request);
|
AnalyzeResult result = analyzeService.analyze(request);
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ public class AnnotationService {
|
|||||||
annotation.setRectangle(pdRectangle);
|
annotation.setRectangle(pdRectangle);
|
||||||
annotation.setQuadPoints(toQuadPoints(rectangles, mediaBox, cropBox));
|
annotation.setQuadPoints(toQuadPoints(rectangles, mediaBox, cropBox));
|
||||||
if (!redactionLogEntry.isHint()) {
|
if (!redactionLogEntry.isHint()) {
|
||||||
annotation.setContents(createAnnotationContent(redactionLogEntry));
|
annotation.setContents(redactionLogEntry.getValue() + " " +createAnnotationContent(redactionLogEntry));
|
||||||
}
|
}
|
||||||
annotation.setTitlePopup(redactionLogEntry.getId());
|
annotation.setTitlePopup(redactionLogEntry.getId());
|
||||||
annotation.setAnnotationName(redactionLogEntry.getId());
|
annotation.setAnnotationName(redactionLogEntry.getId());
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user