[Swift-commit] r5915 - usertools/plotter/src/plotter
wozniak at ci.uchicago.edu
wozniak at ci.uchicago.edu
Sat Sep 1 09:58:36 CDT 2012
Author: wozniak
Date: 2012-09-01 09:58:35 -0500 (Sat, 01 Sep 2012)
New Revision: 5915
Added:
usertools/plotter/src/plotter/UserInputException.java
Modified:
usertools/plotter/src/plotter/Lines.java
usertools/plotter/src/plotter/Plotter.java
Log:
Better error checking
Modified: usertools/plotter/src/plotter/Lines.java
===================================================================
--- usertools/plotter/src/plotter/Lines.java 2012-09-01 00:47:24 UTC (rev 5914)
+++ usertools/plotter/src/plotter/Lines.java 2012-09-01 14:58:35 UTC (rev 5915)
@@ -63,6 +63,7 @@
see LineReader.read() and LineReader.array()
*/
public void plotter(String[] args)
+ throws UserInputException
{
// Settings:
boolean verbose = false;
@@ -115,6 +116,8 @@
System.exit(1);
}
double[][] array = LineReader.array(lines);
+ if (array[0].length != 2)
+ throw new UserInputException("file is not two-column: " + name);
data.add(array);
addLabel(name, labels);
Util.verbose("array:\n" + toString(array));
@@ -187,12 +190,13 @@
return true;
}
/**
+ Stores the data in the given resulting Collection
Stores the label as the Series key.
Stores the filename as the Series description.
*/
static XYSeriesCollection collection(List<double[][]> data,
- List<String> labels,
- List<String> names)
+ List<String> labels,
+ List<String> names)
{
final XYSeriesCollection collection = new XYSeriesCollection();
Modified: usertools/plotter/src/plotter/Plotter.java
===================================================================
--- usertools/plotter/src/plotter/Plotter.java 2012-09-01 00:47:24 UTC (rev 5914)
+++ usertools/plotter/src/plotter/Plotter.java 2012-09-01 14:58:35 UTC (rev 5915)
@@ -10,24 +10,26 @@
{
public static void main(String[] args)
{
- Getopt plot = new Getopt( "Plotter", args, "bdhs");
- /*
- * Fix this check: Need to check to see if the specify one of the types of plots first
- * then check to see if the argument counts is correct.
- */
- if (args.length < 4 )
+ try
{
- usage();
- }
+ Getopt plot = new Getopt( "Plotter", args, "bdhs");
+ /*
+ * Fix this check: Need to check to see if the specify one of the types of plots first
+ * then check to see if the argument counts is correct.
+ */
+ if (args.length < 4 )
+ {
+ usage();
+ }
- /* Gather the arguments except the first one */
- String[] tmp = new String[args.length - 1];
- for( int i = 0; i < tmp.length; ++i )
- {
- tmp[i] = args[i+1];
- }
- switch( plot.getopt() )
- {
+ /* Gather the arguments except the first one */
+ String[] tmp = new String[args.length - 1];
+ for( int i = 0; i < tmp.length; ++i )
+ {
+ tmp[i] = args[i+1];
+ }
+ switch( plot.getopt() )
+ {
/* If asking for a single labeled Y-axis */
case 's':
{
@@ -55,7 +57,14 @@
{
usage();
}
+ }
}
+ catch (UserInputException e)
+ {
+ System.out.println("input error: ");
+ System.out.println(e.getMessage());
+ // e.printStackTrace();
+ }
}
static List<String> dataFileList(String[] args, int start)
Added: usertools/plotter/src/plotter/UserInputException.java
===================================================================
--- usertools/plotter/src/plotter/UserInputException.java (rev 0)
+++ usertools/plotter/src/plotter/UserInputException.java 2012-09-01 14:58:35 UTC (rev 5915)
@@ -0,0 +1,12 @@
+
+package plotter;
+
+public class UserInputException extends Exception
+{
+ public UserInputException(String s)
+ {
+ super(s);
+ }
+
+ private static final long serialVersionUID = 1L;
+}
More information about the Swift-commit
mailing list