Search in sources :

Example 36 with XmlObject

use of org.apache.xmlbeans.XmlObject in project ocvn by devgateway.

the class XSSFAreaChartData method createNewSerie.

@Override
protected CustomChartSeries createNewSerie(final int id, final int order, final ChartDataSource<?> categories, final ChartDataSource<? extends Number> values) {
    return new AbstractSeries(id, order, categories, values) {

        @Override
        public void addToChart(final XmlObject ctChart) {
            final CTAreaChart ctAreaChart = (CTAreaChart) ctChart;
            final CTAreaSer ctAreaSer = ctAreaChart.addNewSer();
            ctAreaSer.addNewIdx().setVal(this.id);
            ctAreaSer.addNewOrder().setVal(this.order);
            final CTAxDataSource catDS = ctAreaSer.addNewCat();
            XSSFChartUtil.buildAxDataSource(catDS, this.categories);
            final CTNumDataSource valueDS = ctAreaSer.addNewVal();
            XSSFChartUtil.buildNumDataSource(valueDS, this.values);
            if (isTitleSet()) {
                ctAreaSer.setTx(getCTSerTx());
            }
        }
    };
}
Also used : CTNumDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource) CTAreaChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaChart) CTAreaSer(org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaSer) XmlObject(org.apache.xmlbeans.XmlObject) CTAxDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource)

Example 37 with XmlObject

use of org.apache.xmlbeans.XmlObject in project ocvn by devgateway.

the class XSSFBubbleChartData method createNewSerie.

@Override
protected CustomChartSeries createNewSerie(final int id, final int order, final ChartDataSource<?> categories, final ChartDataSource<? extends Number> values) {
    return new AbstractSeries(id, order, categories, values) {

        @Override
        public void addToChart(final XmlObject ctChart) {
            final CTBubbleChart ctBubbleChart = (CTBubbleChart) ctChart;
            final CTBubbleSer bubbleSer = ctBubbleChart.addNewSer();
            bubbleSer.addNewIdx().setVal(this.id);
            bubbleSer.addNewOrder().setVal(this.order);
            final CTAxDataSource catDS = bubbleSer.addNewXVal();
            XSSFChartUtil.buildAxDataSource(catDS, this.categories);
            final CTNumDataSource valueDS = bubbleSer.addNewBubbleSize();
            XSSFChartUtil.buildNumDataSource(valueDS, this.values);
            if (isTitleSet()) {
                bubbleSer.setTx(getCTSerTx());
            }
        }
    };
}
Also used : CTBubbleSer(org.openxmlformats.schemas.drawingml.x2006.chart.CTBubbleSer) CTNumDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource) XmlObject(org.apache.xmlbeans.XmlObject) CTBubbleChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTBubbleChart) CTAxDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource)

Example 38 with XmlObject

use of org.apache.xmlbeans.XmlObject in project oc-explorer by devgateway.

the class XSSFBubbleChartData method createNewSerie.

@Override
protected CustomChartSeries createNewSerie(final int id, final int order, final ChartDataSource<?> categories, final ChartDataSource<? extends Number> values) {
    return new AbstractSeries(id, order, categories, values) {

        @Override
        public void addToChart(final XmlObject ctChart) {
            final CTBubbleChart ctBubbleChart = (CTBubbleChart) ctChart;
            final CTBubbleSer bubbleSer = ctBubbleChart.addNewSer();
            bubbleSer.addNewIdx().setVal(this.id);
            bubbleSer.addNewOrder().setVal(this.order);
            final CTAxDataSource catDS = bubbleSer.addNewXVal();
            XSSFChartUtil.buildAxDataSource(catDS, this.categories);
            final CTNumDataSource valueDS = bubbleSer.addNewBubbleSize();
            XSSFChartUtil.buildNumDataSource(valueDS, this.values);
            if (isTitleSet()) {
                bubbleSer.setTx(getCTSerTx());
            }
        }
    };
}
Also used : CTBubbleSer(org.openxmlformats.schemas.drawingml.x2006.chart.CTBubbleSer) CTNumDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource) XmlObject(org.apache.xmlbeans.XmlObject) CTBubbleChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTBubbleChart) CTAxDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource)

Example 39 with XmlObject

use of org.apache.xmlbeans.XmlObject in project knime-core by knime.

the class PMMLRuleTranslator method findFirst.

/**
 * Finds the first xml {@link SimpleRule} within the {@code rule} {@link CompoundRule}.
 *
 * @param rule A {@link CompoundRule}.
 * @return The first {@link SimpleRule} the should provide the outcome.
 */
private SimpleRule findFirst(final CompoundRule rule) {
    XmlCursor newCursor = rule.newCursor();
    if (newCursor.toFirstChild()) {
        do {
            XmlObject object = newCursor.getObject();
            if (object instanceof SimpleRuleDocument.SimpleRule) {
                SimpleRuleDocument.SimpleRule sr = (SimpleRuleDocument.SimpleRule) object;
                return sr;
            }
            if (object instanceof CompoundRule) {
                CompoundRule cp = (CompoundRule) object;
                SimpleRule first = findFirst(cp);
                if (first != null) {
                    return first;
                }
            }
        } while (newCursor.toNextSibling());
    }
    assert false : rule;
    return null;
}
Also used : CompoundRule(org.dmg.pmml.CompoundRuleDocument.CompoundRule) SimpleRule(org.dmg.pmml.SimpleRuleDocument.SimpleRule) SimpleRule(org.dmg.pmml.SimpleRuleDocument.SimpleRule) XmlObject(org.apache.xmlbeans.XmlObject) SimpleRuleDocument(org.dmg.pmml.SimpleRuleDocument) XmlCursor(org.apache.xmlbeans.XmlCursor)

Example 40 with XmlObject

use of org.apache.xmlbeans.XmlObject in project knime-core by knime.

the class PMMLPortObject method addPMMLModelFromHandler.

/**
 * Appends the pmml model of the content handler by invoking its
 * {@link PMMLContentHandler#addPMMLModel(DocumentFragment,
 * PMMLPortObjectSpec)} method.
 * Only {@link PMMLModelType} elements can be added.
 * @param handler PMML content handler
 * @throws SAXException if the pmml model could not be added
 */
@Deprecated
public void addPMMLModelFromHandler(final PMMLContentHandler handler) throws SAXException {
    XmlObject model = null;
    try {
        model = XmlObject.Factory.parse(handler.getPMMLModelFragment(m_spec));
    } catch (Exception e) {
        throw new SAXException(e);
    }
    PMML pmmlXml = m_pmmlDoc.getPMML();
    XmlCursor pmmlCursor = pmmlXml.newCursor();
    pmmlCursor.toEndToken();
    XmlCursor modelCursor = model.newCursor();
    modelCursor.toFirstChild();
    modelCursor.copyXml(pmmlCursor);
    modelCursor.dispose();
    pmmlCursor.dispose();
}
Also used : PMML(org.dmg.pmml.PMMLDocument.PMML) XmlObject(org.apache.xmlbeans.XmlObject) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) XmlCursor(org.apache.xmlbeans.XmlCursor)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)102 XmlCursor (org.apache.xmlbeans.XmlCursor)49 XmlException (org.apache.xmlbeans.XmlException)17 Test (org.junit.Test)14 CTTbl (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)13 CTAxDataSource (org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource)12 CTNumDataSource (org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource)12 DefaultExchange (org.apache.camel.impl.DefaultExchange)10 ArrayList (java.util.ArrayList)9 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)9 CTP (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP)9 CTPicture (org.openxmlformats.schemas.presentationml.x2006.main.CTPicture)7 IOException (java.io.IOException)6 QName (javax.xml.namespace.QName)6 POIXMLException (org.apache.poi.POIXMLException)6 CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)6 CTGroupShape (org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape)6 CTGraphicalObjectFrame (org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame)5 Node (org.w3c.dom.Node)5 CTConnector (org.openxmlformats.schemas.presentationml.x2006.main.CTConnector)4