[Swift-commit] r5779 - usertools/plotter/src/plotter

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Mon Apr 30 14:39:44 CDT 2012


Author: wozniak
Date: 2012-04-30 14:39:44 -0500 (Mon, 30 Apr 2012)
New Revision: 5779

Modified:
   usertools/plotter/src/plotter/Bars.java
   usertools/plotter/src/plotter/Util.java
Log:
Minor reorgs; enable legend.enabled for Bar plots


Modified: usertools/plotter/src/plotter/Bars.java
===================================================================
--- usertools/plotter/src/plotter/Bars.java	2012-04-30 16:58:45 UTC (rev 5778)
+++ usertools/plotter/src/plotter/Bars.java	2012-04-30 19:39:44 UTC (rev 5779)
@@ -3,16 +3,8 @@
 
 import java.awt.Color;
 import java.awt.geom.Rectangle2D;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
+import java.io.*;
+import java.util.*;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.xmlgraphics.java2d.GraphicContext;
@@ -26,7 +18,7 @@
 import org.jfree.data.category.DefaultCategoryDataset;
 
 /**
- * See main() for command-line arguments
+ * See bars() for command-line arguments
  * */
 public class Bars
 {
@@ -53,7 +45,7 @@
 
   static boolean withLegend = true;
   static boolean verbose = false;
-  
+
   /**
        Args: Lines <properties> <output file> <data file>*
        Reads settings from properties: see scanProperties()
@@ -61,7 +53,7 @@
        Data files are two-columns of numbers each -
        see LineReader.read() and LineReader.array()
    */
-  public static void bars(String props, String output, 
+  public static void bars(String props, String output,
                           List<String> names, boolean verbose)
   {
     Bars.verbose = verbose;
@@ -101,11 +93,11 @@
       double[][] array = LineReader.array(lines);
       data.add(array);
       addLabel(name, labels);
-      Util.verbose("array:\n" + toString(array));
+      Util.verbose("array:\n" + Util.doublesToString(array));
     }
 
     CategoryDataset dataset = makeDataset(data);
-    
+
     plot(dataset, title, xlabel, ylabel, output);
   }
 
@@ -118,7 +110,7 @@
         result.addValue((Number) d[i][1], "", String.valueOf(d[i][0]));
     return result;
   }
-  
+
   /**
        Generate simple plot.
        @param collection The x,y data.
@@ -155,12 +147,12 @@
       System.err.println("Problem with file: " + output);
       return false;
     }
-    
-    JFreeChart chart = 
-      ChartFactory.createBarChart(title, xlabel, ylabel, 
-                                  dataset, PlotOrientation.VERTICAL, 
-                                  true, true, false);
 
+    JFreeChart chart =
+      ChartFactory.createBarChart(title, xlabel, ylabel,
+                                  dataset, PlotOrientation.VERTICAL,
+                                  withLegend, true, false);
+
     setupPlot(chart, dataset);
     chart.draw(g2d, rectangle);
 
@@ -186,13 +178,17 @@
     Plots.setupLegend(chart, properties);
     plot.setBackgroundPaint(Color.WHITE);
 
-   //  BarRenderer.setDefaultShadowsVisible(false);
     BarRenderer renderer = (BarRenderer) plot.getRenderer();
     renderer.setGradientPaintTransformer(null);
     renderer.setSeriesPaint(0, Color.red);
-    renderer.setSeriesPaint(1, Color.green);
-    plot.setRenderer(renderer);
-    // renderer.setShadowVisible(false);
+
+    //  BarRenderer.setDefaultShadowsVisible(false);
+//    BarRenderer renderer = (BarRenderer) plot.getRenderer();
+//    renderer.setGradientPaintTransformer(null);
+//    renderer.setSeriesPaint(0, Color.red);
+//    renderer.setSeriesPaint(1, Color.green);
+//    plot.setRenderer(renderer);
+//    // renderer.setShadowVisible(false);
   }
 
   /**
@@ -220,7 +216,7 @@
     title = properties.getProperty("title");
     xlabel = properties.getProperty("xlabel");
     ylabel = properties.getProperty("ylabel");
-    
+
     String tmp;
     tmp = properties.getProperty("width");
     if (tmp != null)
@@ -282,30 +278,4 @@
       label = "";
     labels.add(label);
   }
-
-  static boolean showShape(String name)
-  {
-    String mode = properties.getProperty("shape."+name);
-    // System.out.println(mode);
-    if ("none".equals(mode))
-      return false;
-    return true;
-  }
-
-  static String toString(double[][] array)
-  {
-    StringBuilder sb = new StringBuilder();
-    for (int i = 0; i < array.length; i++)
-    {
-      double[] row = array[i];
-      for (int j = 0; j < row.length; j++)
-      {
-        sb.append(array[i][j]);
-        if (j < row.length-1)
-          sb.append(" ");
-      }
-      sb.append("\n");
-    }
-    return sb.toString();
-  }
 }

Modified: usertools/plotter/src/plotter/Util.java
===================================================================
--- usertools/plotter/src/plotter/Util.java	2012-04-30 16:58:45 UTC (rev 5778)
+++ usertools/plotter/src/plotter/Util.java	2012-04-30 19:39:44 UTC (rev 5779)
@@ -5,22 +5,39 @@
  * */
 public class Util
 {
-    static boolean v = false;
+  static boolean v = false;
 
-    public static void fatal(String s)
+  public static String doublesToString(double[][] array)
+  {
+    StringBuilder sb = new StringBuilder();
+    for (int i = 0; i < array.length; i++)
     {
-        System.err.println(s);
-        System.exit(2);
+      double[] row = array[i];
+      for (int j = 0; j < row.length; j++)
+      {
+        sb.append(array[i][j]);
+        if (j < row.length-1)
+          sb.append(" ");
+      }
+      sb.append("\n");
     }
+    return sb.toString();
+  }
 
-    public static void verbose(String s)
-    {
-        if (v)
-            System.out.println(s);
-    }
+  public static void fatal(String s)
+  {
+    System.err.println(s);
+    System.exit(2);
+  }
 
-    public static void verbose(boolean status)
-    {
-        v = status;
-    }
+  public static void verbose(String s)
+  {
+    if (v)
+      System.out.println(s);
+  }
+
+  public static void verbose(boolean status)
+  {
+    v = status;
+  }
 }




More information about the Swift-commit mailing list