Index: pom.xml
===================================================================
--- pom.xml	(revision 0)
+++ pom.xml	(revision 0)
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ *
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>com.xpn.xwiki.platform</groupId>
+    <artifactId>xwiki-core-parent</artifactId>
+    <version>1.9-SNAPSHOT</version>
+  </parent>
+  <groupId>org.xwiki.platform</groupId>
+  <artifactId>xwiki-core-jfreechart</artifactId>
+  <name>XWiki Platform - Core - Chart Generator</name>
+  <packaging>jar</packaging>
+  <description>XWiki Platform - Core - Chart Generator</description>
+  <!-- needed for the jfreechart artifact -->
+  <!-- Temporary removed for speeding up the build process. To be re-enabled soon.
+  <repositories>
+        <repository>
+            <id>Atlassian</id>
+            <name>Atlassian Repository</name>
+            <url>https://maven.atlassian.com/repository/public/</url>
+        </repository>
+  </repositories>
+  -->      
+  <dependencies>
+	<dependency>
+  		<groupId>jfree</groupId>
+  		<artifactId>jfreechart</artifactId>
+  		<version>1.0.11</version>
+	</dependency>
+    <dependency>
+  		<groupId>jfree</groupId>
+  		<artifactId>jcommon</artifactId>
+  		<version>1.0.12</version>
+	</dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <includes>
+            <include>**/RenderingTests.java</include>
+          </includes>
+        </configuration>
+      </plugin>
+      <plugin>
+        <!-- Apply the Checkstyle configurations defined in the top level pom.xml file -->
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+</project>
Index: src/main/java/org/xwiki/chart/ChartGenerator.java
===================================================================
--- src/main/java/org/xwiki/chart/ChartGenerator.java	(revision 0)
+++ src/main/java/org/xwiki/chart/ChartGenerator.java	(revision 0)
@@ -0,0 +1,44 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.chart;
+
+import java.io.File;
+import java.util.Map;
+
+import org.xwiki.chart.source.DataSource;
+
+/**
+ * An interface containing the specifications for the chart generator.
+ * 
+ * @version $Id: $
+ * @since 1.9M1
+ */
+public interface ChartGenerator
+{
+    /**
+     * @return an URL to the generated chart encoded as image file.
+     * @param dataSource the dataSource from which the chart collects the data
+     * @param parameters chart's parameters
+     * @param outputDirectory the directory which will hold the generated chart
+     * @throws ChartGeneratorException in case of an invalid data source
+     */
+    File buildChart(DataSource dataSource, Map<String, Object> parameters, File outputDirectory) 
+        throws ChartGeneratorException;
+}
Index: src/main/java/org/xwiki/chart/ChartGeneratorException.java
===================================================================
--- src/main/java/org/xwiki/chart/ChartGeneratorException.java	(revision 0)
+++ src/main/java/org/xwiki/chart/ChartGeneratorException.java	(revision 0)
@@ -0,0 +1,64 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.chart;
+
+/**
+ * The class used to indicate exceptions specific to the Chart generator.
+ * 
+ * @version $Id: $
+ * @since 1.9M1
+ */
+public class ChartGeneratorException extends Exception
+{
+    /**
+     * Class version.
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Constructs a new exception with the specified message.
+     * 
+     * @param message The explanation of the exception.
+     */
+    public ChartGeneratorException(String message)
+    {
+        super(message);
+    }
+    
+    /**
+     * Constructs a new exception with the specified cause.
+     * 
+     * @param throwable The underlying cause for this exception.
+     */
+    public ChartGeneratorException(Throwable throwable) {
+        super(throwable);
+    }
+
+    /**
+     * Constructs a new exception with the specified message and cause.
+     * 
+     * @param message The explanation of the exception.
+     * @param throwable The underlying cause for this exception.
+     */
+    public ChartGeneratorException(String message, Throwable throwable)
+    {
+        super(message, throwable);
+    }
+}
Index: src/main/java/org/xwiki/chart/internal/DefaultChartGenerator.java
===================================================================
--- src/main/java/org/xwiki/chart/internal/DefaultChartGenerator.java	(revision 0)
+++ src/main/java/org/xwiki/chart/internal/DefaultChartGenerator.java	(revision 0)
@@ -0,0 +1,118 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.chart.internal;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Map;
+import org.xwiki.chart.ChartGenerator;
+import org.xwiki.chart.ChartGeneratorException;
+import org.xwiki.chart.plots.PlotFactory;
+import org.xwiki.chart.source.DataSource;
+import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.Plot;
+
+/**
+ * A class containing the specifications for the chart generator.
+ * 
+ * @version $Id: $
+ * @since 1.9M1
+ */
+public class DefaultChartGenerator implements ChartGenerator
+{
+    /** The chart's width. */
+    private static final String WIDTH = "width";
+    /** The chart's height. */
+    private static final String HEIGHT = "height";
+    /** The series. */
+    private static final String SERIES = "series";
+    /** If the border should be visible or not. */
+    private static final String BORDER_VISIBLE = "border_visible";
+    /** Anti alias feature. */ 
+    private static final String ANTI_ALIAS = "anti_alias";
+    
+    /**
+     * Sets up default values for certain parameters, if they are not provided.
+     * @param parameters the parameter set which the values are to be put into
+     */
+    public void setDefaultValues(Map<String, Object> parameters) {
+        parameters.put(WIDTH, 400);
+        parameters.put(HEIGHT, 300);
+        parameters.put(SERIES, "columns");
+        parameters.put(BORDER_VISIBLE, "false");
+        parameters.put(ANTI_ALIAS, "true");
+    }
+    
+    /**
+     * {@inheritDoc}
+     * @see org.xwiki.chart.ChartGenerator#getImageURL()
+     */
+    @Override
+    public File buildChart(DataSource dataSource, Map<String, Object> parameters, File outputDirectory) 
+        throws ChartGeneratorException
+    {        
+        if (!outputDirectory.isDirectory()) {
+            throw new ChartGeneratorException(outputDirectory.getAbsolutePath() + " is not a directory.");
+        }
+        setDefaultValues(parameters);
+        
+        String type = (String) parameters.get("chartType");
+        Plot plot;
+        
+        String factoryClassName = ChartGenerator.class.getPackage().getName() 
+            + ".plots." + Character.toUpperCase(type.charAt(0))
+            + type.toLowerCase().substring(1) + "PlotFactory";
+
+        PlotFactory factory = null;
+        try {
+            Class factoryClass = Class.forName(factoryClassName);
+            Method method = factoryClass.getMethod("getInstance", new Class[] {});
+            factory = (PlotFactory) method.invoke(null, new Object[] {});
+        } catch (Exception e) {
+            throw new ChartGeneratorException("Could not initialise the plot factory.", e); 
+        }
+        
+        plot = factory.create(dataSource, parameters);
+        
+        JFreeChart jfchart = new JFreeChart(plot);
+        File file = getTempFile(parameters.hashCode() + "." + "png", outputDirectory);
+
+        int width = (Integer) parameters.get(WIDTH);
+        int height = (Integer) parameters.get(HEIGHT);
+        try {
+            ChartUtilities.saveChartAsPNG(file, jfchart, width, height);
+        } catch (Exception e) {
+            throw new ChartGeneratorException("Error saving the chart to disk.", e);
+        }
+
+        return file;
+    }
+
+    /**
+     * @param filename the name of the file to be created
+     * @param outputDirectory the directory in which the file is to be created
+     * @return a temporary file
+     */
+    private File getTempFile(String filename, File outputDirectory)
+    {
+        return new File(outputDirectory, filename);
+    }
+}
\ No newline at end of file
Index: src/main/java/org/xwiki/chart/plots/PiePlotFactory.java
===================================================================
--- src/main/java/org/xwiki/chart/plots/PiePlotFactory.java	(revision 0)
+++ src/main/java/org/xwiki/chart/plots/PiePlotFactory.java	(revision 0)
@@ -0,0 +1,95 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+package org.xwiki.chart.plots;
+
+import java.util.Map;
+
+import org.jfree.chart.plot.PiePlot;
+import org.jfree.chart.plot.Plot;
+import org.jfree.data.general.DefaultPieDataset;
+import org.xwiki.chart.ChartGeneratorException;
+import org.xwiki.chart.source.DataSource;
+
+/**
+ * An implementation for the PlotFactory needed for building a pie chart.
+ * 
+ * @version $Id: $
+ * @since 1.9M1
+ */
+public final class PiePlotFactory implements PlotFactory
+{
+    /** We're dealing with a singleton. */
+    private static PiePlotFactory uniqueInstance = new PiePlotFactory();
+
+    /** Prevents the user from instantiating the class. */
+    private PiePlotFactory()
+    {
+        // empty
+    }
+
+    /** 
+     * Forces the user to use only the unique instance. 
+     * @return the unique instance of this class
+     */
+    public static PiePlotFactory getInstance()
+    {
+        return uniqueInstance;
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see org.xwiki.chart.plots.PlotFactory#create(DataSource, Map)
+     */
+    @Override
+    public Plot create(DataSource dataSource, Map<String, Object> params)
+        throws ChartGeneratorException
+    {
+        final String categoryString = "Category ";
+        
+        DefaultPieDataset dataset = new DefaultPieDataset();
+        String dataSeries = (String) params.get("series");
+        
+        if (dataSeries.equals("columns")) {
+            for (int row = 0; row < dataSource.getRowCount(); row++) {
+                if (dataSource.hasHeaderColumn()) {
+                    String category = dataSource.getHeaderColumnValue(row);
+                    dataset.setValue(category, dataSource.getCell(row, 0));
+                } else {
+                    dataset.setValue(categoryString + (row + 1), dataSource.getCell(row, 0));
+                }
+            }
+        } else if (dataSeries.equals("rows")) {
+            for (int column = 0; column < dataSource.getColumnCount(); column++) {
+                if (dataSource.hasHeaderRow()) {
+                    String category = dataSource.getHeaderRowValue(column);
+                    dataset.setValue(category, dataSource.getCell(0, column));
+                } else {
+                    dataset.setValue(categoryString + (column + 1), dataSource.getCell(0, column));
+                }
+            }
+        } else {
+            throw new ChartGeneratorException("Invalid series parameter:" + dataSeries);
+        }
+
+        PiePlot plot = new PiePlot(dataset);
+        return plot;
+    }
+}
Index: src/main/java/org/xwiki/chart/plots/PlotFactory.java
===================================================================
--- src/main/java/org/xwiki/chart/plots/PlotFactory.java	(revision 0)
+++ src/main/java/org/xwiki/chart/plots/PlotFactory.java	(revision 0)
@@ -0,0 +1,44 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+
+package org.xwiki.chart.plots;
+
+import java.util.Map;
+import org.jfree.chart.plot.Plot;
+import org.xwiki.chart.ChartGeneratorException;
+import org.xwiki.chart.source.DataSource;
+
+/**
+ * It designates a factory for building Plot structures needed for generating the chart.
+ * 
+ * @version $Id: $
+ * @since 1.9M1
+ */
+public interface PlotFactory
+{
+    /**
+     * @param dataSource the chart's data source
+     * @param params additional parameters
+     * @return a Plot to be embedded within the chart 
+     * @throws ChartGeneratorException in case the data cannot be read
+     */
+    Plot create(DataSource dataSource, Map<String, Object> params) throws ChartGeneratorException;
+}
Index: src/main/java/org/xwiki/chart/source/DataSource.java
===================================================================
--- src/main/java/org/xwiki/chart/source/DataSource.java	(revision 0)
+++ src/main/java/org/xwiki/chart/source/DataSource.java	(revision 0)
@@ -0,0 +1,105 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+package org.xwiki.chart.source;
+
+import org.xwiki.chart.ChartGeneratorException;;
+
+/**
+ * A data source for generating a chart.
+ * 
+ * @version $Id: $
+ * @since 1.9M1
+ */
+public interface DataSource
+{
+    /**
+     * @return the number of rows of this data source
+     */
+    int getRowCount(); 
+
+    /**
+     * @return the number of columns of this data source
+     */    
+    int getColumnCount();
+
+    /**
+     * @param rowIndex the index of the row
+     * @param colIndex the index of the column
+     * @return the value of a single cell
+     * @throws ChartGeneratorException in case of invalid indexes
+     */
+    Number getCell(int rowIndex, int colIndex) throws ChartGeneratorException;
+
+    /**
+     * @param rowIndex the index of the row
+     * @return a whole row
+     * @throws ChartGeneratorException in case of invalid index
+     */
+    Number[] getRow(int rowIndex) throws ChartGeneratorException;
+
+    /**
+     * @param colIndex the index of the column
+     * @return A whole column
+     * @throws ChartGeneratorException in case of invalid index
+     */
+    Number[] getColumn(int colIndex) throws ChartGeneratorException;
+
+    /**
+     * @return a matrix containing the all data source values
+     */
+    Number[][] getAllCells();
+
+    /**
+     * @return true when this data source has a header row
+     */
+    boolean hasHeaderRow();
+
+    /**
+     * @return true when this data source has a header column
+     */
+    boolean hasHeaderColumn();
+
+    /**
+     * @param columnIndex the given index
+     * @return the value in the header row, given by columnIndex
+     * @throws ChartGeneratorException in case of invalid index
+     */
+    String getHeaderRowValue(int columnIndex) throws ChartGeneratorException;
+
+    /**
+     * @return the whole header row
+     * @throws ChartGeneratorException in case there is no header defined
+     */
+    String[] getHeaderRow() throws ChartGeneratorException;
+
+    /**
+     * @param rowIndex the index of the row
+     * @return the value in the header column, given by rowIndex
+     * @throws ChartGeneratorException in case there is no header defined or the index is invalid
+     */
+    String getHeaderColumnValue(int rowIndex) throws ChartGeneratorException;
+
+    /**
+     * @return the whole header column
+     * @throws ChartGeneratorException in case there is no header define
+     */
+    String[] getHeaderColumn() throws ChartGeneratorException;
+}
Index: src/main/java/org/xwiki/chart/source/DataSourceFactory.java
===================================================================
--- src/main/java/org/xwiki/chart/source/DataSourceFactory.java	(revision 0)
+++ src/main/java/org/xwiki/chart/source/DataSourceFactory.java	(revision 0)
@@ -0,0 +1,41 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+package org.xwiki.chart.source;
+
+import java.util.Map;
+
+import org.xwiki.chart.ChartGeneratorException;
+
+/**
+ * A factory for building a specific data source.
+ * 
+ * @version $Id: $
+ * @since 1.9M1
+ */
+public interface DataSourceFactory
+{
+    /**
+     * @return the actual data source it creates. 
+     * @param params the parameters required for building the source
+     * @throws ChartGeneratorException in case the datasource cannot be created
+     */
+    DataSource create(Map<String, Object> params) throws ChartGeneratorException;
+}
Index: src/main/java/org/xwiki/chart/source/DefaultDataSource.java
===================================================================
--- src/main/java/org/xwiki/chart/source/DefaultDataSource.java	(revision 0)
+++ src/main/java/org/xwiki/chart/source/DefaultDataSource.java	(revision 0)
@@ -0,0 +1,279 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+package org.xwiki.chart.source;
+
+import org.xwiki.chart.ChartGeneratorException;
+
+/**
+ * This offers a set of basic features for a data source and can be used as a
+ * base class for more complex data sources, too.
+ * 
+ * @version $Id: $
+ * @since 1.9M1
+ */
+public class DefaultDataSource implements DataSource
+{
+    /**
+     * A matrix for storing the actual data.
+     */
+    protected Number[][] data;
+
+    /**
+     * The header rows.
+     */
+    protected String[] headerRow;
+
+    /**
+     * The header columns.
+     */
+    protected String[] headerColumn;
+
+    /**
+     * This no-arg constructor creates an empty data source with no headers.
+     */
+    public DefaultDataSource()
+    {
+        data = new Number[0][0];
+    }
+
+    /**
+     * This constructor creates a data source with no headers.
+     * 
+     * @param data A matrix containing the values of the data source
+     */
+    public DefaultDataSource(Number[][] data)
+    {
+        this.data = data;
+    }
+
+    /**
+     * This constructor creates a data source with the given data and headers.
+     * 
+     * @param data A matrix containing the values of the data source
+     * @param headerRow The header row with headerRow.length == data[x].length, for x=0,data.length-1
+     * @param headerColumn The header column with headerColumn.length == data.length
+     * @throws IllegalArgumentException Thrown when the conditions above are not satisfied
+     */
+    public DefaultDataSource(Number[][] data, String[] headerRow, String[] headerColumn)
+    {
+        if (headerColumn != null && headerColumn.length != data.length) {
+            throw new IllegalArgumentException("headerColumn.length != data.length");
+        }
+        for (int i = 0; i < data.length; i++) {
+            if (headerRow != null && headerRow.length != data[i].length) {
+                throw new IllegalArgumentException("headerRow.length != data[" + i + "]" + ".length");
+            } else if (headerRow == null && i > 0 && data[i].length != data[i - 1].length) {
+                throw new IllegalArgumentException("data[" + i + "].length != data[" + (i - 1) + "].length");
+            }
+        }
+        this.data = data;
+        this.headerColumn = headerColumn;
+        this.headerRow = headerRow;
+    }
+
+    /**
+     * @return the number of rows of this data source
+     */
+    public int getRowCount()
+    {
+        return data.length;
+    }
+
+    /**
+     * @return the number of columns of this data source
+     */
+    public int getColumnCount()
+    {
+        if (data.length > 0) {
+            return data[0].length;
+        } else {
+            return 0;
+        }
+    }
+
+    /**
+     * @param rowIndex the index of the row
+     * @param colIndex the index of the column
+     * @return the value of a single cell
+     * @throws ChartGeneratorException in case of invalid indexes
+     */
+    public Number getCell(int rowIndex, int colIndex) throws ChartGeneratorException
+    {
+        checkRowIndex(rowIndex);
+        checkColumnIndex(colIndex);
+        return data[rowIndex][colIndex];
+    }
+
+    /**
+     * Sets the value of a single cell.
+     * 
+     * @param rowIndex the index of the row
+     * @param colIndex the index of the column
+     * @param content the value to set in the cell
+     * @throws ChartGeneratorException in case of invalid indexes
+     */
+    public void setCell(int rowIndex, int colIndex, Number content) throws ChartGeneratorException
+    {
+        checkRowIndex(rowIndex);
+        checkColumnIndex(colIndex);
+        data[rowIndex][colIndex] = content;
+    }
+
+    /**
+     * @param rowIndex the index of the row
+     * @return a whole row
+     * @throws ChartGeneratorException in case of invalid index
+     */
+    public Number[] getRow(int rowIndex) throws ChartGeneratorException
+    {
+        checkRowIndex(rowIndex);
+        return data[rowIndex];
+    }
+
+    /**
+     * @param colIndex the index of the column
+     * @return A whole column
+     * @throws ChartGeneratorException in case of invalid index
+     */
+    public Number[] getColumn(int colIndex) throws ChartGeneratorException
+    {
+        checkColumnIndex(colIndex);
+        Number[] column = new Number[getRowCount()];
+        for (int i = 0; i < getRowCount(); i++) {
+            column[i] = data[i][colIndex];
+        }
+        return column;
+    }
+
+    /**
+     * @return a matrix containing the all data source values
+     */
+    public Number[][] getAllCells()
+    {
+        return data;
+    }
+
+    /**
+     * @return true when this data source has a header row
+     */
+    public boolean hasHeaderRow() 
+    {
+        return headerRow != null;
+    }
+
+    /**
+     * @return true when this data source has a header column
+     */
+    public boolean hasHeaderColumn()
+    {
+        return headerColumn != null;
+    }
+
+    /**
+     * @param columnIndex the given index
+     * @return the value in the header row, given by columnIndex
+     * @throws ChartGeneratorException in case of invalid index
+     */
+    public String getHeaderRowValue(int columnIndex) throws ChartGeneratorException
+    {
+        checkHeaderRow();
+        checkColumnIndex(columnIndex);
+        return headerRow[columnIndex];
+    }
+
+    /**
+     * @return the whole header row
+     * @throws ChartGeneratorException in case there is no header defined
+     */
+    public String[] getHeaderRow() throws ChartGeneratorException
+    {
+        checkHeaderRow();
+        return headerRow;
+    }
+
+    /**
+     * @param rowIndex the index of the row
+     * @return the value in the header column, given by rowIndex
+     * @throws ChartGeneratorException in case there is no header defined or the index is invalid
+     */
+    public String getHeaderColumnValue(int rowIndex) throws ChartGeneratorException
+    {
+        checkHeaderColumn();
+        checkRowIndex(rowIndex);
+        return headerColumn[rowIndex];
+    }
+
+    /**
+     * @return the whole header column
+     * @throws ChartGeneratorException in case there is no header define
+     */
+    public String[] getHeaderColumn() throws ChartGeneratorException
+    {
+        checkHeaderColumn();
+        return headerColumn;
+    }
+
+    /**
+     * Checks whether the given value is a valid row index.
+     * @param rowIndex the index of the row
+     * @throws ChartGeneratorException of the given index is invalid
+     */
+    private void checkRowIndex(int rowIndex) throws ChartGeneratorException
+    {
+        if (rowIndex < 0 || rowIndex >= getRowCount()) {
+            throw new ChartGeneratorException("Invalid row index: " + rowIndex);
+        }
+    }
+ 
+   /**
+    * Checks whether the given value is a valid column index.
+    * @param columnIndex the index of the row
+    * @throws ChartGeneratorException if the given index is invalid
+    */
+    private void checkColumnIndex(int columnIndex) throws ChartGeneratorException
+    {
+        if (columnIndex < 0 || columnIndex >= getColumnCount()) {
+            throw new ChartGeneratorException("Invalid column index: " + columnIndex);
+        }
+    }
+
+    /**
+     * Checks if we have a header row defined.
+     * @throws ChartGeneratorException if we don't
+     */
+    private void checkHeaderRow() throws ChartGeneratorException
+    {
+        if (!hasHeaderRow()) {
+            throw new ChartGeneratorException("No header row defined for the table.");
+        }
+    }
+
+    /**
+     * Checks if we have a header column defined.
+     * @throws ChartGeneratorException if we don't
+     */
+    private void checkHeaderColumn() throws ChartGeneratorException
+    {
+        if (!hasHeaderColumn()) {
+            throw new ChartGeneratorException("No header column defined for the table.");
+        }
+    }
+}
Index: src/main/resources/META-INF/plexus/components.xml
===================================================================
--- src/main/resources/META-INF/plexus/components.xml	(revision 0)
+++ src/main/resources/META-INF/plexus/components.xml	(revision 0)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ *
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+-->
+<component-set>
+  <components>
+    <component>
+      <role>org.xwiki.chart.ChartGenerator</role>
+      <role-hint>default</role-hint>
+      <implementation>org.xwiki.chart.internal.DefaultChartGenerator</implementation>
+      <instantiation-strategy>singleton</instantiation-strategy>
+    </component>
+  </components>
+</component-set>
\ No newline at end of file

