[Swift-commit] r8230 - usertools/plotter/src/plotter
wozniak at ci.uchicago.edu
wozniak at ci.uchicago.edu
Mon Aug 25 22:46:38 CDT 2014
Author: wozniak
Date: 2014-08-25 22:46:38 -0500 (Mon, 25 Aug 2014)
New Revision: 8230
Modified:
usertools/plotter/src/plotter/Lines.java
Log:
Support date axes
Modified: usertools/plotter/src/plotter/Lines.java
===================================================================
--- usertools/plotter/src/plotter/Lines.java 2014-08-22 20:23:09 UTC (rev 8229)
+++ usertools/plotter/src/plotter/Lines.java 2014-08-26 03:46:38 UTC (rev 8230)
@@ -19,6 +19,7 @@
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.annotations.XYTextAnnotation;
+import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.LogAxis;
import org.jfree.chart.axis.LogarithmicAxis;
import org.jfree.chart.axis.NumberAxis;
@@ -120,16 +121,12 @@
{
File file = new File(name);
Util.verbose("open: " + file);
- List<String> lines = null;
double[][] array;
try
{
- lines = LineReader.read(file);
-
+ List<String> lines = LineReader.read(file);
if (lines == null)
- {
System.err.println("Problem when reading: "+file);
- }
array = LineReader.array(lines);
}
catch (FileNotFoundException e)
@@ -142,18 +139,24 @@
(e.getMessage() + "\n" + "In file: " + file);
}
- 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);
+ checkRead(name, array);
data.add(array);
addLabel(name, labels);
Util.verbose("array:\n" + toString(array));
}
}
+ static void checkRead(String name, double[][] array)
+ throws UserInputException
+ {
+ 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);
+ }
+
/**
Generate simple plot.
@param collection The x,y data.
@@ -256,6 +259,7 @@
private static void setupPlot(JFreeChart chart,
XYSeriesCollection collection)
+ throws UserInputException
{
XYPlot plot = chart.getXYPlot();
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
@@ -283,6 +287,7 @@
}
static void setAxes(XYPlot plot)
+ throws UserInputException
{
setAxisTypes(plot);
@@ -315,14 +320,20 @@
private static void setAxisTypes(XYPlot plot)
+ throws UserInputException
{
if (axis_x_type.equals("logarithmic"))
{
NumberAxis domainAxis = new LogarithmicAxis(xlabel);
plot.setDomainAxis(domainAxis);
}
+ else if (axis_x_type.equals("date"))
+ {
+ DateAxis dateAxis = new DateAxis(xlabel);
+ plot.setDomainAxis(dateAxis);
+ }
else if (!axis_x_type.equals("normal"))
- throw new RuntimeException
+ throw new UserInputException
("Invalid axis.x type: " + axis_x_type);
if (axis_y_type.equals("logarithmic"))
@@ -331,7 +342,7 @@
plot.setRangeAxis(rangeAxis);
}
else if (!axis_y_type.equals("normal"))
- throw new RuntimeException
+ throw new UserInputException
("Invalid axis.y type: " + axis_y_type);
}
More information about the Swift-commit
mailing list