Package org.openhab.core.ui.chart
Interface ChartProvider
@NonNullByDefault
public interface ChartProvider
Defines the interface for chart providers. A chart provider interfaces with
the persistence store to get the data and receives parameters from the UI
chart servlet and returns a chart image object (PNG).
- Author:
- Chris Jackson - Initial contribution, Holger Reichert - Support for themes, DPI, legend hiding, Jan N. Klug - add y-axis label formatter
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Provides a list of image types -
Method Summary
Modifier and TypeMethodDescriptioncreateChart
(@Nullable String service, @Nullable String theme, ZonedDateTime startTime, ZonedDateTime endTime, int height, int width, @Nullable String items, @Nullable String groups, @Nullable Integer dpi, @Nullable Boolean legend) Creates a chart object.default BufferedImage
createChart
(@Nullable String service, @Nullable String theme, ZonedDateTime startTime, ZonedDateTime endTime, int height, int width, @Nullable String items, @Nullable String groups, @Nullable Integer dpi, @Nullable String yAxisDecimalPattern, @Nullable Boolean legend) Creates a chart object.Gets the type of data that will be written by the chart.getName()
Gets the name of this chart provider.
-
Method Details
-
getName
String getName()Gets the name of this chart provider.- Returns:
- String containing the provider name
-
createChart
BufferedImage createChart(@Nullable String service, @Nullable String theme, ZonedDateTime startTime, ZonedDateTime endTime, int height, int width, @Nullable String items, @Nullable String groups, @Nullable Integer dpi, @Nullable Boolean legend) throws ItemNotFoundException Creates a chart object. This sets the initial parameters for the chart before the items are added- Parameters:
service
- A string containing the name of the persistence service. May be null in which case the chart provider can decide itself which store to use.theme
- A string containing a theme name for the chart. The provider should store its own themes. May be null to use a default theme.startTime
- The start time of the chartendTime
- The end time of the chartheight
- The height of the chartwidth
- The width of the chartitems
- The items to display on the chartgroups
- The groups to display on the chartdpi
- The DPI (dots per inch) value, can benull
legend
- Show the legend? Ifnull
, the ChartProvider should make his own decision.- Returns:
- BufferedImage object if the chart is rendered correctly, otherwise null.
- Throws:
ItemNotFoundException
- if an item or group is not foundIllegalArgumentException
- if an invalid argument is passed
-
createChart
default BufferedImage createChart(@Nullable String service, @Nullable String theme, ZonedDateTime startTime, ZonedDateTime endTime, int height, int width, @Nullable String items, @Nullable String groups, @Nullable Integer dpi, @Nullable String yAxisDecimalPattern, @Nullable Boolean legend) throws ItemNotFoundException Creates a chart object. This sets the initial parameters for the chart before the items are added- Parameters:
service
- A string containing the name of the persistence service. May be null in which case the chart provider can decide itself which store to use.theme
- A string containing a theme name for the chart. The provider should store its own themes. May be null to use a default theme.startTime
- The start time of the chartendTime
- The end time of the chartheight
- The height of the chartwidth
- The width of the chartitems
- The items to display on the chartgroups
- The groups to display on the chartdpi
- The DPI (dots per inch) value, can benull
yAxisDecimalPattern
- The format pattern for the y-axis labelslegend
- Show the legend? Ifnull
, the ChartProvider should make his own decision.- Returns:
- BufferedImage object if the chart is rendered correctly, otherwise null.
- Throws:
ItemNotFoundException
- if an item or group is not foundIllegalArgumentException
- if an invalid argument is passed
-
getChartType
ChartProvider.ImageType getChartType()Gets the type of data that will be written by the chart.- Returns:
- ImageType
-