public class ContrastResult extends Object
This class encapsulates all the contrast information for a text element, including the text itself and a list of all background elements that it overlaps with, along with their respective contrast ratios.
Each text element may have multiple background elements behind it, especially in complex PDF layouts. This class collects all such relationships to provide a comprehensive view of the text's contrast characteristics for accessibility analysis.
| Modifier and Type | Class and Description |
|---|---|
static class |
ContrastResult.OverlappingArea
Represents a single contrast analysis result entry between text and a background element.
|
| Constructor and Description |
|---|
ContrastResult(TextColorInfo textRenderInfo,
int pageNumber)
Constructs a new
ContrastResult for the specified text element. |
| Modifier and Type | Method and Description |
|---|---|
void |
addContrastResult(ContrastResult.OverlappingArea overlappingArea)
Adds a background contrast entry to this result.
|
List<ContrastResult.OverlappingArea> |
getOverlappingAreas()
Gets all the background contrast entries for this text element.
|
int |
getPageNumber()
Gets the page number where the text element is located.
|
TextColorInfo |
getTextRenderInfo()
Gets the text render information for this contrast result.
|
public ContrastResult(TextColorInfo textRenderInfo, int pageNumber)
ContrastResult for the specified text element.
The result is initialized with an empty list of background entries, which should
be populated using addContrastResult(OverlappingArea).
textRenderInfo - the text element for which contrast is being analyzedpageNumber - the page number where the text element is locatedpublic int getPageNumber()
public TextColorInfo getTextRenderInfo()
The text information includes the character, parent text, color, geometric path, and font size of the text element being analyzed.
public void addContrastResult(ContrastResult.OverlappingArea overlappingArea)
Each entry represents a background element that the text overlaps with, along with the calculated contrast ratio between the text color and background color. Multiple entries indicate that the text appears over multiple backgrounds.
overlappingArea - the contrast result entry containing background information and contrast ratiopublic List<ContrastResult.OverlappingArea> getOverlappingAreas()
Each entry in the list represents a background element that the text overlaps with, containing the background's color, path, and the calculated contrast ratio. The list may be empty if no backgrounds were detected, or may contain multiple entries if the text overlaps multiple background elements.
Copyright © 1998–2026 Apryse Group NV. All rights reserved.