Package org.silverpeas.core.chart
Class AbstractChart<CHART_ITEM_TYPE extends AbstractChartItem>
- java.lang.Object
-
- org.silverpeas.core.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 AbstractChartItem> extends Object implements Chart<CHART_ITEM_TYPE>
Common implementation between each chart.- Author:
- Yohann Chastagnier
-
-
Constructor Summary
Constructors Constructor Description AbstractChart()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T extends AbstractChart<CHART_ITEM_TYPE>>
Tadd(CHART_ITEM_TYPE item)
Adds an item into the list of chart items.<T extends AbstractChart<CHART_ITEM_TYPE>>
TaddExtra(String key, String 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(JSONCodec.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>>
TwithTitle(String title)
Sets the title of the chart.
-
-
-
Method Detail
-
getTitle
public String getTitle()
Description copied from interface:Chart
Gets the title of the chart.- Specified by:
getTitle
in interfaceChart<CHART_ITEM_TYPE extends AbstractChartItem>
- Returns:
- the title of the chart.
-
addExtra
public <T extends AbstractChart<CHART_ITEM_TYPE>> T addExtra(String key, String 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 interfaceChart<CHART_ITEM_TYPE extends AbstractChartItem>
- Returns:
- a string that represents a json array.
-
computeExtraDataAsJson
protected void computeExtraDataAsJson(JSONCodec.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 interfaceChart<CHART_ITEM_TYPE extends AbstractChartItem>
- 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.
-
-