use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.
the class ChartDesignWriterTest method writeConfiguration_chartHasRadialGradientBackgroundColor_theRadialGradientIsWrittenAsElement.
@Test
public void writeConfiguration_chartHasRadialGradientBackgroundColor_theRadialGradientIsWrittenAsElement() {
Configuration configuration = new Configuration();
DesignContext designContext = new DesignContext();
GradientColor gradientColor = GradientColor.createRadial(0.5, 0.3, 0.7);
gradientColor.addColorStop(0, new SolidColor("black"));
gradientColor.addColorStop(1, new SolidColor("white"));
configuration.getChart().setBackgroundColor(gradientColor);
Element parent = new Element(Tag.valueOf("test"), "");
ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
assertEquals("<chart><background-color><radial-gradient cx=\"0.5\" cy=\"0.3\" r=\"0.7\"></radial-gradient>" + "<stops position=\"0\" color=\"black\"></stops>" + "<stops position=\"1\" color=\"white\"></stops>" + "</background-color></chart>", removeWhitespacesBetweenTags(parent.child(0).toString()));
}
use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.
the class ColorFactoryTests method create_noColorInStops_DesignExceptionIsThrown.
@Test(expected = DesignException.class)
public void create_noColorInStops_DesignExceptionIsThrown() {
Element element = createColorElement("<background-color><linear-gradient x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"></linear-gradient>" + "<stops position=\"0\"></stops>" + "<stops position=\"1\" color=\"black\"></stops>" + "</background-color>");
GradientColor color = ColorFactory.createGradient(element);
}
use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.
the class ColorFactoryTests method create_linearColor_colorIsCreatedWithCorrectParametersAndStops.
@Test
public void create_linearColor_colorIsCreatedWithCorrectParametersAndStops() {
Element element = createColorElement("<background-color><linear-gradient x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"></linear-gradient>" + "<stops position=\"0\" color=\"white\"></stops>" + "<stops position=\"1\" color=\"black\"></stops>" + "</background-color>");
GradientColor color = ColorFactory.createGradient(element);
assertNotNull(color.getLinearGradient());
assertNull(color.getRadialGradient());
assertEquals(0d, color.getLinearGradient().getX1());
assertEquals(0d, color.getLinearGradient().getY1());
assertEquals(1d, color.getLinearGradient().getX2());
assertEquals(1d, color.getLinearGradient().getY2());
}
use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.
the class ColorFactoryTests method create_doubleNotParsable_DesignExceptionIsThrown.
@Test(expected = DesignException.class)
public void create_doubleNotParsable_DesignExceptionIsThrown() {
Element element = createColorElement("<background-color><linear-gradient x1=\"abc\" y1=\"0\" x2=\"1\" y2=\"1\"></linear-gradient>" + "<stops position=\"0\" color=\"white\"></stops>" + "<stops position=\"1\" color=\"black\"></stops>" + "</background-color>");
GradientColor color = ColorFactory.createGradient(element);
}
Aggregations