Class XMLChartStyle
java.lang.Object
net.simplace.ui.jfreechart.AbstractChartStyle
net.simplace.ui.jfreechart.style.XMLChartStyle
- All Implemented Interfaces:
ChartStyle
This class represents a style (XML defined) which shall be used for creating a chart.
The style consists of the following components: chart, plot, domain axis, range axis
and renderer which is then applied to the particular dataset.
The structure of the XML style definition is following (in simple):
<style id="" type="" stacked="" stepped="" d3="" orientation="" legend="" tooltips="" urls="">
<chart>
<title localise="true">direct chart title or resource bundle key</title>
<background paint="#ffffe0"/>
<border visible="true"/>
</chart>
<plot>
<!-- detail described in PlotCustomiser -->
</plot>
<domainAxis>
<!-- detail described in AxisCustomiser -->
</domainAxis>
<rangeAxis>
<!-- detail described in AxisCustomiser -->
</rangeAxis>
<renderer>
<!-- detail described in RendererCustomiser -->
</renderer>
</style>
Description:
style/@id- (required) Style id (arbitrary string but unique in the scope of all chart style definitions).style/@type- (required) Type of the chart, one of:area,bar,line,point,pie,gantt,timeseries,spider,array.style/@stacked- (optional)true/falseif the chart shall be stacked. Makes sense only for area, bar and time series (as area) charts.style/@stepped- (optional)true/falseif the chart shall be stepped. Makes sense only for area and time series (as area) charts.style/@d3- (optional)true/falseif the chart shall be visualised in 3D (bar charts only; currently ignored).style/@orientation- (optional)vertical/horizontal.style/@legend- (optional)trueif the legend shall be generated.style/@tooltips- (optional)trueif the tooltips shall be generated.style/@urls- (optional)trueif the URLs (image map) shall be generated.style/@timeSeriesAsArea- (optional)trueto draw a time series chart as area chart.style/@recommendedDataset- (optional) dataset type, seegetRecommendedDataset().title/@localise- (optional)trueif the text of thetitleelement is a key in the locale bundle (seeTitleDef).
- Author:
- Martin Uhlir
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumType of dataset a chart style expects.Nested classes/interfaces inherited from interface ChartStyle
ChartStyle.ChartType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.jfree.chart.JFreeChartJFreeChart created from the style definition and datasetprotected ChartStyle.ChartTypeThe type of the chartprotected StringLabel on the domain (X) axisprotected booleanStores whether a legend is generated for the chart (Default: true).protected org.jfree.chart.plot.PlotOrientationOrientation of the chartprotected StringLabel on the range (Y) axisprotected org.jdom2.ElementStyle (from XML definition) used for this instance XMLChartStyleprotected StringId of the styleprotected StringChart titleprotected booleanStores whether tooltips are generated for the chart data (Default: true).protected booleanStores whether URLs are generated for the chart (Default: true).Fields inherited from class AbstractChartStyle
iObservable, iType, iXAxisTitle, iYAxisTitle -
Constructor Summary
ConstructorsConstructorDescriptionXMLChartStyle(org.jdom2.Element aStyleElement, net.simplace.core.FWObservable aObservable) Constructor which creates chart style based on XML style element. -
Method Summary
Modifier and TypeMethodDescriptionorg.jfree.chart.JFreeChartapplyToDataset(List<org.jfree.data.general.Dataset> aDatasets) Creates the default chart for the chart type and customises chart, axes, plot and renderer according to the style definition.Gets recommended dataset for given type of chart: the attributerecommendedDatasetor, if not defined, the default of the chart type.getTitle()Returns the title for the chart.getType()Returns the type of the chart style.Returns the title for the chart's x-axis.Returns the title for the chart's y-axis.booleanReturns whether the chart is configured to generate a legend.booleanReturns whether the chart is configured to generate tooltips for the data.booleanhasURLs()Returns whether the chart is configured to generate URLs.voidSets the chart title and the text of the elementchart/title.Methods inherited from class AbstractChartStyle
setLegend, setObservable, setTooltips, setType, setURLs, setXAxisTitle, setYAxisTitle
-
Field Details
-
iStyleElement
protected org.jdom2.Element iStyleElementStyle (from XML definition) used for this instance XMLChartStyle -
iChart
protected org.jfree.chart.JFreeChart iChartJFreeChart created from the style definition and dataset -
iStyleId
Id of the style -
iTitle
Chart title -
iDomainAxisLabel
Label on the domain (X) axis -
iRangeAxisLabel
Label on the range (Y) axis -
iOrientation
protected org.jfree.chart.plot.PlotOrientation iOrientationOrientation of the chart -
iLegend
protected boolean iLegendStores whether a legend is generated for the chart (Default: true). -
iTooltips
protected boolean iTooltipsStores whether tooltips are generated for the chart data (Default: true). -
iURLs
protected boolean iURLsStores whether URLs are generated for the chart (Default: true). -
iChartType
The type of the chart
-
-
Constructor Details
-
XMLChartStyle
public XMLChartStyle(org.jdom2.Element aStyleElement, net.simplace.core.FWObservable aObservable) throws ChartStyleException Constructor which creates chart style based on XML style element.- Parameters:
aStyleElement- XML style elementaObservable- provides the parameters and the system id for the titles, may benull- Throws:
ChartStyleException- is thrown if any error (improper values, missing required values, ...) Occurs when trying to create instance of this classIllegalArgumentException- is thrown if aStyleElement is null or has improper element name or missing required attribute id
-
-
Method Details
-
getRecommendedDataset
Gets recommended dataset for given type of chart: the attributerecommendedDatasetor, if not defined, the default of the chart type.- Returns:
- recommended dataset for given type of chart
-
applyToDataset
Creates the default chart for the chart type and customises chart, axes, plot and renderer according to the style definition.- Parameters:
aDatasets- the data for the chart (except for array charts only the first dataset is used)- Returns:
- the chart
- Throws:
IllegalArgumentException- if the datasets arenullUnsupportedOperationException- if the dataset does not fit the chart type
-
getTitle
Description copied from class:AbstractChartStyleReturns the title for the chart.- Specified by:
getTitlein interfaceChartStyle- Overrides:
getTitlein classAbstractChartStyle- Returns:
- the (localised) chart title,
nullif not defined
-
setTitle
Sets the chart title and the text of the elementchart/title.- Specified by:
setTitlein interfaceChartStyle- Overrides:
setTitlein classAbstractChartStyle- Parameters:
aTitle- the new title;nullis ignored
-
getType
Description copied from interface:ChartStyleReturns the type of the chart style.- Specified by:
getTypein interfaceChartStyle- Overrides:
getTypein classAbstractChartStyle- Returns:
- the chart type from the attribute
type
-
getXAxisTitle
Description copied from class:AbstractChartStyleReturns the title for the chart's x-axis.- Specified by:
getXAxisTitlein interfaceChartStyle- Overrides:
getXAxisTitlein classAbstractChartStyle- Returns:
- the label of the horizontal axis: the domain axis label for vertical, the range axis label for horizontal orientation
-
getYAxisTitle
Description copied from class:AbstractChartStyleReturns the title for the chart's y-axis.- Specified by:
getYAxisTitlein interfaceChartStyle- Overrides:
getYAxisTitlein classAbstractChartStyle- Returns:
- the label of the vertical axis: the range axis label for vertical, the domain axis label for horizontal orientation
-
hasLegend
public boolean hasLegend()Description copied from class:AbstractChartStyleReturns whether the chart is configured to generate a legend.- Specified by:
hasLegendin interfaceChartStyle- Overrides:
hasLegendin classAbstractChartStyle- Returns:
trueif the attributelegendistrue
-
hasTooltips
public boolean hasTooltips()Description copied from class:AbstractChartStyleReturns whether the chart is configured to generate tooltips for the data.- Specified by:
hasTooltipsin interfaceChartStyle- Overrides:
hasTooltipsin classAbstractChartStyle- Returns:
trueif the attributetooltipsistrue
-
hasURLs
public boolean hasURLs()Description copied from class:AbstractChartStyleReturns whether the chart is configured to generate URLs.- Specified by:
hasURLsin interfaceChartStyle- Overrides:
hasURLsin classAbstractChartStyle- Returns:
trueif the attributeurlsistrue
-