Search in sources :

Example 1 with AbstractPlotOptions

use of com.vaadin.addon.charts.model.AbstractPlotOptions in project charts by vaadin.

the class ConfigurationTest method getPlotOptions_getAfterChartCreation_EmptyCollectionReturned.

@Test
public void getPlotOptions_getAfterChartCreation_EmptyCollectionReturned() {
    Chart chart = new Chart();
    Collection<AbstractPlotOptions> result = chart.getConfiguration().getPlotOptions();
    assertEquals(0, result.size());
}
Also used : AbstractPlotOptions(com.vaadin.addon.charts.model.AbstractPlotOptions) Chart(com.vaadin.addon.charts.Chart) Test(org.junit.Test)

Example 2 with AbstractPlotOptions

use of com.vaadin.addon.charts.model.AbstractPlotOptions in project charts by vaadin.

the class ConfigurationTest method getPlotOptionsForType_noPlotOptionFound_ReturnNull.

@Test
public void getPlotOptionsForType_noPlotOptionFound_ReturnNull() {
    Chart chart = new Chart();
    AbstractPlotOptions result = chart.getConfiguration().getPlotOptions(ChartType.LINE);
    assertNull(result);
}
Also used : AbstractPlotOptions(com.vaadin.addon.charts.model.AbstractPlotOptions) Chart(com.vaadin.addon.charts.Chart) Test(org.junit.Test)

Example 3 with AbstractPlotOptions

use of com.vaadin.addon.charts.model.AbstractPlotOptions in project charts by vaadin.

the class ConfigurationTest method getPlotOptionsForType_PlotOptionsLineIsCreated_ReturnTheLinePlotOptions.

@Test
public void getPlotOptionsForType_PlotOptionsLineIsCreated_ReturnTheLinePlotOptions() {
    Chart chart = new Chart();
    PlotOptionsLine expected = new PlotOptionsLine();
    chart.getConfiguration().setPlotOptions(expected);
    AbstractPlotOptions result = chart.getConfiguration().getPlotOptions(ChartType.LINE);
    assertEquals(expected, result);
}
Also used : PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) AbstractPlotOptions(com.vaadin.addon.charts.model.AbstractPlotOptions) Chart(com.vaadin.addon.charts.Chart) Test(org.junit.Test)

Example 4 with AbstractPlotOptions

use of com.vaadin.addon.charts.model.AbstractPlotOptions in project charts by vaadin.

the class ChartDesignReader method createPlotOptionsFor.

private static AbstractPlotOptions createPlotOptionsFor(String type) {
    String plotOptionsClassName = "com.vaadin.addon.charts.model.PlotOptions" + toClassName(type);
    try {
        Class<?> plotOptionsClass = Class.forName(plotOptionsClassName);
        Object plotOptions = plotOptionsClass.newInstance();
        return (AbstractPlotOptions) plotOptions;
    } catch (ClassNotFoundException e) {
        throw new DesignException("Cannot find plot options class: " + plotOptionsClassName);
    } catch (InstantiationException e) {
        throw new DesignException("Cannot create options class: " + plotOptionsClassName);
    } catch (IllegalAccessException e) {
        throw new DesignException("Cannot create options class: " + plotOptionsClassName);
    }
}
Also used : DesignException(com.vaadin.ui.declarative.DesignException) AbstractPlotOptions(com.vaadin.addon.charts.model.AbstractPlotOptions) AbstractConfigurationObject(com.vaadin.addon.charts.model.AbstractConfigurationObject)

Aggregations

AbstractPlotOptions (com.vaadin.addon.charts.model.AbstractPlotOptions)4 Chart (com.vaadin.addon.charts.Chart)3 Test (org.junit.Test)3 AbstractConfigurationObject (com.vaadin.addon.charts.model.AbstractConfigurationObject)1 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)1 DesignException (com.vaadin.ui.declarative.DesignException)1