com.ge.research.charts.tooltips
Class AbstractTooltipGenerator

java.lang.Object
  extended bycom.ge.research.charts.tooltips.AbstractTooltipGenerator
Direct Known Subclasses:
CategoryTooltipGenerator, HighLowTooltipGenerator, PieTooltipGenerator, XYTooltipGenerator

public abstract class AbstractTooltipGenerator
extends java.lang.Object

An abstract tooltip generator, that produces a tooltip for each datapoint within a chart. The tooltip string should be computed for each datapoint, however the created string needs not be different for each point. The tooltip string is defined for an entire chart, with placeholders for series name, category/domain name/value, and point/range values, that can be filled in for each datapoint.

Version:
$Revision: 1.1 $ $Date: 2006/08/11 00:17:42 $
Author:
garbiras

Field Summary
static int CURRENCYSTYLE
          Constant used by NumberFormat factory methods to specify a style of format for currency numbers
static java.text.SimpleDateFormat DEFAULT_DATE_FORMAT
          The default date format to use when displaying date values as strings
static java.text.DecimalFormat DEFAULT_ITEM_LABEL_NUMBER_FORMAT
          The default number format style to use when displaying item lable numbers as strings
static java.text.DecimalFormat DEFAULT_ITEM_VALUE_NUMBER_FORMAT
          The default number format style to use when displaying item value numbers as strings
static java.lang.String DEFAULT_TOOLTIP
          The default tooltip string to use
static int INTEGERSTYLE
          Constant used by NumberFormat factory methods to specify a style of format for integers
static java.lang.String ITEM_LABEL_PLACEHOLDER
          The tooltip placeholder, marking where to insert the category name or domain label/value, within the tooltip string
static java.lang.String ITEM_VALUE_PLACEHOLDER
          The tooltip placeholder, marking where to insert the category/range value, within the tooltip string
static int NUMBERSTYLE
          Constant used by NumberFormat factory methods to specify a style of format for general numbers
static int PERCENTSTYLE
          Constant used by NumberFormat factory methods to specify a style of format for percent numbers
static java.lang.String SERIES_NAME_PLACEHOLDER
          The tooltip placeholder, marking where to insert the value of the series name, within the tooltip string
 
Constructor Summary
AbstractTooltipGenerator()
           
 
Method Summary
 java.lang.String generateToolTip(java.lang.String seriesName, java.lang.Object item, java.lang.Object value)
          Constructs the tooltip for a datapoint, using the tooltip string format as well as the various applicable date and number formaters.
 java.text.SimpleDateFormat getDateFormat()
          Returns the SimpleDateFormat object to be applied to Date data values within the chart.
 java.lang.String getDateFormatString()
          Returns the string representation of the date format pattern to be applied to Date data values within the chart.
 java.text.NumberFormat getItemLabelNumberFormat()
          Returns the NumberFormat object to be applied to Number item label values within the chart.
 java.lang.String getItemLabelNumberFormatString()
          Returns the string representation of the number format pattern to be applied to Number item label values within the chart.
 java.text.NumberFormat getItemValueNumberFormat()
          Returns the NumberFormat object to be applied to Number datapoint values within the chart.
 java.lang.String getItemValueNumberFormatString()
          Returns the string representation of the number format pattern to be applied to Number datapoint values within the chart.
protected  java.lang.String getStringValue(java.lang.Comparable c)
          Returns the string representation of the Comparable argument object.
 java.lang.String getTooltipStr()
          Returns the tooltip string to be used for displaying information about the datapoints of a chart.
 void setDateFormat(java.lang.String string)
          Sets the date format pattern to apply to Date data values within the chart.
 void setItemLabelNumberFormat(java.text.DecimalFormat format)
          Sets the item label NumberFormat to apply to Number item label values within the chart.
 void setItemLabelNumberFormat(int style)
          Sets the item label NumberFormat to apply to Number item label values within the chart.
 void setItemValueNumberFormat(java.text.DecimalFormat format)
          Sets the datapoint value NumberFormat to apply to Number datapoint values within the chart.
 void setItemValueNumberFormat(int style)
          Sets the datapoint value NumberFormat to apply to Number datapoint values within the chart.
 void setTooltipStr(java.lang.String string)
          Sets the tooltip string to use for displaying information about the datapoints of a chart.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUMBERSTYLE

public static final int NUMBERSTYLE
Constant used by NumberFormat factory methods to specify a style of format for general numbers

See Also:
Constant Field Values

CURRENCYSTYLE

public static final int CURRENCYSTYLE
Constant used by NumberFormat factory methods to specify a style of format for currency numbers

See Also:
Constant Field Values

PERCENTSTYLE

public static final int PERCENTSTYLE
Constant used by NumberFormat factory methods to specify a style of format for percent numbers

See Also:
Constant Field Values

INTEGERSTYLE

public static final int INTEGERSTYLE
Constant used by NumberFormat factory methods to specify a style of format for integers

See Also:
Constant Field Values

DEFAULT_DATE_FORMAT

public static final java.text.SimpleDateFormat DEFAULT_DATE_FORMAT
The default date format to use when displaying date values as strings


DEFAULT_ITEM_LABEL_NUMBER_FORMAT

public static final java.text.DecimalFormat DEFAULT_ITEM_LABEL_NUMBER_FORMAT
The default number format style to use when displaying item lable numbers as strings


DEFAULT_ITEM_VALUE_NUMBER_FORMAT

public static final java.text.DecimalFormat DEFAULT_ITEM_VALUE_NUMBER_FORMAT
The default number format style to use when displaying item value numbers as strings


SERIES_NAME_PLACEHOLDER

public static final java.lang.String SERIES_NAME_PLACEHOLDER
The tooltip placeholder, marking where to insert the value of the series name, within the tooltip string

See Also:
Constant Field Values

ITEM_LABEL_PLACEHOLDER

public static final java.lang.String ITEM_LABEL_PLACEHOLDER
The tooltip placeholder, marking where to insert the category name or domain label/value, within the tooltip string

See Also:
Constant Field Values

ITEM_VALUE_PLACEHOLDER

public static final java.lang.String ITEM_VALUE_PLACEHOLDER
The tooltip placeholder, marking where to insert the category/range value, within the tooltip string

See Also:
Constant Field Values

DEFAULT_TOOLTIP

public static final java.lang.String DEFAULT_TOOLTIP
The default tooltip string to use

See Also:
Constant Field Values
Constructor Detail

AbstractTooltipGenerator

public AbstractTooltipGenerator()
Method Detail

generateToolTip

public java.lang.String generateToolTip(java.lang.String seriesName,
                                        java.lang.Object item,
                                        java.lang.Object value)
Constructs the tooltip for a datapoint, using the tooltip string format as well as the various applicable date and number formaters.

Parameters:
seriesName - the name of the dataseries the datapoint belongs to
item - the datapoint "place" (category or domain value)
value - the datapoint value
Returns:
The tooltip string to display for the datapoint

getDateFormat

public final java.text.SimpleDateFormat getDateFormat()
Returns the SimpleDateFormat object to be applied to Date data values within the chart.

Returns:
The SimpleDateFormat object to use for Date data values within the chart

getDateFormatString

public final java.lang.String getDateFormatString()
Returns the string representation of the date format pattern to be applied to Date data values within the chart.

Returns:
The string representation of the date format pattern to use for Date data values within the chart

getItemLabelNumberFormat

public final java.text.NumberFormat getItemLabelNumberFormat()
Returns the NumberFormat object to be applied to Number item label values within the chart.

Returns:
The NumberFormat object to use for Number item label values within the chart

getItemLabelNumberFormatString

public final java.lang.String getItemLabelNumberFormatString()
Returns the string representation of the number format pattern to be applied to Number item label values within the chart.

Returns:
The string representation of the number format pattern to use for Number item label values within the chart

getItemValueNumberFormat

public final java.text.NumberFormat getItemValueNumberFormat()
Returns the NumberFormat object to be applied to Number datapoint values within the chart.

Returns:
The NumberFormat object to use for Number datapoint values within the chart

getItemValueNumberFormatString

public final java.lang.String getItemValueNumberFormatString()
Returns the string representation of the number format pattern to be applied to Number datapoint values within the chart.

Returns:
The string representation of the number format pattern to use for Number datapoint values within the chart

getTooltipStr

public final java.lang.String getTooltipStr()
Returns the tooltip string to be used for displaying information about the datapoints of a chart.

Returns:
The tooltip string to be used for displaying information about the datapoints of a chart

setDateFormat

public final void setDateFormat(java.lang.String string)
Sets the date format pattern to apply to Date data values within the chart. If the argument string is null or an invalid date format pattern, then the DEFAULT_DATE_FORMAT pattern is used.

Parameters:
string - the date format pattern to apply to Date data values within the chart
See Also:
DEFAULT_DATE_FORMAT

setItemLabelNumberFormat

public final void setItemLabelNumberFormat(int style)
Sets the item label NumberFormat to apply to Number item label values within the chart. If the argument style is not one of the acceptable style types (of the NumberFormat class), then the DEFAULT_ITEM_LABEL_NUMBER_FORMAT is used.

Parameters:
style - the NumberFormat style to apply to Number item label values within the chart
See Also:
DEFAULT_ITEM_LABEL_NUMBER_FORMAT, NumberFormat.getIntegerInstance(), NumberFormat.getCurrencyInstance(), NumberFormat.getPercentInstance(), NumberFormat.getNumberInstance()

setItemLabelNumberFormat

public final void setItemLabelNumberFormat(java.text.DecimalFormat format)
Sets the item label NumberFormat to apply to Number item label values within the chart. If the argument format is null, then the DEFAULT_ITEM_LABEL_NUMBER_FORMAT is used.

Parameters:
format - the NumberFormat to apply to Number item label values within the chart
See Also:
DEFAULT_ITEM_LABEL_NUMBER_FORMAT

setItemValueNumberFormat

public final void setItemValueNumberFormat(int style)
Sets the datapoint value NumberFormat to apply to Number datapoint values within the chart. If the argument style is not one of the acceptable style types (of the NumberFormat class), then the DEFAULT_ITEM_VALUE_NUMBER_FORMAT is used.

Parameters:
style - the NumberFormat style to apply to Number datapoint values within the chart
See Also:
DEFAULT_ITEM_VALUE_NUMBER_FORMAT, NumberFormat.getIntegerInstance(), NumberFormat.getCurrencyInstance(), NumberFormat.getPercentInstance(), NumberFormat.getNumberInstance()

setItemValueNumberFormat

public final void setItemValueNumberFormat(java.text.DecimalFormat format)
Sets the datapoint value NumberFormat to apply to Number datapoint values within the chart. If the argument format is null, then the DEFAULT_ITEM_VALUE_NUMBER_FORMAT is used.

Parameters:
format - the NumberFormat to apply to Number datapoint values within the chart
See Also:
DEFAULT_ITEM_VALUE_NUMBER_FORMAT

setTooltipStr

public void setTooltipStr(java.lang.String string)
Sets the tooltip string to use for displaying information about the datapoints of a chart. If the argument string is null or StringUtils.EMPTY_STRING, then the tooltip string is set to the DEFAULT_TOOLTIP.

Parameters:
string - the tooltip string to use for displaying information about the datapoints of a chart
See Also:
DEFAULT_TOOLTIP, StringUtils.isNullOrEmpty(java.lang.String)

getStringValue

protected final java.lang.String getStringValue(java.lang.Comparable c)
Returns the string representation of the Comparable argument object. If the Comparable argument object is not of a specific subtype currently able to generate an accurate string representation for, then StringUtils.EMPTY_STRING is returned.

Parameters:
c - the Comparable object to return the string value of
Returns:
The string representation of the Comparable argument object.
See Also:
StringUtils.EMPTY_STRING