Class ContrastResult.OverlappingArea
- Enclosing class:
- ContrastResult
This class encapsulates the information about a specific background element that intersects with a text element, along with the calculated contrast ratio between them. It is used as part of a ContrastResult to provide detailed information about all backgrounds that contribute to the overall contrast of a text element.
The contrast ratio is calculated according to WCAG 2.1 guidelines and ranges from 1:1 (no contrast) to 21:1 (maximum contrast between black and white).
-
Constructor Summary
ConstructorsConstructorDescriptionOverlappingArea(BackgroundColorInfo backgroundRenderInfo, double contrastRatio) Constructs a new ContrastResultEntry with the specified background information and contrast ratio. -
Method Summary
Modifier and TypeMethodDescriptionGets the background render information for this contrast entry.doubleGets the contrast ratio between the text and this background element.doubleGets the percentage of the text area that overlaps with this background element.voidsetOverlapRatio(double overlappingAreaInPercentage) Sets the percentage of the text area that overlaps with this background element.
-
Constructor Details
-
OverlappingArea
Constructs a new ContrastResultEntry with the specified background information and contrast ratio.- Parameters:
-
backgroundRenderInfo- the background element that was analyzed for contrast -
contrastRatio- the calculated contrast ratio between the text and this background, according to WCAG 2.1 guidelines (ranges from 1.0 to 21.0)
-
-
Method Details
-
getBackgroundRenderInfo
Gets the background render information for this contrast entry.The background information includes the color and geometric path of the background element that was compared against the text.
- Returns:
- the background render information
-
getContrastRatio
public double getContrastRatio()Gets the contrast ratio between the text and this background element.The contrast ratio is calculated according to WCAG 2.1 guidelines:
*1.0 indicates no contrast (identical colors) *21.0 is the maximum contrast (black and white)
- Returns:
- the contrast ratio value, ranging from 1.0 to 21.0
-
getOverlapRatio
public double getOverlapRatio()Gets the percentage of the text area that overlaps with this background element.- Returns:
- the overlapping area in percentage.
-
setOverlapRatio
public void setOverlapRatio(double overlappingAreaInPercentage) Sets the percentage of the text area that overlaps with this background element. Should be a value between 0 and 1 representing 0% to 100%.- Parameters:
-
overlappingAreaInPercentage- the overlapping area in percentage.
-