public class ColorScale extends Object implements ColorRule, Comparable
ColorScale colorScale = new ColorScale(new Color[] {Color.WHITE, Color.BLACK, Color.BLUE, Color.GREEN});
Center center = body.addCenter();
center.addSpan("Color Scale Created from White, Black, Blue, & Green");
Table table = center.addTable();
Tr row = table.addRow();
for (int i = 0; i <= 20; i++)
{
float value = i * 0.05f;
HTMLColor scaleColor = new HTMLColor(colorScale.getColor(value));
row.addCell(String.format("%.2f", value)).setStyle(CSS.color(scaleColor.getContrastingColor()) + CSS.bgColor(scaleColor));
}
| 0.00 | 0.05 | 0.10 | 0.15 | 0.20 | 0.25 | 0.30 | 0.35 | 0.40 | 0.45 | 0.50 | 0.55 | 0.60 | 0.65 | 0.70 | 0.75 | 0.80 | 0.85 | 0.90 | 0.95 | 1.00 |
| 0.00 | 0.05 | 0.10 | 0.15 | 0.20 | 0.25 | 0.30 | 0.35 | 0.40 | 0.45 | 0.50 | 0.55 | 0.60 | 0.65 | 0.70 | 0.75 | 0.80 | 0.85 | 0.90 | 0.95 | 1.00 |
| 0.00 | 0.05 | 0.10 | 0.15 | 0.20 | 0.25 | 0.30 | 0.35 | 0.40 | 0.45 | 0.50 | 0.55 | 0.60 | 0.65 | 0.70 | 0.75 | 0.80 | 0.85 | 0.90 | 0.95 | 1.00 |
| Modifier and Type | Field and Description |
|---|---|
static XMLName |
XML_COLOR_SCALE |
| Constructor and Description |
|---|
ColorScale(Color... inColors) |
ColorScale(List<Color> inColors) |
ColorScale(XMLTag inXMLTag) |
| Modifier and Type | Method and Description |
|---|---|
Color |
assignColorForValue(float inValue)
Determines the color that should be assigned to the specified value that
has been normalized to the range of 0 to 1.
|
int |
compareTo(Object inObj2) |
List<HTMLColor> |
getColors() |
XMLTag |
toXMLTag() |
public static final XMLName XML_COLOR_SCALE
public ColorScale(List<Color> inColors)
public ColorScale(Color... inColors)
public ColorScale(XMLTag inXMLTag)
public Color assignColorForValue(float inValue)
assignColorForValue in interface ColorRuleinValue - 0 <= float value >= 1.0public int compareTo(Object inObj2)
compareTo in interface Comparable
jataylor@hairyfatguy.com