From 02a2727028d33303618b8ce62ab7f74fee4427d6 Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Sun, 25 Nov 2012 22:49:45 +0000 Subject: QPID-4338: [Java Performance Charts] Renamed SeriesStokeAndPaintAccessor and modified its api to make its intention more obvious. Also minor code tidy-ups in ColorFactory. Applied patch from Philip Harvey git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1413438 13f79535-47bb-0310-9956-ffa450edef68 --- .../charting/chartbuilder/BaseChartBuilder.java | 6 ++-- .../CategoryDataSetBasedChartBuilder.java | 10 +++---- .../charting/chartbuilder/ColorFactory.java | 3 +- .../chartbuilder/SeriesStokeAndPaintAccessor.java | 32 -------------------- .../chartbuilder/SeriesStrokeAndPaintApplier.java | 35 ++++++++++++++++++++++ .../chartbuilder/StatisticalBarCharBuilder.java | 10 +++---- .../chartbuilder/XYDataSetBasedChartBuilder.java | 10 +++---- 7 files changed, 54 insertions(+), 52 deletions(-) delete mode 100644 qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStokeAndPaintAccessor.java create mode 100644 qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java (limited to 'qpid/java') diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java index 2fe30bb751..700d7fa0ce 100644 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java +++ b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java @@ -41,14 +41,14 @@ public abstract class BaseChartBuilder implements ChartBuilder setBackgroundColour(chart); } - public void addSeriesAttributes(List series, SeriesStokeAndPaintAccessor stokeAndPaintAccessor) + protected void addSeriesAttributes(JFreeChart targetChart, List series, SeriesStrokeAndPaintApplier strokeAndPaintApplier) { for (int i = 0; i < series.size(); i++) { SeriesDefinition seriesDefinition = series.get(i); if (seriesDefinition.getSeriesColourName() != null) { - stokeAndPaintAccessor.setSeriesPaint(i, ColorFactory.toColour(seriesDefinition.getSeriesColourName())); + strokeAndPaintApplier.setSeriesPaint(i, ColorFactory.toColour(seriesDefinition.getSeriesColourName()), targetChart); } if (seriesDefinition.getStrokeWidth() != null) { @@ -56,7 +56,7 @@ public abstract class BaseChartBuilder implements ChartBuilder boolean dashed = seriesDefinition.getStrokeWidth() < 0; float width = Math.abs(seriesDefinition.getStrokeWidth()); BasicStroke stroke = buildStrokeOfWidth(width, dashed); - stokeAndPaintAccessor.setSeriesStroke(i, stroke); + strokeAndPaintApplier.setSeriesStroke(i, stroke, targetChart); } } } diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java index cd56b0c967..ba027d9d93 100644 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java +++ b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java @@ -81,18 +81,18 @@ public abstract class CategoryDataSetBasedChartBuilder extends BaseChartBuilder chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); addCommonChartAttributes(chart, chartingDefinition); - addSeriesAttributes(chartingDefinition.getSeries(), new SeriesStokeAndPaintAccessor() + addSeriesAttributes(chart, chartingDefinition.getSeries(), new SeriesStrokeAndPaintApplier() { @Override - public void setSeriesStroke(int seriesIndex, Stroke stroke) + public void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart) { - chart.getCategoryPlot().getRenderer().setSeriesStroke(seriesIndex, stroke); + targetChart.getCategoryPlot().getRenderer().setSeriesStroke(seriesIndex, stroke); } @Override - public void setSeriesPaint(int seriesIndex, Color colour) + public void setSeriesPaint(int seriesIndex, Color colour, JFreeChart targetChart) { - chart.getCategoryPlot().getRenderer().setSeriesPaint(seriesIndex, colour); + targetChart.getCategoryPlot().getRenderer().setSeriesPaint(seriesIndex, colour); } }); diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java index 942d42ad73..49d777c506 100644 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java +++ b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java @@ -23,7 +23,6 @@ import java.awt.Color; public class ColorFactory { - /** * Converts a colour name known to the JDK into a {@link Color} instance. Additionally, * if the work dark_ is prepended to the colour, a darker shade of the same colour is @@ -52,7 +51,7 @@ public class ColorFactory } } - protected static Color getColourFromStaticField(String colourName) + private static Color getColourFromStaticField(String colourName) { try { diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStokeAndPaintAccessor.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStokeAndPaintAccessor.java deleted file mode 100644 index 75c3f9d3f2..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStokeAndPaintAccessor.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.disttest.charting.chartbuilder; - -import java.awt.Color; -import java.awt.Stroke; - -public interface SeriesStokeAndPaintAccessor -{ - - void setSeriesStroke(int i, Stroke stroke); - - void setSeriesPaint(int i, Color blue); - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java new file mode 100644 index 0000000000..4d6c37a9f4 --- /dev/null +++ b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.disttest.charting.chartbuilder; + +import java.awt.Color; +import java.awt.Stroke; + +import org.jfree.chart.JFreeChart; + +/** + * Applies the supplied stroke and color to a series in the target chart. + * Multiple implementations exist to because of the various chart types. + */ +public interface SeriesStrokeAndPaintApplier +{ + void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart); + void setSeriesPaint(int seriesIndex, Color color, JFreeChart targetChart); +} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarCharBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarCharBuilder.java index 40a8b31b87..1669ee1bb2 100644 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarCharBuilder.java +++ b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarCharBuilder.java @@ -92,18 +92,18 @@ public class StatisticalBarCharBuilder extends BaseChartBuilder chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); addCommonChartAttributes(chart, chartingDefinition); - addSeriesAttributes(chartingDefinition.getSeries(), new SeriesStokeAndPaintAccessor() + addSeriesAttributes(chart, chartingDefinition.getSeries(), new SeriesStrokeAndPaintApplier() { @Override - public void setSeriesStroke(int seriesIndex, Stroke stroke) + public void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart) { - chart.getCategoryPlot().getRenderer().setSeriesStroke(seriesIndex, stroke); + targetChart.getCategoryPlot().getRenderer().setSeriesStroke(seriesIndex, stroke); } @Override - public void setSeriesPaint(int seriesIndex, Color colour) + public void setSeriesPaint(int seriesIndex, Color colour, JFreeChart targetChart) { - chart.getCategoryPlot().getRenderer().setSeriesPaint(seriesIndex, colour); + targetChart.getCategoryPlot().getRenderer().setSeriesPaint(seriesIndex, colour); } }); diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java index 2af8395516..168794be50 100644 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java +++ b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java @@ -98,18 +98,18 @@ public abstract class XYDataSetBasedChartBuilder extends BaseChartBuilder dataset, PLOT_ORIENTATION, SHOW_LEGEND, SHOW_TOOL_TIPS, SHOW_URLS); addCommonChartAttributes(chart, chartingDefinition); - addSeriesAttributes(chartingDefinition.getSeries(), new SeriesStokeAndPaintAccessor() + addSeriesAttributes(chart, chartingDefinition.getSeries(), new SeriesStrokeAndPaintApplier() { @Override - public void setSeriesStroke(int seriesIndex, Stroke stroke) + public void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart) { - chart.getXYPlot().getRenderer().setSeriesStroke(seriesIndex, stroke); + targetChart.getXYPlot().getRenderer().setSeriesStroke(seriesIndex, stroke); } @Override - public void setSeriesPaint(int seriesIndex, Color colour) + public void setSeriesPaint(int seriesIndex, Color colour, JFreeChart targetChart) { - chart.getXYPlot().getRenderer().setSeriesPaint(seriesIndex, colour); + targetChart.getXYPlot().getRenderer().setSeriesPaint(seriesIndex, colour); } }); -- cgit v1.2.1