Package org.odftoolkit.odfdom.dom.element.chart

Examples of org.odftoolkit.odfdom.dom.element.chart.ChartChartElement


      // init chart container by searching the embeded document
      mCharts = new HashMap<String, Chart>();
      List<Document> charts = mDocument.getEmbeddedDocuments(Document.OdfMediaType.CHART);
      for (Document chartDoc : charts) {
        OdfContentDom contentDom = chartDoc.getContentDom();
        ChartChartElement chartEle = (ChartChartElement) contentDom.getXPath().evaluate("//chart:chart[1]",
            contentDom, XPathConstants.NODE);
        String documentPath = chartDoc.getDocumentPath();
        mCharts.put(documentPath, new Chart(chartEle, documentPath));
      }
    } catch (Exception ex) {
View Full Code Here


      String sName = mDocument.getDocumentPath() + "/" + title + "_" + System.currentTimeMillis();
      // embed this chart document
      ChartDocument newChartDocument = ChartDocument.newChartDocument();
      mDocument.insertDocument(newChartDocument, sName);
      OdfContentDom contentDom = newChartDocument.getContentDom();
      ChartChartElement chartEle = (ChartChartElement) (contentDom.getXPath().evaluate("//chart:chart[1]",
          contentDom, XPathConstants.NODE));
      Chart chart = new Chart(chartEle, sName);
      chart.setChartTitle(title);
      chart.setChartType(ChartType.BAR);
      chart.setUseLegend(true);
View Full Code Here

  public Chart getChartById(String chartId) {
    try {
      Document embedChartDoc = mDocument.getEmbeddedDocument(chartId);
      if (embedChartDoc != null) {
        OdfContentDom contentDom = embedChartDoc.getContentDom();
        ChartChartElement chartEle = (ChartChartElement) contentDom.getXPath().evaluate("//chart:chart[1]",
            contentDom, XPathConstants.NODE);
        Chart chart = new Chart(chartEle, chartId);
        if (mCharts.get(chartId) != null) {
          return chart;
        }
View Full Code Here

      OdfTextParagraph p0 = (OdfTextParagraph) lst.item(lst.getLength() - 1);

      OfficeDocumentContentElement content = contentDom.newOdfElement(OfficeDocumentContentElement.class);
      OfficeBodyElement body = contentDom.newOdfElement(OfficeBodyElement.class);
      content.appendChild(body);
      ChartChartElement chart = contentDom.newOdfElement(ChartChartElement.class);
      //create children element
      ChartPlotAreaElement plotArea = chart.newChartPlotAreaElement();
      body.appendChild(chart);
      p0.getParentNode().insertBefore(content, p0);


      XPath xpath = contentDom.getXPath();
      ChartChartElement chartTest = (ChartChartElement) xpath.evaluate("//chart:chart[last()]", contentDom, XPathConstants.NODE);

      Assert.assertNotNull(chartTest.getChildNodes());

      Assert.assertTrue(chartTest.getChildNodes().item(0) instanceof ChartPlotAreaElement);
      Assert.assertEquals(plotArea, chartTest.getChildNodes().item(0));
      Assert.assertEquals(chartTest.getChildNodes().item(0).getNodeName(), "chart:plot-area");

      contentDom.getDocument().save(ResourceUtilities.newTestOutputFile("CreatChildrenForChartTest.odt"));

    } catch (Exception e) {
      Logger.getLogger(CreateChildrenElementsTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

   * Child element is mandatory.
   *
   * @return the element {@odf.element chart:chart}
   */
   public ChartChartElement newChartChartElement(String chartClassValue) {
    ChartChartElement chartChart = ((OdfFileDom) this.ownerDocument).newOdfElement(ChartChartElement.class);
    chartChart.setChartClassAttribute(chartClassValue);
    this.appendChild(chartChart);
    return chartChart;
  }
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.chart.ChartChartElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.