Class XMLChartStyle

java.lang.Object
net.simplace.ui.jfreechart.AbstractChartStyle
net.simplace.ui.jfreechart.style.XMLChartStyle
All Implemented Interfaces:
ChartStyle

public class XMLChartStyle extends AbstractChartStyle
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/false if the chart shall be stacked. Makes sense only for area, bar and time series (as area) charts.
  • style/@stepped - (optional) true/false if the chart shall be stepped. Makes sense only for area and time series (as area) charts.
  • style/@d3 - (optional) true/false if the chart shall be visualised in 3D (bar charts only; currently ignored).
  • style/@orientation - (optional) vertical/horizontal.
  • style/@legend - (optional) true if the legend shall be generated.
  • style/@tooltips - (optional) true if the tooltips shall be generated.
  • style/@urls - (optional) true if the URLs (image map) shall be generated.
  • style/@timeSeriesAsArea - (optional) true to draw a time series chart as area chart.
  • style/@recommendedDataset - (optional) dataset type, see getRecommendedDataset().
  • title/@localise - (optional) true if the text of the title element is a key in the locale bundle (see TitleDef).
Author:
Martin Uhlir
  • Field Details

    • iStyleElement

      protected org.jdom2.Element iStyleElement
      Style (from XML definition) used for this instance XMLChartStyle
    • iChart

      protected org.jfree.chart.JFreeChart iChart
      JFreeChart created from the style definition and dataset
    • iStyleId

      protected String iStyleId
      Id of the style
    • iTitle

      protected String iTitle
      Chart title
    • iDomainAxisLabel

      protected String iDomainAxisLabel
      Label on the domain (X) axis
    • iRangeAxisLabel

      protected String iRangeAxisLabel
      Label on the range (Y) axis
    • iOrientation

      protected org.jfree.chart.plot.PlotOrientation iOrientation
      Orientation of the chart
    • iLegend

      protected boolean iLegend
      Stores whether a legend is generated for the chart (Default: true).
    • iTooltips

      protected boolean iTooltips
      Stores whether tooltips are generated for the chart data (Default: true).
    • iURLs

      protected boolean iURLs
      Stores whether URLs are generated for the chart (Default: true).
    • iChartType

      protected ChartStyle.ChartType 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 element
      aObservable - provides the parameters and the system id for the titles, may be null
      Throws:
      ChartStyleException - is thrown if any error (improper values, missing required values, ...) Occurs when trying to create instance of this class
      IllegalArgumentException - is thrown if aStyleElement is null or has improper element name or missing required attribute id
  • Method Details

    • getRecommendedDataset

      public XMLChartStyle.RecommendedDataset getRecommendedDataset()
      Gets recommended dataset for given type of chart: the attribute recommendedDataset or, if not defined, the default of the chart type.
      Returns:
      recommended dataset for given type of chart
    • applyToDataset

      public org.jfree.chart.JFreeChart applyToDataset(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.
      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 are null
      UnsupportedOperationException - if the dataset does not fit the chart type
    • getTitle

      public String getTitle()
      Description copied from class: AbstractChartStyle
      Returns the title for the chart.
      Specified by:
      getTitle in interface ChartStyle
      Overrides:
      getTitle in class AbstractChartStyle
      Returns:
      the (localised) chart title, null if not defined
    • setTitle

      public void setTitle(String aTitle)
      Sets the chart title and the text of the element chart/title.
      Specified by:
      setTitle in interface ChartStyle
      Overrides:
      setTitle in class AbstractChartStyle
      Parameters:
      aTitle - the new title; null is ignored
    • getType

      public ChartStyle.ChartType getType()
      Description copied from interface: ChartStyle
      Returns the type of the chart style.
      Specified by:
      getType in interface ChartStyle
      Overrides:
      getType in class AbstractChartStyle
      Returns:
      the chart type from the attribute type
    • getXAxisTitle

      public String getXAxisTitle()
      Description copied from class: AbstractChartStyle
      Returns the title for the chart's x-axis.
      Specified by:
      getXAxisTitle in interface ChartStyle
      Overrides:
      getXAxisTitle in class AbstractChartStyle
      Returns:
      the label of the horizontal axis: the domain axis label for vertical, the range axis label for horizontal orientation
    • getYAxisTitle

      public String getYAxisTitle()
      Description copied from class: AbstractChartStyle
      Returns the title for the chart's y-axis.
      Specified by:
      getYAxisTitle in interface ChartStyle
      Overrides:
      getYAxisTitle in class AbstractChartStyle
      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: AbstractChartStyle
      Returns whether the chart is configured to generate a legend.
      Specified by:
      hasLegend in interface ChartStyle
      Overrides:
      hasLegend in class AbstractChartStyle
      Returns:
      true if the attribute legend is true
    • hasTooltips

      public boolean hasTooltips()
      Description copied from class: AbstractChartStyle
      Returns whether the chart is configured to generate tooltips for the data.
      Specified by:
      hasTooltips in interface ChartStyle
      Overrides:
      hasTooltips in class AbstractChartStyle
      Returns:
      true if the attribute tooltips is true
    • hasURLs

      public boolean hasURLs()
      Description copied from class: AbstractChartStyle
      Returns whether the chart is configured to generate URLs.
      Specified by:
      hasURLs in interface ChartStyle
      Overrides:
      hasURLs in class AbstractChartStyle
      Returns:
      true if the attribute urls is true