2.17.2: 2011-06-17

net.sf.basedb.clients.web.formatter
Class ColorFormatter

java.lang.Object
  extended by net.sf.basedb.clients.web.formatter.ColorFormatter
All Implemented Interfaces:
Formatter<Number>

public class ColorFormatter
extends Object
implements Formatter<Number>

Formatter that adds a small colored box next to a value. The actual value is formatted by the supplied numeric formatter. The color to display is generated by a ColorGenerator. Null or Float NaN values are not colored.

Version:
2.0
Author:
nicklas
Last modified
$Date: 2008-09-11 22:05:50 +0200 (Thu, 11 Sep 2008) $

Field Summary
private  ColorGenerator colorGen
           
private  Formatter<Number> numberFormatter
           
 
Constructor Summary
ColorFormatter(ColorGenerator colorGen, Formatter<Number> numberFormatter)
          Create a new color formatter.
 
Method Summary
 String format(Number value)
          Format a value by converting it to a string.
 Number parseString(String value)
          Parse a string and return a value of the correct type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colorGen

private ColorGenerator colorGen

numberFormatter

private Formatter<Number> numberFormatter
Constructor Detail

ColorFormatter

public ColorFormatter(ColorGenerator colorGen,
                      Formatter<Number> numberFormatter)
Create a new color formatter.

Parameters:
colorGen - The color generator to use for generating colors
numberFormatter - The formatter to use for formatterin the values
Method Detail

format

public String format(Number value)
Description copied from interface: Formatter
Format a value by converting it to a string.

Specified by:
format in interface Formatter<Number>
Parameters:
value - The value to format
Returns:
A formatted string

parseString

public Number parseString(String value)
Description copied from interface: Formatter
Parse a string and return a value of the correct type. A null input string should (unless otherwise documented by a specific formatter implementation) be allowed and may return null or any other "default" value.

Specified by:
parseString in interface Formatter<Number>
Parameters:
value - The string to parse
Returns:
An object

2.17.2: 2011-06-17