RED-9975: Fixed missing section numbers in layout grid
This commit is contained in:
parent
0f641670f7
commit
dda5a2c719
@ -88,10 +88,19 @@ public class LayoutGrid extends LayoutGridLayerConfig {
|
|||||||
public void addTreeId(SemanticNode semanticNode) {
|
public void addTreeId(SemanticNode semanticNode) {
|
||||||
|
|
||||||
Page page = semanticNode.getFirstPage();
|
Page page = semanticNode.getFirstPage();
|
||||||
if (semanticNode.getBBox().get(page) == null) {
|
if (semanticNode.getBBox()
|
||||||
|
.get(page) == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addPlacedText(page, semanticNode.getBBox().get(page), semanticNode.getBBox().get(page), buildTreeIdString(semanticNode), 1, treeIds, TREEID_COLOR);
|
addPlacedText(page,
|
||||||
|
semanticNode.getBBox()
|
||||||
|
.get(page),
|
||||||
|
semanticNode.getBBox()
|
||||||
|
.get(page),
|
||||||
|
buildTreeIdString(semanticNode),
|
||||||
|
1,
|
||||||
|
treeIds,
|
||||||
|
TREEID_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -120,7 +129,8 @@ public class LayoutGrid extends LayoutGridLayerConfig {
|
|||||||
.toList();
|
.toList();
|
||||||
Integer maxChildDepth = subSections.stream()
|
Integer maxChildDepth = subSections.stream()
|
||||||
.map(node -> node.getTreeId().size())
|
.map(node -> node.getTreeId().size())
|
||||||
.max(Integer::compareTo).orElse(section.getTreeId().size());
|
.max(Integer::compareTo)
|
||||||
|
.orElse(section.getTreeId().size());
|
||||||
int ownDepth = section.getTreeId().size();
|
int ownDepth = section.getTreeId().size();
|
||||||
|
|
||||||
Page firstPage = section.getFirstPage();
|
Page firstPage = section.getFirstPage();
|
||||||
@ -205,7 +215,8 @@ public class LayoutGrid extends LayoutGridLayerConfig {
|
|||||||
PlacedText newText = PlacedText.textFacingUp(s, upperLeftCorner, FONT_SIZE, color, FONT);
|
PlacedText newText = PlacedText.textFacingUp(s, upperLeftCorner, FONT_SIZE, color, FONT);
|
||||||
float threshold = 1.5f * FONT_SIZE;
|
float threshold = 1.5f * FONT_SIZE;
|
||||||
Optional<PlacedText> conflictingText = placedTexts.stream()
|
Optional<PlacedText> conflictingText = placedTexts.stream()
|
||||||
.filter(pt -> Math.abs(pt.lineStart().getY() - newText.lineStart().getY()) <= threshold || Math.abs(pt.lineStart().getX() - newText.lineStart().getX()) <= threshold)
|
.filter(pt -> Math.abs(pt.lineStart().getY() - newText.lineStart().getY()) <= threshold
|
||||||
|
&& Math.abs(pt.lineStart().getX() - newText.lineStart().getX()) <= threshold)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
if (conflictingText.isPresent()) {
|
if (conflictingText.isPresent()) {
|
||||||
@ -286,7 +297,8 @@ public class LayoutGrid extends LayoutGridLayerConfig {
|
|||||||
|
|
||||||
List<ColoredLine> coloredLines = getOrCreateVisualizationsOnPage(page.getNumber(), sections).getColoredLines();
|
List<ColoredLine> coloredLines = getOrCreateVisualizationsOnPage(page.getNumber(), sections).getColoredLines();
|
||||||
int lineWidthModifier = maxChildDepth - ownDepth;
|
int lineWidthModifier = maxChildDepth - ownDepth;
|
||||||
Rectangle2D r = RectangleTransformations.pad(semanticNode.getBBox().get(page), LINE_WIDTH * (1 + lineWidthModifier), LINE_WIDTH * (1 + lineWidthModifier));
|
Rectangle2D r = RectangleTransformations.pad(semanticNode.getBBox()
|
||||||
|
.get(page), LINE_WIDTH * (1 + lineWidthModifier), LINE_WIDTH * (1 + lineWidthModifier));
|
||||||
|
|
||||||
SemanticNode highestParent = semanticNode.getHighestParent();
|
SemanticNode highestParent = semanticNode.getHighestParent();
|
||||||
Rectangle2D highestParentRect = rectangleMap.get(new RectangleIdentifier(highestParent.getTreeId(), page.getNumber()));
|
Rectangle2D highestParentRect = rectangleMap.get(new RectangleIdentifier(highestParent.getTreeId(), page.getNumber()));
|
||||||
@ -335,7 +347,8 @@ public class LayoutGrid extends LayoutGridLayerConfig {
|
|||||||
List<Double> ys = yStream.collect(Collectors.toList());
|
List<Double> ys = yStream.collect(Collectors.toList());
|
||||||
ys.remove(0);
|
ys.remove(0);
|
||||||
|
|
||||||
Rectangle2D tableBBox = table.getBBox().get(page);
|
Rectangle2D tableBBox = table.getBBox()
|
||||||
|
.get(page);
|
||||||
List<ColoredLine> coloredLines = getOrCreateVisualizationsOnPage(page.getNumber(), tables).getColoredLines();
|
List<ColoredLine> coloredLines = getOrCreateVisualizationsOnPage(page.getNumber(), tables).getColoredLines();
|
||||||
|
|
||||||
xs.forEach(x -> {
|
xs.forEach(x -> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user