Search in sources :

Example 1 with TimePeriodModel

use of com.serotonin.m2m2.web.mvc.rest.v1.model.dataPoint.TimePeriodModel in project ma-modules-public by infiniteautomation.

the class ChartRendererFactory method createModel.

/**
 * @param vo
 * @return
 */
public static BaseChartRendererModel<?> createModel(DataPointVO vo) {
    ChartRenderer renderer = vo.getChartRenderer();
    if (renderer == null)
        return null;
    if (renderer.getTypeName().equals(ImageChartRenderer.getDefinition().getName())) {
        ImageChartRenderer r = (ImageChartRenderer) renderer;
        TimePeriodModel tp = new TimePeriodModel(r.getNumberOfPeriods(), r.getTimePeriod());
        ImageChartRendererModel model = new ImageChartRendererModel(tp);
        return model;
    } else if (renderer.getTypeName().equals(ImageFlipbookRenderer.getDefinition().getName())) {
        ImageFlipbookRenderer r = (ImageFlipbookRenderer) renderer;
        ImageFlipbookChartRendererModel model = new ImageFlipbookChartRendererModel(r.getLimit());
        return model;
    } else if (renderer.getTypeName().equals(StatisticsChartRenderer.getDefinition().getName())) {
        StatisticsChartRenderer r = (StatisticsChartRenderer) renderer;
        TimePeriodModel tp = new TimePeriodModel(r.getNumberOfPeriods(), r.getTimePeriod());
        StatisticsChartRendererModel model = new StatisticsChartRendererModel(tp, r.isIncludeSum());
        return model;
    } else if (renderer.getTypeName().equals(TableChartRenderer.getDefinition().getName())) {
        TableChartRenderer r = (TableChartRenderer) renderer;
        TableChartRendererModel model = new TableChartRendererModel(r.getLimit());
        return model;
    } else {
        throw new ShouldNeverHappenException("Unknown Chart Renderer: " + renderer.getDef().getName());
    }
}
Also used : TableChartRenderer(com.serotonin.m2m2.view.chart.TableChartRenderer) StatisticsChartRenderer(com.serotonin.m2m2.view.chart.StatisticsChartRenderer) ImageFlipbookRenderer(com.serotonin.m2m2.view.chart.ImageFlipbookRenderer) ShouldNeverHappenException(com.serotonin.ShouldNeverHappenException) ImageChartRenderer(com.serotonin.m2m2.view.chart.ImageChartRenderer) TimePeriodModel(com.serotonin.m2m2.web.mvc.rest.v1.model.dataPoint.TimePeriodModel) StatisticsChartRenderer(com.serotonin.m2m2.view.chart.StatisticsChartRenderer) ImageChartRenderer(com.serotonin.m2m2.view.chart.ImageChartRenderer) ChartRenderer(com.serotonin.m2m2.view.chart.ChartRenderer) TableChartRenderer(com.serotonin.m2m2.view.chart.TableChartRenderer)

Aggregations

ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)1 ChartRenderer (com.serotonin.m2m2.view.chart.ChartRenderer)1 ImageChartRenderer (com.serotonin.m2m2.view.chart.ImageChartRenderer)1 ImageFlipbookRenderer (com.serotonin.m2m2.view.chart.ImageFlipbookRenderer)1 StatisticsChartRenderer (com.serotonin.m2m2.view.chart.StatisticsChartRenderer)1 TableChartRenderer (com.serotonin.m2m2.view.chart.TableChartRenderer)1 TimePeriodModel (com.serotonin.m2m2.web.mvc.rest.v1.model.dataPoint.TimePeriodModel)1