Author: kwall
Date: Sun Nov 25 22:49:45 2012
New Revision: 1413438

URL: http://svn.apache.org/viewvc?rev=1413438&view=rev
Log:
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 <[email protected]>

Added:
    
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java
      - copied, changed from r1413434, 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStokeAndPaintAccessor.java
Removed:
    
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStokeAndPaintAccessor.java
Modified:
    
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java
    
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java
    
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java
    
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarCharBuilder.java
    
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java

Modified: 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java?rev=1413438&r1=1413437&r2=1413438&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java
 (original)
+++ 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java
 Sun Nov 25 22:49:45 2012
@@ -41,14 +41,14 @@ public abstract class BaseChartBuilder i
         setBackgroundColour(chart);
     }
 
-    public void addSeriesAttributes(List<SeriesDefinition> series, 
SeriesStokeAndPaintAccessor stokeAndPaintAccessor)
+    protected void addSeriesAttributes(JFreeChart targetChart, 
List<SeriesDefinition> 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 i
                 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);
             }
         }
     }

Modified: 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java?rev=1413438&r1=1413437&r2=1413438&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java
 (original)
+++ 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java
 Sun Nov 25 22:49:45 2012
@@ -81,18 +81,18 @@ public abstract class CategoryDataSetBas
         
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);
             }
         });
 

Modified: 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java?rev=1413438&r1=1413437&r2=1413438&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java
 (original)
+++ 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java
 Sun Nov 25 22:49:45 2012
@@ -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
         {

Copied: 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java
 (from r1413434, 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStokeAndPaintAccessor.java)
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java?p2=qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java&p1=qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStokeAndPaintAccessor.java&r1=1413434&r2=1413438&rev=1413438&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStokeAndPaintAccessor.java
 (original)
+++ 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java
 Sun Nov 25 22:49:45 2012
@@ -22,11 +22,14 @@ package org.apache.qpid.disttest.chartin
 import java.awt.Color;
 import java.awt.Stroke;
 
-public interface SeriesStokeAndPaintAccessor
-{
-
-    void setSeriesStroke(int i, Stroke stroke);
-
-    void setSeriesPaint(int i, Color blue);
+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);
 }

Modified: 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarCharBuilder.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarCharBuilder.java?rev=1413438&r1=1413437&r2=1413438&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarCharBuilder.java
 (original)
+++ 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarCharBuilder.java
 Sun Nov 25 22:49:45 2012
@@ -92,18 +92,18 @@ public class StatisticalBarCharBuilder e
         
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);
             }
         });
 

Modified: 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java?rev=1413438&r1=1413437&r2=1413438&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java
 (original)
+++ 
qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java
 Sun Nov 25 22:49:45 2012
@@ -98,18 +98,18 @@ public abstract class XYDataSetBasedChar
                 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);
             }
         });
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to