org.silverpeas.chart
Class AbstractChart<CHART_ITEM_TYPE extends ChartItem>

java.lang.Object
  extended by org.silverpeas.chart.AbstractChart<CHART_ITEM_TYPE>
All Implemented Interfaces:
Chart<CHART_ITEM_TYPE>
Direct Known Subclasses:
AbstractAxisChart, PieChart

public abstract class AbstractChart<CHART_ITEM_TYPE extends ChartItem>
extends Object
implements Chart<CHART_ITEM_TYPE>

Common implementation between each chart.

Author:
Yohann Chastagnier

Constructor Summary
AbstractChart()
           
 
Method Summary
protected
<T extends AbstractChart<CHART_ITEM_TYPE>>
T
add(CHART_ITEM_TYPE item)
          Adds an item into the list of chart items.
<T extends AbstractChart<CHART_ITEM_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 data list as a json array.
protected  void computeExtraDataAsJson(org.json.JSONObject jsonChart)
          Overriding this method if necessary.
 Object getExtra(String key)
          Gets the value of an information associated to the chart, but not necessary for the chart rendering.
 List<CHART_ITEM_TYPE> getItems()
          Gets all items that constitutes the chart.
 String getTitle()
          Gets the title of the chart.
<T extends AbstractChart<CHART_ITEM_TYPE>>
T
withTitle(String title)
          Sets the title of the chart.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.silverpeas.chart.Chart
getType
 

Constructor Detail

AbstractChart

public AbstractChart()
Method Detail

getTitle

public String getTitle()
Description copied from interface: Chart
Gets the title of the chart.

Specified by:
getTitle in interface Chart<CHART_ITEM_TYPE extends ChartItem>
Returns:
the title of the chart.

addExtra

public <T extends AbstractChart<CHART_ITEM_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 final <T extends AbstractChart<CHART_ITEM_TYPE>> T withTitle(String title)
Sets the title of the chart.

Parameters:
title - the title of the chart.
Returns:
the instance of the chart itself.

asJson

public final String asJson()
Description copied from interface: Chart
Gets data list as a json array.

Specified by:
asJson in interface Chart<CHART_ITEM_TYPE extends ChartItem>
Returns:
a string that represents a json array.

computeExtraDataAsJson

protected void computeExtraDataAsJson(org.json.JSONObject jsonChart)
Overriding this method if necessary.

Parameters:
jsonChart - the json object that represents the chart.

getItems

public final List<CHART_ITEM_TYPE> getItems()
Description copied from interface: Chart
Gets all items that constitutes the chart.

Specified by:
getItems in interface Chart<CHART_ITEM_TYPE extends ChartItem>
Returns:
a list of data where each data represents a chart part.

add

protected <T extends AbstractChart<CHART_ITEM_TYPE>> T add(CHART_ITEM_TYPE item)
Adds an item into the list of chart items.

Type Parameters:
T -
Parameters:
item - the chart item to add.
Returns:
the instance of the chart itself.


Copyright © 2016 Silverpeas. All Rights Reserved.