summaryrefslogtreecommitdiff
path: root/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java')
-rw-r--r--java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java72
1 files changed, 63 insertions, 9 deletions
diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java
index def87f5840..9cadf0ec3c 100644
--- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java
+++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java
@@ -23,6 +23,9 @@ import java.awt.Color;
import java.awt.GradientPaint;
import org.apache.qpid.disttest.charting.definition.ChartingDefinition;
+import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder;
+import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder;
+import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.title.ShortTextTitle;
@@ -30,12 +33,67 @@ import org.jfree.data.general.Dataset;
public abstract class BaseChartBuilder implements ChartBuilder
{
- private static final GradientPaint BLUE_GRADIENT = new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue);
+ static final GradientPaint BLUE_GRADIENT = new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue);
- public void addCommonChartAttributes(JFreeChart chart, ChartingDefinition chartingDefinition)
+ private SeriesPainter _seriesPainter = new SeriesPainter();
+
+ private final SeriesBuilder _seriesBuilder;
+
+ protected BaseChartBuilder(SeriesBuilder seriesBuilder)
+ {
+ _seriesBuilder = seriesBuilder;
+ }
+
+ @Override
+ public JFreeChart buildChart(ChartingDefinition chartingDefinition)
+ {
+ _seriesBuilder.setDatasetHolder(newDatasetHolder());
+ Dataset dataset = _seriesBuilder.build(chartingDefinition.getSeriesDefinitions());
+
+ JFreeChart chart = createChart(chartingDefinition, dataset);
+ return chart;
+ }
+
+
+ /**
+ * return a holder of an empty dataset suitable for use with the chart type
+ * returned by {@link #createChartImpl(String, String, String, Dataset, PlotOrientation, boolean, boolean, boolean)}.
+ */
+ protected abstract DatasetHolder newDatasetHolder();
+
+ /**
+ * Create a chart with the supplied parameters.
+ *
+ * For ease of implementation, the signature is intentionally similar
+ * to {@link ChartFactory}'s factory methods.
+ */
+ protected abstract JFreeChart createChartImpl(
+ String title, String xAxisTitle, String yAxisTitle,
+ final Dataset dataset,
+ PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls);
+
+ /**
+ * Create a {@link SeriesStrokeAndPaintApplier} that will be used to format a chart
+ */
+ protected abstract SeriesStrokeAndPaintApplier newStrokeAndPaintApplier();
+
+
+ private JFreeChart createChart(ChartingDefinition chartingDefinition, final Dataset dataset)
{
+ String title = chartingDefinition.getChartTitle();
+ String xAxisTitle = chartingDefinition.getXAxisTitle();
+ String yAxisTitle = chartingDefinition.getYAxisTitle();
+
+ final JFreeChart chart = createChartImpl(
+ title, xAxisTitle, yAxisTitle,
+ dataset,
+ PLOT_ORIENTATION, SHOW_LEGEND, SHOW_TOOL_TIPS, SHOW_URLS);
+
addSubtitle(chart, chartingDefinition);
- setBackgroundColour(chart);
+ chart.setBackgroundPaint(BLUE_GRADIENT);
+ _seriesPainter.applySeriesAppearance(chart, chartingDefinition.getSeriesDefinitions(), newStrokeAndPaintApplier());
+
+ return chart;
}
private void addSubtitle(JFreeChart chart, ChartingDefinition chartingDefinition)
@@ -46,13 +104,9 @@ public abstract class BaseChartBuilder implements ChartBuilder
}
}
- private void setBackgroundColour(JFreeChart chart)
+ void setSeriesPainter(SeriesPainter seriesPainter)
{
- chart.setBackgroundPaint(BLUE_GRADIENT);
+ _seriesPainter = seriesPainter;
}
- public abstract JFreeChart createChartImpl(String title, String xAxisTitle,
- String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips,
- boolean showUrls);
-
}