public class GradientFormatter extends java.lang.Object implements Formatter
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
highlightBackground |
protected boolean |
highlightForeground |
| Constructor and Description |
|---|
GradientFormatter(float maxScore,
java.lang.String minForegroundColor,
java.lang.String maxForegroundColor,
java.lang.String minBackgroundColor,
java.lang.String maxBackgroundColor)
Sets the color range for the IDF scores
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
getBackgroundColorString(float score) |
protected java.lang.String |
getForegroundColorString(float score) |
static int |
hexToInt(java.lang.String hex)
Converts a hex string into an int.
|
java.lang.String |
highlightTerm(java.lang.String originalText,
TokenGroup tokenGroup) |
protected boolean highlightForeground
protected boolean highlightBackground
public GradientFormatter(float maxScore,
java.lang.String minForegroundColor,
java.lang.String maxForegroundColor,
java.lang.String minBackgroundColor,
java.lang.String maxBackgroundColor)
maxScore - The score (and above) displayed as maxColor (See QueryScorer.getMaxTermWeight()
which can be used to calibrate scoring scale)minForegroundColor - The hex color used for representing IDF scores of zero eg
#FFFFFF (white) or null if no foreground color requiredmaxForegroundColor - The largest hex color used for representing IDF scores eg
#000000 (black) or null if no foreground color requiredminBackgroundColor - The hex color used for representing IDF scores of zero eg
#FFFFFF (white) or null if no background color requiredmaxBackgroundColor - The largest hex color used for representing IDF scores eg
#000000 (black) or null if no background color requiredpublic java.lang.String highlightTerm(java.lang.String originalText,
TokenGroup tokenGroup)
highlightTerm in interface FormatteroriginalText - The section of text being considered for markuptokenGroup - contains one or several overlapping Tokens along with
their scores and positions.protected java.lang.String getForegroundColorString(float score)
protected java.lang.String getBackgroundColorString(float score)
public static final int hexToInt(java.lang.String hex)
hex - A string in capital or lower case hex, of no more then 16
characters.java.lang.NumberFormatException - if the string is more than 16 characters long, or if any
character is not in the set [0-9a-fA-f]Copyright © 2000–2025 The Apache Software Foundation. All rights reserved.