org.silverpeas.chart
Class AbstractChartItem<DATA_TYPE>

java.lang.Object
  extended by org.silverpeas.chart.AbstractChartItem<DATA_TYPE>
All Implemented Interfaces:
ChartItem
Direct Known Subclasses:
AbstractAxisChartItem, PieChartItem

public abstract class AbstractChartItem<DATA_TYPE>
extends Object
implements ChartItem

Author:
Yohann Chastagnier

Constructor Summary
AbstractChartItem()
           
 
Method Summary
<T extends AbstractChartItem<DATA_TYPE>>
T
addExtra(String key, Object value)
          Adds an extra information associated to the chart, but not necessary for the chart rendering.
 String asJson()
          Gets the json representation of the item.
protected abstract  void computeDataAsJson(org.json.JSONObject itemAsJson)
          Computes the data of the item into a JSON representation.
 Object getExtra(String key)
          Gets the value of an information associated to the chart, but not necessary for the chart rendering.
 String getTitle()
          Gets the label of the item.
<T extends AbstractChartItem<DATA_TYPE>>
T
withTitle(String title)
          Sets the title that defines the item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractChartItem

public AbstractChartItem()
Method Detail

getTitle

public String getTitle()
Description copied from interface: ChartItem
Gets the label of the item.

Specified by:
getTitle in interface ChartItem
Returns:
a string representation of the label that defines the item, empty if no label.

addExtra

public <T extends AbstractChartItem<DATA_TYPE>> T addExtra(String key,
                                                           Object value)
Adds an extra information associated to the chart, but not necessary for the chart rendering. Useful to provide data from a treatment to an other one.

Type Parameters:
T -
Parameters:
key - the key at which the given information is registered.
value - the value registered.
Returns:
the instance of the chart itself.

getExtra

public Object getExtra(String key)
Gets the value of an information associated to the chart, but not necessary for the chart rendering. Useful to provide data from a treatment to an other one.

Parameters:
key - the ket at which the extra data is registered.
Returns:
the extra data as it has been registered.

withTitle

public <T extends AbstractChartItem<DATA_TYPE>> T withTitle(String title)
Sets the title that defines the item.

Type Parameters:
T -
Parameters:
title - a title as string.
Returns:
the instance of the chart itself.

asJson

public final String asJson()
Gets the json representation of the item.

Specified by:
asJson in interface ChartItem
Returns:
a string that represents the item as a json array.

computeDataAsJson

protected abstract void computeDataAsJson(org.json.JSONObject itemAsJson)
Computes the data of the item into a JSON representation.



Copyright © 2016 Silverpeas. All Rights Reserved.