RED-5381: Test1: Rotate in TextPositionSequence
This commit is contained in:
parent
69540bcd5e
commit
dafc140f11
@ -54,8 +54,9 @@ public class BlockificationService {
|
||||
|
||||
|| isSplittedByRuling(maxX, minY, word.getX1(), word.getY1(), horizontalRulingLines)
|
||||
|| isSplittedByRuling(minX, minY, word.getX1(), word.getY2(), verticalRulingLines);
|
||||
boolean splitByDir = prev != null && !prev.getDir().equals(word.getDir());
|
||||
|
||||
if (prev != null && (lineSeparation || startFromTop || splitByX || newLineAfterSplit || splittedByRuling)) {
|
||||
if (prev != null && (lineSeparation || startFromTop || splitByX || newLineAfterSplit || splittedByRuling || splitByDir)) {
|
||||
|
||||
Orientation prevOrientation = null;
|
||||
if (!chunkBlockList1.isEmpty()) {
|
||||
|
||||
@ -147,29 +147,6 @@ public class TextPositionSequence implements CharSequence {
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
@JsonAttribute(ignore = true)
|
||||
public float getX1() {
|
||||
|
||||
if (rotation == 90) {
|
||||
return textPositions.get(0).getYDirAdj() - getTextHeight();
|
||||
} else {
|
||||
return textPositions.get(0).getXDirAdj();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
@JsonAttribute(ignore = true)
|
||||
public float getX2() {
|
||||
|
||||
if (rotation == 90) {
|
||||
return textPositions.get(0).getYDirAdj();
|
||||
} else {
|
||||
return textPositions.get(textPositions.size() - 1).getXDirAdj() + textPositions.get(textPositions.size() - 1).getWidthDirAdj() + HEIGHT_PADDING;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
@JsonAttribute(ignore = true)
|
||||
@ -179,13 +156,72 @@ public class TextPositionSequence implements CharSequence {
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
@JsonAttribute(ignore = true)
|
||||
public float getX1() {
|
||||
|
||||
if (getDir().getDegrees() == 90) {
|
||||
return textPositions.get(0).getYDirAdj() - getTextHeight();
|
||||
}
|
||||
else if (getDir().getDegrees() == 180) {
|
||||
return pageWidth - textPositions.get(textPositions.size() - 1).getXDirAdj() - textPositions.get(textPositions.size() - 1).getWidthDirAdj() - HEIGHT_PADDING;
|
||||
|
||||
}
|
||||
else if (getDir().getDegrees() == 270) {
|
||||
|
||||
return pageWidth - textPositions.get(0).getYDirAdj() ;
|
||||
}
|
||||
else {
|
||||
return textPositions.get(0).getXDirAdj();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
@JsonAttribute(ignore = true)
|
||||
public float getX2() {
|
||||
|
||||
if (getDir().getDegrees() == 90) {
|
||||
return textPositions.get(0).getYDirAdj();
|
||||
}
|
||||
|
||||
else if (getDir().getDegrees() == 180) {
|
||||
return pageWidth - textPositions.get(0).getXDirAdj() ;
|
||||
}
|
||||
|
||||
else if (getDir().getDegrees() == 270) {
|
||||
return pageWidth - textPositions.get(0).getYDirAdj() + getTextHeight();
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
return textPositions.get(textPositions.size() - 1).getXDirAdj() + textPositions.get(textPositions.size() - 1).getWidthDirAdj() + HEIGHT_PADDING;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
@JsonAttribute(ignore = true)
|
||||
public float getY1() {
|
||||
|
||||
if (rotation == 90) {
|
||||
if (getDir().getDegrees() == 90 ) {
|
||||
return textPositions.get(0).getXDirAdj();
|
||||
} else {
|
||||
}
|
||||
|
||||
else if (getDir().getDegrees() == 180) {
|
||||
return textPositions.get(0).getYDirAdj() - getTextHeight();
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if (getDir().getDegrees() == 270) {
|
||||
return pageHeight - textPositions.get(textPositions.size() - 1).getXDirAdj() - getTextHeight() + HEIGHT_PADDING;
|
||||
|
||||
}
|
||||
else {
|
||||
return pageHeight - textPositions.get(0).getYDirAdj();
|
||||
}
|
||||
}
|
||||
@ -195,14 +231,26 @@ public class TextPositionSequence implements CharSequence {
|
||||
@JsonAttribute(ignore = true)
|
||||
public float getY2() {
|
||||
|
||||
if (rotation == 90) {
|
||||
if (getDir().getDegrees() == 90) {
|
||||
return textPositions.get(textPositions.size() - 1).getXDirAdj() + getTextHeight() - HEIGHT_PADDING;
|
||||
} else {
|
||||
}
|
||||
|
||||
else if (getDir().getDegrees() == 180 ) {
|
||||
|
||||
return textPositions.get(0).getYDirAdj();
|
||||
}
|
||||
|
||||
else if (getDir().getDegrees() == 270 ) {
|
||||
return pageHeight - textPositions.get(0).getXDirAdj();
|
||||
}
|
||||
|
||||
else {
|
||||
return pageHeight - textPositions.get(0).getYDirAdj() + getTextHeight();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
@JsonAttribute(ignore = true)
|
||||
public float getTextHeight() {
|
||||
|
||||
@ -98,11 +98,27 @@ public class PdfVisualisationService {
|
||||
contentStream.beginText();
|
||||
|
||||
contentStream.setNonStrokingColor(Color.BLUE);
|
||||
contentStream.setFont(PDType1Font.TIMES_ROMAN, 12f);
|
||||
contentStream.setFont(PDType1Font.TIMES_ROMAN, 2f);
|
||||
|
||||
contentStream.newLineAtOffset(textBlock.getMinX(), textBlock.getMaxY() + 10);
|
||||
contentStream.showText(textBlock.getClassification() + textBlock.getOrientation() + "-->" + textBlock.getSequences().get(0).getDir());
|
||||
contentStream.endText();
|
||||
contentStream.beginText();
|
||||
contentStream.newLineAtOffset(textBlock.getMinX(), textBlock.getMinY());
|
||||
contentStream.showText("MinX,MinY");
|
||||
contentStream.endText();
|
||||
contentStream.beginText();
|
||||
contentStream.newLineAtOffset(textBlock.getMaxX(), textBlock.getMinY());
|
||||
contentStream.showText("MaxX,MinY");
|
||||
contentStream.endText();
|
||||
contentStream.beginText();
|
||||
contentStream.newLineAtOffset(textBlock.getMinX(), textBlock.getMaxY());
|
||||
contentStream.showText("MinX,MaxY");
|
||||
contentStream.endText();
|
||||
contentStream.beginText();
|
||||
contentStream.newLineAtOffset(textBlock.getMaxX(), textBlock.getMaxY());
|
||||
contentStream.showText("MaxX,MaxY");
|
||||
|
||||
contentStream.showText(textBlock.getClassification() + textBlock.getOrientation());
|
||||
|
||||
contentStream.endText();
|
||||
}
|
||||
|
||||
@ -1168,7 +1168,7 @@ public class RedactionIntegrationTest {
|
||||
|
||||
System.out.println("classificationTest");
|
||||
|
||||
AnalyzeRequest request = prepareStorage("files/Metolachlor/S-Metolachlor_RAR_01_Volume_1_2018-09-06.pdf");
|
||||
AnalyzeRequest request = prepareStorage("files/new/RotateTestFile.pdf");
|
||||
|
||||
RedactionRequest redactionRequest = RedactionRequest.builder()
|
||||
.dossierId(request.getDossierId())
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user