Class ContrastResult
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a single contrast analysis result entry between text and a background element. -
Constructor Summary
ConstructorsConstructorDescriptionContrastResult(TextColorInfo textRenderInfo, int pageNumber) Constructs a newContrastResultfor the specified text element. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContrastResult(ContrastResult.OverlappingArea overlappingArea) Adds a background contrast entry to this result.Gets all the background contrast entries for this text element.intGets the page number where the text element is located.Gets the text render information for this contrast result.
-
Constructor Details
-
ContrastResult
Constructs a newContrastResultfor the specified text element.The result is initialized with an empty list of background entries, which should be populated using
addContrastResult(OverlappingArea).- Parameters:
-
textRenderInfo- the text element for which contrast is being analyzed -
pageNumber- the page number where the text element is located
-
-
Method Details
-
getPageNumber
public int getPageNumber()Gets the page number where the text element is located.- Returns:
- the page number
-
getTextRenderInfo
Gets the text render information for this contrast result.The text information includes the character, parent text, color, geometric path, and font size of the text element being analyzed.
- Returns:
- the text render information
-
addContrastResult
Adds a background contrast entry to this result.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.
- Parameters:
-
overlappingArea- the contrast result entry containing background information and contrast ratio
-
getOverlappingAreas
Gets all the background contrast entries for this text element.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.
- Returns:
- an unmodifiable view of the list of contrast result entries
-