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

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Tue Jan 14 11:33:03 CST 2014


Author: wozniak
Date: 2014-01-14 11:33:03 -0600 (Tue, 14 Jan 2014)
New Revision: 7473

Modified:
   usertools/plotter/src/plotter/Lines.java
Log:
Additional error check


Modified: usertools/plotter/src/plotter/Lines.java
===================================================================
--- usertools/plotter/src/plotter/Lines.java	2014-01-13 20:53:32 UTC (rev 7472)
+++ usertools/plotter/src/plotter/Lines.java	2014-01-14 17:33:03 UTC (rev 7473)
@@ -7,7 +7,9 @@
 import java.awt.Color;
 import java.awt.geom.Rectangle2D;
 import java.io.*;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.xmlgraphics.java2d.GraphicContext;
@@ -15,8 +17,10 @@
 import org.jfree.chart.ChartFactory;
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.annotations.XYTextAnnotation;
+import org.jfree.chart.axis.LogAxis;
 import org.jfree.chart.axis.LogarithmicAxis;
 import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.ValueAxis;
 import org.jfree.chart.plot.PlotOrientation;
 import org.jfree.chart.plot.XYPlot;
 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
@@ -117,6 +121,8 @@
         System.exit(1);
       }
       double[][] array = LineReader.array(lines);
+      if (array.length == 0)
+        throw new UserInputException("file has no data: " + name);
       if (array[0].length != 2)
         throw new UserInputException("file is not two-column: " + name);
       data.add(array);
@@ -273,7 +279,7 @@
 
     if (ymin != null || ymax != null)
     {
-      NumberAxis axis = (NumberAxis) plot.getRangeAxis();
+      ValueAxis axis = plot.getRangeAxis();
       Range range = axis.getRange();
       aymin = range.getLowerBound();
       aymax = range.getUpperBound();
@@ -281,6 +287,8 @@
       if (ymax != null) aymax = ymax;
       axis.setRange(aymin, aymax);
     }
+    //  NumberAxis axis = (NumberAxis) plot.getRangeAxis();
+    // axis.setTickUnit(new NumberTickUnit(1, new DecimalFormat("0"), 1));
   }
 
 
@@ -297,7 +305,7 @@
 
     if (axis_y_type.equals("logarithmic"))
     {
-      NumberAxis rangeAxis = new LogarithmicAxis(ylabel);
+      ValueAxis rangeAxis = new LogAxis(ylabel);
       plot.setRangeAxis(rangeAxis);
     }
     else if (!axis_y_type.equals("normal"))
@@ -436,19 +444,19 @@
       return false;
     return true;
   }
-  
-  static BasicStroke dottedStroke = 
+
+  static BasicStroke dottedStroke =
     new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                     1.0f, new float[] {6.0f, 6.0f}, 0.0f);
-  
+
   static void formatLine(String name, XYLineAndShapeRenderer renderer, int i)
   {
     System.out.println(name);
-    String lineStyle = properties.getProperty("line."+name); 
+    String lineStyle = properties.getProperty("line."+name);
     if ("dotted".equals(lineStyle))
       renderer.setSeriesStroke(i, dottedStroke);
   }
-  
+
   static String toString(double[][] array)
   {
     StringBuilder sb = new StringBuilder();




More information about the Swift-commit mailing list