Search in sources :

Example 6 with SeriesDefinition

use of org.apache.qpid.disttest.charting.definition.SeriesDefinition in project qpid-broker-j by apache.

the class SeriesPainter method applySeriesAppearance.

public void applySeriesAppearance(JFreeChart chart, List<SeriesDefinition> seriesDefinitions, SeriesStrokeAndPaintApplier strokeAndPaintApplier) {
    for (int i = 0; i < seriesDefinitions.size(); i++) {
        SeriesDefinition seriesDefinition = seriesDefinitions.get(i);
        if (seriesDefinition.getSeriesColourName() != null) {
            strokeAndPaintApplier.setSeriesPaint(i, ColorFactory.toColour(seriesDefinition.getSeriesColourName()), chart);
        }
        if (seriesDefinition.getStrokeWidth() != null) {
            // Negative width used to signify dashed
            boolean dashed = seriesDefinition.getStrokeWidth() < 0;
            float width = Math.abs(seriesDefinition.getStrokeWidth());
            BasicStroke stroke = buildStrokeOfWidth(width, dashed);
            strokeAndPaintApplier.setSeriesStroke(i, stroke, chart);
        }
        if (seriesDefinition.getShape() != null) {
            Shape shape = buildShape(seriesDefinition.getShape());
            strokeAndPaintApplier.setSeriesShape(i, shape, chart);
        }
    }
}
Also used : SeriesDefinition(org.apache.qpid.disttest.charting.definition.SeriesDefinition) BasicStroke(java.awt.BasicStroke) Shape(java.awt.Shape)

Example 7 with SeriesDefinition

use of org.apache.qpid.disttest.charting.definition.SeriesDefinition 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 8 with SeriesDefinition

use of org.apache.qpid.disttest.charting.definition.SeriesDefinition 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)

Example 9 with SeriesDefinition

use of org.apache.qpid.disttest.charting.definition.SeriesDefinition in project qpid-broker-j by apache.

the class JdbcUrlGeneratorTest method testGetJdbcUrlThrowsExceptionIfUrlProvidedAndSeriesDirectorySpecified.

public void testGetJdbcUrlThrowsExceptionIfUrlProvidedAndSeriesDirectorySpecified() {
    String urlTemplate = "urlTemplate";
    JdbcUrlGenerator jdbcUrlGenerator = new JdbcUrlGenerator(urlTemplate);
    SeriesDefinition seriesDefinition = mock(SeriesDefinition.class);
    when(seriesDefinition.getSeriesDirectory()).thenReturn("mydir");
    try {
        jdbcUrlGenerator.getJdbcUrl(seriesDefinition);
        fail("Expected exception not thrown");
    } catch (IllegalArgumentException e) {
    // pass
    }
}
Also used : SeriesDefinition(org.apache.qpid.disttest.charting.definition.SeriesDefinition)

Example 10 with SeriesDefinition

use of org.apache.qpid.disttest.charting.definition.SeriesDefinition in project qpid-broker-j by apache.

the class JdbcUrlGeneratorTest method testGetJdbcUrlReturnsProvidedUrl.

public void testGetJdbcUrlReturnsProvidedUrl() {
    String urlTemplate = "urlTemplate";
    JdbcUrlGenerator jdbcUrlGenerator = new JdbcUrlGenerator(urlTemplate);
    SeriesDefinition seriesDefinition = mock(SeriesDefinition.class);
    String jdbcUrl = jdbcUrlGenerator.getJdbcUrl(seriesDefinition);
    assertEquals(urlTemplate, jdbcUrl);
}
Also used : SeriesDefinition(org.apache.qpid.disttest.charting.definition.SeriesDefinition)

Aggregations

SeriesDefinition (org.apache.qpid.disttest.charting.definition.SeriesDefinition)11 SeriesRow (org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow)4 DatasetHolder (org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder)3 BasicStroke (java.awt.BasicStroke)1 Shape (java.awt.Shape)1 ArrayList (java.util.ArrayList)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