use of org.apache.qpid.disttest.charting.definition.SeriesDefinition 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;
}
};
}
use of org.apache.qpid.disttest.charting.definition.SeriesDefinition 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;
}
};
}
use of org.apache.qpid.disttest.charting.definition.SeriesDefinition in project qpid-broker-j by apache.
the class JdbcSeriesBuilder method build.
@Override
public Dataset build(List<SeriesDefinition> seriesDefinitions) {
for (Iterator<SeriesDefinition> iterator = seriesDefinitions.iterator(); iterator.hasNext(); ) {
SeriesDefinition series = iterator.next();
buildDataSetForSingleSeries(series);
}
return _datasetHolder.getPopulatedDataset();
}
use of org.apache.qpid.disttest.charting.definition.SeriesDefinition in project qpid-broker-j by apache.
the class JdbcSeriesBuilderTest method testBuildOneSeries.
public void testBuildOneSeries() throws Exception {
SeriesDefinition seriesDefinition = createTestSeriesDefinition();
JdbcSeriesBuilder seriesBuilder = new JdbcSeriesBuilder("org.relique.jdbc.csv.CsvDriver", null);
seriesBuilder.setDatasetHolder(_seriesWalkerCallback);
seriesBuilder.build(Collections.singletonList(seriesDefinition));
verify(_seriesWalkerCallback).beginSeries(seriesDefinition);
verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new SeriesRow("elephant", "2"));
verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new SeriesRow("lion", "3"));
verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new SeriesRow("tiger", "4"));
verify(_seriesWalkerCallback).endSeries(seriesDefinition);
}
use of org.apache.qpid.disttest.charting.definition.SeriesDefinition in project qpid-broker-j by apache.
the class JdbcUrlGeneratorTest method testGetJdbcUrlWithoutProvidingAUrlReturnsCsvUrlWithCorrectDirectory.
public void testGetJdbcUrlWithoutProvidingAUrlReturnsCsvUrlWithCorrectDirectory() {
JdbcUrlGenerator jdbcUrlGenerator = new JdbcUrlGenerator(null);
SeriesDefinition seriesDefinition = mock(SeriesDefinition.class);
when(seriesDefinition.getSeriesDirectory()).thenReturn("mydir");
String jdbcUrl = jdbcUrlGenerator.getJdbcUrl(seriesDefinition);
assertEquals("jdbc:relique:csv:mydir", jdbcUrl);
}
Aggregations