Search in sources :

Example 1 with SeriesRow

use of org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow in project qpid-broker-j by apache.

the class CategoryDataSetBasedChartBuilder method newDatasetHolder.

@Override
protected DatasetHolder newDatasetHolder() {
    return new DatasetHolder() {

        private final DefaultCategoryDataset _dataset = new DefaultCategoryDataset();

        @Override
        public void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row) {
            String x = row.dimensionAsString(0);
            double y = row.dimensionAsDouble(1);
            _dataset.addValue(y, seriesDefinition.getSeriesLegend(), x);
        }

        @Override
        public void beginSeries(SeriesDefinition seriesDefinition) {
        // unused
        }

        @Override
        public void endSeries(SeriesDefinition seriesDefinition) {
        // unused
        }

        @Override
        public int getNumberOfDimensions() {
            return 2;
        }

        @Override
        public Dataset getPopulatedDataset() {
            return _dataset;
        }
    };
}
Also used : SeriesDefinition(org.apache.qpid.disttest.charting.definition.SeriesDefinition) DatasetHolder(org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) SeriesRow(org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow)

Example 2 with SeriesRow

use of org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow in project qpid-broker-j by apache.

the class XYDataSetBasedChartBuilder method newDatasetHolder.

@Override
protected DatasetHolder newDatasetHolder() {
    return new DatasetHolder() {

        private final DefaultXYDataset _dataset = new DefaultXYDataset();

        private List<Double[]> _xyPairs = null;

        @Override
        public void beginSeries(SeriesDefinition seriesDefinition) {
            _xyPairs = new ArrayList<Double[]>();
        }

        @Override
        public void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row) {
            double x = row.dimensionAsDouble(0);
            double y = row.dimensionAsDouble(1);
            _xyPairs.add(new Double[] { x, y });
        }

        @Override
        public void endSeries(SeriesDefinition seriesDefinition) {
            double[][] seriesData = listToSeriesDataArray();
            _dataset.addSeries(seriesDefinition.getSeriesLegend(), seriesData);
        }

        @Override
        public int getNumberOfDimensions() {
            return 2;
        }

        private double[][] listToSeriesDataArray() {
            double[][] seriesData = new double[2][_xyPairs.size()];
            int i = 0;
            for (Iterator<Double[]> iterator = _xyPairs.iterator(); iterator.hasNext(); ) {
                Double[] xyPair = iterator.next();
                seriesData[0][i] = xyPair[0];
                seriesData[1][i] = xyPair[1];
                i++;
            }
            return seriesData;
        }

        @Override
        public Dataset getPopulatedDataset() {
            return _dataset;
        }
    };
}
Also used : SeriesDefinition(org.apache.qpid.disttest.charting.definition.SeriesDefinition) DatasetHolder(org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder) DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) ArrayList(java.util.ArrayList) List(java.util.List) SeriesRow(org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow)

Example 3 with SeriesRow

use of org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow in project qpid-broker-j by apache.

the class StatisticalBarChartBuilder method newDatasetHolder.

@Override
protected DatasetHolder newDatasetHolder() {
    return new DatasetHolder() {

        private final DefaultStatisticalCategoryDataset _dataset = new DefaultStatisticalCategoryDataset();

        @Override
        public void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row) {
            String x = row.dimensionAsString(0);
            double mean = row.dimensionAsDouble(1);
            double stdDev = row.dimensionAsDouble(2);
            _dataset.add(mean, stdDev, seriesDefinition.getSeriesLegend(), x);
        }

        @Override
        public void beginSeries(SeriesDefinition seriesDefinition) {
        // unused
        }

        @Override
        public void endSeries(SeriesDefinition seriesDefinition) {
        // unused
        }

        @Override
        public int getNumberOfDimensions() {
            return 3;
        }

        @Override
        public Dataset getPopulatedDataset() {
            return _dataset;
        }
    };
}
Also used : SeriesDefinition(org.apache.qpid.disttest.charting.definition.SeriesDefinition) DatasetHolder(org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder) DefaultStatisticalCategoryDataset(org.jfree.data.statistics.DefaultStatisticalCategoryDataset) SeriesRow(org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow)

Example 4 with SeriesRow

use of org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow in project qpid-broker-j by apache.

the class ChartProductionTest method testTimeSeriesLineChart.

public void testTimeSeriesLineChart() throws Exception {
    when(_seriesDefinition.getShape()).thenReturn("cross");
    SeriesRow[] timelineSeriesRows = new SeriesRow[] { new SeriesRow(new Date(1), 1d), new SeriesRow(new Date(2), 2d), new SeriesRow(new Date(3), 3d), new SeriesRow(new Date(4), 4d), new SeriesRow(new Date(5), 5d), new SeriesRow(new Date(6), 6d), new SeriesRow(new Date(7), 4d) };
    ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.TIMELINE, new SampleSeriesBuilder(timelineSeriesRows));
    assertChartTitlesAndWriteToFile(builder);
}
Also used : SeriesRow(org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow) Date(java.util.Date)

Example 5 with SeriesRow

use of org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow in project qpid-broker-j by apache.

the class TimeSeriesBuilderCallbackTest method testAddPointToSeries.

public void testAddPointToSeries() {
    TimeSeriesHolder timeSeriesHolder = new TimeSeriesHolder();
    SeriesDefinition seriesDefinition = mock(SeriesDefinition.class);
    when(seriesDefinition.getSeriesLegend()).thenReturn(SERIES_LEGEND);
    timeSeriesHolder.beginSeries(seriesDefinition);
    timeSeriesHolder.addDataPointToSeries(seriesDefinition, new SeriesRow(_dates[0], _values[0]));
    timeSeriesHolder.addDataPointToSeries(seriesDefinition, new SeriesRow(_dates[1], _values[1]));
    timeSeriesHolder.addDataPointToSeries(seriesDefinition, new SeriesRow(_dates[2], _values[2]));
    timeSeriesHolder.endSeries(seriesDefinition);
    TimeSeriesCollection timeSeriesCollection = (TimeSeriesCollection) timeSeriesHolder.getPopulatedDataset();
    TimeSeries actualTimeSeries = timeSeriesCollection.getSeries(SERIES_LEGEND);
    for (int i = 0; i < NUMBER_OF_DATA_POINTS; i++) {
        TimeSeriesDataItem dataItem0 = actualTimeSeries.getDataItem(i);
        assertEquals(_dates[i].getTime(), dataItem0.getPeriod().getMiddleMillisecond());
        assertEquals(_values[i], dataItem0.getValue());
    }
}
Also used : SeriesDefinition(org.apache.qpid.disttest.charting.definition.SeriesDefinition) TimeSeries(org.jfree.data.time.TimeSeries) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) TimeSeriesDataItem(org.jfree.data.time.TimeSeriesDataItem) SeriesRow(org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow)

Aggregations

SeriesRow (org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow)5 SeriesDefinition (org.apache.qpid.disttest.charting.definition.SeriesDefinition)4 DatasetHolder (org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder)3 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)1 DefaultStatisticalCategoryDataset (org.jfree.data.statistics.DefaultStatisticalCategoryDataset)1 TimeSeries (org.jfree.data.time.TimeSeries)1 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)1 TimeSeriesDataItem (org.jfree.data.time.TimeSeriesDataItem)1 DefaultXYDataset (org.jfree.data.xy.DefaultXYDataset)1