public class GradientFormatter extends java.lang.Object implements Formatter
Modifier and Type | Field and Description |
---|---|
(package private) int |
bgBMax |
(package private) int |
bgBMin |
(package private) int |
bgGMax |
(package private) int |
bgGMin |
(package private) int |
bgRMax |
(package private) int |
bgRMin |
(package private) int |
fgBMax |
(package private) int |
fgBMin |
(package private) int |
fgGMax |
(package private) int |
fgGMin |
(package private) int |
fgRMax |
(package private) int |
fgRMin |
private static char[] |
hexDigits |
protected boolean |
highlightBackground |
protected boolean |
highlightForeground |
private float |
maxScore |
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) |
private int |
getColorVal(int colorMin,
int colorMax,
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) |
private static java.lang.String |
intToHex(int i) |
private float maxScore
int fgRMin
int fgGMin
int fgBMin
int fgRMax
int fgGMax
int fgBMax
protected boolean highlightForeground
int bgRMin
int bgGMin
int bgBMin
int bgRMax
int bgGMax
int bgBMax
protected boolean highlightBackground
private static char[] hexDigits
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 Formatter
originalText
- 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)
private int getColorVal(int colorMin, int colorMax, float score)
private static java.lang.String intToHex(int i)
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]