Search in sources :

Example 91 with Elements

use of org.jsoup.select.Elements in project charts by vaadin.

the class ChartDesignWriterTest method writeConfiguration_multiplePlotOptions_allPlotOptionsAreChildrenOfPlotOptionsTag.

@Test
public void writeConfiguration_multiplePlotOptions_allPlotOptionsAreChildrenOfPlotOptionsTag() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    PlotOptionsLine plotOptionsLine = new PlotOptionsLine();
    plotOptionsLine.setAnimation(false);
    PlotOptionsSpline plotOptionsSpline = new PlotOptionsSpline();
    plotOptionsSpline.setVisible(false);
    configuration.setPlotOptions(plotOptionsLine, plotOptionsSpline);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    // Expected (the order of plot options is unknown):
    // "<plot-options>
    // <line animation=\"false\">
    // </line>
    // <spline visible=\"false\">
    // </spline>
    // </plot-options>"
    assertEquals("plot-options", parent.child(0).tagName());
    Elements plotOptions = parent.child(0).children();
    assertEquals(2, plotOptions.size());
    assertPlotOptions("line", "animation", "false", plotOptions);
    assertPlotOptions("spline", "visible", "false", plotOptions);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 92 with Elements

use of org.jsoup.select.Elements in project charts by vaadin.

the class ChartDesignReaderTest method readConfiguration_axisTitleHasTextOnlyContent_theContentIsSetAsTitleText.

@Test
public void readConfiguration_axisTitleHasTextOnlyContent_theContentIsSetAsTitleText() {
    Elements elements = createElements("<y-axis><chart-title>my title</chart-title></y-axis>");
    Configuration configuration = new Configuration();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    assertEquals("my title", configuration.getyAxis().getTitle().getText());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 93 with Elements

use of org.jsoup.select.Elements in project charts by vaadin.

the class ChartDesignReaderTest method readConfiguration_multiplePlotOptions_attributesAreReadToCorrectPlotOptions.

@Test
public void readConfiguration_multiplePlotOptions_attributesAreReadToCorrectPlotOptions() {
    Elements elements = createElements("<plot-options>" + "<line animation=\"true\"></line>" + "<spline animation=\"false\"></spline>" + "</plot-options>");
    Configuration configuration = new Configuration();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    PlotOptionsLine line = (PlotOptionsLine) configuration.getPlotOptions(ChartType.LINE);
    PlotOptionsSpline spline = (PlotOptionsSpline) configuration.getPlotOptions(ChartType.SPLINE);
    assertFalse(spline.getAnimation());
    assertTrue(line.getAnimation());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Elements(org.jsoup.select.Elements) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) Test(org.junit.Test)

Example 94 with Elements

use of org.jsoup.select.Elements in project charts by vaadin.

the class ChartDesignReaderTest method readConfiguration_multiplePlotOptions_plotOptionsLineIsAddedToConfiguration.

@Test
public void readConfiguration_multiplePlotOptions_plotOptionsLineIsAddedToConfiguration() {
    Elements elements = createElements("<plot-options><line></line><spline></spline></plot-options>");
    Configuration configuration = new Configuration();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    assertEquals(2, configuration.getPlotOptions().size());
    assertThat(configuration.getPlotOptions(ChartType.LINE), instanceOf(PlotOptionsLine.class));
    assertThat(configuration.getPlotOptions(ChartType.SPLINE), instanceOf(PlotOptionsSpline.class));
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Elements(org.jsoup.select.Elements) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) Test(org.junit.Test)

Example 95 with Elements

use of org.jsoup.select.Elements in project charts by vaadin.

the class ChartDesignReaderTest method readConfiguration_titleWithStyleAsInnerElement_theTitleAndStyleAreInConfiguration.

@Test
public void readConfiguration_titleWithStyleAsInnerElement_theTitleAndStyleAreInConfiguration() {
    Elements elements = createElements("<chart-title text=\"foobar\"><chart-style top=\"12\"></chart-style></chart-title>");
    Configuration configuration = new Configuration();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    assertEquals("12", configuration.getTitle().getStyle().getTop());
    assertEquals("foobar", configuration.getTitle().getText());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Aggregations

Elements (org.jsoup.select.Elements)709 Element (org.jsoup.nodes.Element)490 Document (org.jsoup.nodes.Document)362 ArrayList (java.util.ArrayList)213 IOException (java.io.IOException)151 Test (org.junit.Test)110 URL (java.net.URL)58 List (java.util.List)47 Matcher (java.util.regex.Matcher)42 Pattern (java.util.regex.Pattern)34 HashMap (java.util.HashMap)30 InputStream (java.io.InputStream)29 Jsoup (org.jsoup.Jsoup)28 Configuration (com.vaadin.addon.charts.model.Configuration)27 File (java.io.File)26 JSONObject (org.json.JSONObject)26 JSONException (org.json.JSONException)25 Collectors (java.util.stream.Collectors)23 URISyntaxException (java.net.URISyntaxException)22 BootstrapContext (com.vaadin.flow.server.BootstrapHandler.BootstrapContext)20