[Swift-commit] r4636 - in usertools/plotter: . build etc old_scripts src/plotter

jonmon at ci.uchicago.edu jonmon at ci.uchicago.edu
Mon Jun 20 14:45:11 CDT 2011


Author: jonmon
Date: 2011-06-20 14:45:11 -0500 (Mon, 20 Jun 2011)
New Revision: 4636

Added:
   usertools/plotter/build/
   usertools/plotter/build/plotter/
   usertools/plotter/etc/
   usertools/plotter/etc/manifest
   usertools/plotter/old_scripts/classpath.zsh
   usertools/plotter/old_scripts/manifest.old
Removed:
   usertools/plotter/classpath.zsh
Modified:
   usertools/plotter/build.xml
   usertools/plotter/src/plotter/LineReader.java
   usertools/plotter/src/plotter/Lines.java
   usertools/plotter/src/plotter/Plotter.java
   usertools/plotter/src/plotter/Util.java
   usertools/plotter/swift_plotter.zsh
Log:
o fixed a bug where labels were being set to ""
o added functionality to compile into jar


Modified: usertools/plotter/build.xml
===================================================================
--- usertools/plotter/build.xml	2011-06-20 14:59:48 UTC (rev 4635)
+++ usertools/plotter/build.xml	2011-06-20 19:45:11 UTC (rev 4636)
@@ -11,8 +11,9 @@
           depends="compile" />
 
   <target name="compile">
-    <javac includeAntRuntime="false"
+    <javac includeAntRuntime="no"
            srcdir="src"
+           destdir="build"
            classpath="${classpath}"
            listfiles="${lf}"
            debug="true"
@@ -21,10 +22,18 @@
     </javac>
   </target>
 
+  <target name="jar">
+    <jar destfile="lib/plotter.jar"
+         basedir="build"
+         manifest="etc/manifest" />
+  </target>
+
   <target name="clean">
     <delete>
-      <fileset dir="src/plotter" includes="**/*.class"/>
+      <fileset dir="build/plotter" includes="**/*.class"/>
     </delete>
+    <delete file="lib/plotter.jar" />
+    <delete file="build/Plotter.class" />
   </target>
 
 </project>

Deleted: usertools/plotter/classpath.zsh
===================================================================
--- usertools/plotter/classpath.zsh	2011-06-20 14:59:48 UTC (rev 4635)
+++ usertools/plotter/classpath.zsh	2011-06-20 19:45:11 UTC (rev 4636)
@@ -1,17 +0,0 @@
-
-# Source this to set up classpath for plotter runs
-# classpath stored in ${CP}
-
-if [[ $( uname ) == CYGWIN* ]]
-then
-    typeset -T CP cp ";"
-    cp+=c:/cygwin${PLOTTERS}/src
-    for jar in ${PLOTTERS}/lib/*.jar
-    do
-      cp+=c:/cygwin${jar}
-    done
-else
-    typeset -T CP cp
-    CP=${CLASSPATH}:${PLOTTERS}/src
-    cp+=( ${PLOTTERS}/lib/*.jar )
-fi

Added: usertools/plotter/etc/manifest
===================================================================
--- usertools/plotter/etc/manifest	                        (rev 0)
+++ usertools/plotter/etc/manifest	2011-06-20 19:45:11 UTC (rev 4636)
@@ -0,0 +1,10 @@
+Class-Path: build 
+ colt.jar 
+ java-getopt-1.0.13.jar 
+ jfreechart-1.0.13.jar 
+ xmlgraphics-commons-1.4svn.jar 
+ commons-io-1.4.jar 
+ jcommon-1.0.16.jar 
+ junit.jar
+Main-Class: Plotter
+

Copied: usertools/plotter/old_scripts/classpath.zsh (from rev 4635, usertools/plotter/classpath.zsh)
===================================================================
--- usertools/plotter/old_scripts/classpath.zsh	                        (rev 0)
+++ usertools/plotter/old_scripts/classpath.zsh	2011-06-20 19:45:11 UTC (rev 4636)
@@ -0,0 +1,17 @@
+
+# Source this to set up classpath for plotter runs
+# classpath stored in ${CP}
+
+if [[ $( uname ) == CYGWIN* ]]
+then
+    typeset -T CP cp ";"
+    cp+=c:/cygwin${PLOTTERS}/src
+    for jar in ${PLOTTERS}/lib/*.jar
+    do
+      cp+=c:/cygwin${jar}
+    done
+else
+    typeset -T CP cp
+    CP=${CLASSPATH}:${PLOTTERS}/src
+    cp+=( ${PLOTTERS}/lib/*.jar )
+fi

Added: usertools/plotter/old_scripts/manifest.old
===================================================================
--- usertools/plotter/old_scripts/manifest.old	                        (rev 0)
+++ usertools/plotter/old_scripts/manifest.old	2011-06-20 19:45:11 UTC (rev 4636)
@@ -0,0 +1,10 @@
+Class-Path: /Users/jonmon/Library/Swift/usertools/plotter/plotter 
+ /Users/jonmon/Library/Swift/usertools/plotter/lib/colt.jar 
+ /Users/jonmon/Library/Swift/usertools/plotter/lib/java-getopt-1.0.13.jar 
+ /Users/jonmon/Library/Swift/usertools/plotter/lib/jfreechart-1.0.13.jar 
+ /Users/jonmon/Library/Swift/usertools/plotter/lib/xmlgraphics-commons-1.4svn.jar 
+ /Users/jonmon/Library/Swift/usertools/plotter/lib/commons-io-1.4.jar 
+ /Users/jonmon/Library/Swift/usertools/plotter/lib/jcommon-1.0.16.jar 
+ /Users/jonmon/Library/Swift/usertools/plotter/lib/junit.jar
+Main-Class: plotter.Plotter
+

Modified: usertools/plotter/src/plotter/LineReader.java
===================================================================
--- usertools/plotter/src/plotter/LineReader.java	2011-06-20 14:59:48 UTC (rev 4635)
+++ usertools/plotter/src/plotter/LineReader.java	2011-06-20 19:45:11 UTC (rev 4636)
@@ -12,9 +12,6 @@
  * */
 public class LineReader
 {
-    LineReader()
-    {}
-
     public static List<String> read(File file)
         throws FileNotFoundException
     {

Modified: usertools/plotter/src/plotter/Lines.java
===================================================================
--- usertools/plotter/src/plotter/Lines.java	2011-06-20 14:59:48 UTC (rev 4635)
+++ usertools/plotter/src/plotter/Lines.java	2011-06-20 19:45:11 UTC (rev 4636)
@@ -9,6 +9,7 @@
 
 import org.apache.commons.io.IOUtils;
 import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D;
+import org.apache.xmlgraphics.java2d.GraphicContext;
 import org.jfree.chart.ChartFactory;
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.axis.NumberAxis;
@@ -26,6 +27,7 @@
 {
     static Properties properties;
 
+    // defualt this is not a Black and White plot
     public static boolean bw = false;
 
     static int width = 400;
@@ -40,6 +42,92 @@
     static boolean withLegend = true;
 
     /**
+       Args: Lines <properties> <output file> <data file>*
+       Reads settings from properties: see scanProperties()
+       Produces EPS output file
+       Data files are two-columns of numbers each -
+       see LineReader.read() and LineReader.array()
+    */
+    public void plotter(String[] args)
+    {
+        // Settings:
+        boolean verbose = false;
+
+        Getopt g = new Getopt("testprog", args, "v");
+        int c = -1;
+        while ((c = g.getopt()) != -1)
+        {
+            switch (c)
+            {
+                case 'v':
+                    verbose = true;
+            }
+        }
+
+        if (args.length < 3)
+        {
+            System.err.println
+                ("usage: [<options>] <properties> <output> <data>*");
+            System.exit(2);
+        }
+
+        Bits.init();
+        Util.verbose(verbose);
+
+        String propFile = args[0];
+        String output = args[1];
+        List<String> names = new ArrayList<String>();
+        for (int i = 2; i < args.length; i++)
+            names.add(args[i]);
+
+        String title = null;
+        String xlabel = null;
+        String ylabel = null;
+        List<double[][]> data = new ArrayList<double[][]>();
+        List<String> labels = new ArrayList<String>();
+
+        properties = new Properties();
+        load(propFile);
+        title = properties.getProperty("title");
+        xlabel = properties.getProperty("xlabel");
+        ylabel = properties.getProperty("ylabel");
+
+        scanProperties();
+
+        for (String name : names)
+        {
+            File file = new File(name);
+            Util.verbose("open: " + file);
+            List<String> lines = null;
+            try
+            {
+                lines = LineReader.read(file);
+
+                if (lines == null)
+                {
+                    System.err.println("Problem when reading: "+file);
+                }
+            }
+            catch (FileNotFoundException e)
+            {
+                System.err.println("not found: " + file);
+                System.exit(1);
+            }
+            double[][] array = LineReader.array(lines);
+            data.add(array);
+            // System.out.println(Arrays.toString(array[0]));
+            // System.out.println(Arrays.toString(array[1]));
+            addLabel(name, labels);
+            Util.verbose("array:\n" + toString(array));
+        }
+
+        XYSeriesCollection collection = Util.collection(data, labels,
+                                                        names);
+
+        plot(collection, title, xlabel, ylabel, output);
+    }
+
+    /**
        Generate simple plot.
        @param collection The x,y data.
        @param title Plot title.
@@ -58,17 +146,20 @@
 
         try
         {
-            out = new FileOutputStream(output);
-            out = new BufferedOutputStream(out);
+            /* out = new FileOutputStream(output); */
+            /* out = new BufferedOutputStream(out); */
 
+            /* The above seemed confusing: readability wise, makes perfect sense syntactically wise */
+            out = new BufferedOutputStream( new FileOutputStream( output ) );
+
             g2d = new EPSDocumentGraphics2D(false);
             g2d.setGraphicContext
-                (new org.apache.xmlgraphics.java2d.GraphicContext());
+                (new GraphicContext());
 
             rectangle = new Rectangle2D.Double(0, 0, width, height);
 
             g2d.setGraphicContext
-                (new org.apache.xmlgraphics.java2d.GraphicContext());
+                (new GraphicContext());
             g2d.setupDocument(out, width, height);
         }
         catch (IOException e)
@@ -82,6 +173,8 @@
             (title, xlabel, ylabel, collection,
              PlotOrientation.VERTICAL, withLegend, false, false);
 
+
+
         setupPlot(chart, collection);
         chart.draw(g2d, rectangle);
 
@@ -91,7 +184,7 @@
         }
         catch (Exception e)
         {
-            System.err.println("Err!" + e);
+            System.err.println("Error!" + e);
         }
 
         IOUtils.closeQuietly(out);
@@ -104,6 +197,10 @@
                                   XYSeriesCollection collection)
     {
         XYPlot plot = chart.getXYPlot();
+        // System.out.println(plot.getDomainAxis().getRange().getLowerBound());
+        // System.out.println(plot.getDomainAxis().getRange().getUpperBound());
+        // System.out.println(plot.getRangeAxis().getRange().getLowerBound());
+        // System.out.println(plot.getRangeAxis().getRange().getUpperBound());
         XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
         if (bw)
             for (int i = 0; i < plot.getSeriesCount(); i++)
@@ -125,7 +222,6 @@
     {
         // Actual values: modify if necessary
         double axmin, axmax, aymin, aymax;
-
         if (xmin != null || xmax != null)
         {
             NumberAxis axis = (NumberAxis) plot.getDomainAxis();
@@ -149,106 +245,7 @@
         }
     }
 
-    /**
-       Args: Lines <properties> <output file> <data file>*
-       Reads settings from properties: see scanProperties()
-       Produces EPS output file
-       Data files are two-columns of numbers each -
-       see LineReader.read() and LineReader.array()
-    */
-    public void plotter(String[] args)
-    {
-        // Settings:
-        boolean verbose = false;
 
-        Getopt g = new Getopt("testprog", args, "v");
-        int c = -1;
-        while ((c = g.getopt()) != -1)
-        {
-            switch (c)
-            {
-                case 'v':
-                    verbose = true;
-            }
-        }
-
-        if (args.length < 3)
-        {
-            System.err.println
-                ("usage: [<options>] <properties> <output> <data>*");
-            System.exit(2);
-        }
-
-        Bits.init();
-        Util.verbose(verbose);
-
-        String propFile = args[0];
-        String output = args[1];
-        List<String> names = new ArrayList<String>();
-        for (int i = 2; i < args.length; i++)
-            names.add(args[i]);
-
-        String title = null;
-        String xlabel = null;
-        String ylabel = null;
-        List<double[][]> data = new ArrayList<double[][]>();
-        List<String> labels = new ArrayList<String>();
-
-        properties = new Properties();
-        load(propFile);
-        title = properties.getProperty("title");
-        xlabel = properties.getProperty("xlabel");
-        ylabel = properties.getProperty("ylabel");
-
-        scanProperties();
-
-        for (String name : names)
-        {
-            File file = new File(name);
-            Util.verbose("open: " + file);
-            List<String> lines = null;
-            try
-            {
-                lines = LineReader.read(file);
-            }
-            catch (FileNotFoundException e)
-            {
-                System.err.println("not found: " + file);
-                System.exit(1);
-            }
-            double[][] array = LineReader.array(lines);
-            data.add(array);
-            addLabel(name, labels);
-            Util.verbose("array:\n" + toString(array));
-        }
-
-        XYSeriesCollection collection = Util.collection(data, labels,
-                                                        names);
-
-        plot(collection, title, xlabel, ylabel, output);
-    }
-
-    static void load(String propFile)
-    {
-        try
-        {
-            if (propFile.equals("-"))
-                properties.load(System.in);
-            else
-                properties.load(new FileInputStream(propFile));
-        }
-        catch (FileNotFoundException e)
-        {
-            System.err.println(e);
-            System.exit(1);
-        }
-        catch (IOException e)
-        {
-            e.printStackTrace();
-            System.exit(1);
-        }
-    }
-
     /**
        Various plot properties.  All are currently optional
 
@@ -297,6 +294,27 @@
             withLegend = Boolean.parseBoolean(tmp);
     }
 
+    static void load(String propFile)
+    {
+        try
+        {
+            if (propFile.equals("-"))
+                properties.load(System.in);
+            else
+                properties.load(new FileInputStream(propFile));
+        }
+        catch (FileNotFoundException e)
+        {
+            System.err.println(e);
+            System.exit(1);
+        }
+        catch (IOException e)
+        {
+            e.printStackTrace();
+            System.exit(1);
+        }
+    }
+
     /**
        Arrays.copyOfRange is a Java 1.6 feature.
        This has the same signature.

Modified: usertools/plotter/src/plotter/Plotter.java
===================================================================
--- usertools/plotter/src/plotter/Plotter.java	2011-06-20 14:59:48 UTC (rev 4635)
+++ usertools/plotter/src/plotter/Plotter.java	2011-06-20 19:45:11 UTC (rev 4636)
@@ -1,4 +1,3 @@
-package plotter;
 
 import plotter.Lines;
 import plotter.Dual;

Modified: usertools/plotter/src/plotter/Util.java
===================================================================
--- usertools/plotter/src/plotter/Util.java	2011-06-20 14:59:48 UTC (rev 4635)
+++ usertools/plotter/src/plotter/Util.java	2011-06-20 19:45:11 UTC (rev 4636)
@@ -26,14 +26,20 @@
         int count = 0;
         for (double[][] d : data)
         {
+            /* What does this do? */
+            /* label is set to something but then immediately overwritten */
+            /* That catch should not happen */
             String label = "data: " + count;
             try
             {
-                label = labels.get(count);
+                String s = labels.get(count);
+                if( !(s.equals("")) )
+                    label = s;
             }
             catch (IndexOutOfBoundsException e)
             {}
 
+            System.out.println( "label: "+label );
             XYSeries series = new XYSeries(label);
             for (int i = 0; i < d.length; i++)
                 series.add(d[i][0], d[i][1]);

Modified: usertools/plotter/swift_plotter.zsh
===================================================================
--- usertools/plotter/swift_plotter.zsh	2011-06-20 14:59:48 UTC (rev 4635)
+++ usertools/plotter/swift_plotter.zsh	2011-06-20 19:45:11 UTC (rev 4636)
@@ -1,10 +1,11 @@
 #!/bin/zsh
 
-PLOTTERS=$( cd $( dirname $0 ) ; /bin/pwd )
+#PLOTTERS=$( cd $( dirname $0 ) ; /bin/pwd )
 
 # declare -p PLOTTERS
 
-source ${PLOTTERS}/classpath.zsh
-[[ $? != 0 ]] && print "Could not build CLASSPATH!" && return 1
+#source ${PLOTTERS}/classpath.zsh
+#[[ $? != 0 ]] && print "Could not build CLASSPATH!" && return 1
 
-java -ea -cp ${CP} plotter.Plotter ${*}
+#java -ea -cp ${CP} plotter.Plotter ${*}
+java -jar lib/plotter.jar ${*}




More information about the Swift-commit mailing list