Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/embl/ebi/escience/scufl/tools/XScufl2Dot.java


1   /**
2    * This file is a component of the Taverna project,
3    * and is licensed under the GNU LGPL.
4    * Copyright Tom Oinn, EMBL-EBI
5    */
6   package org.embl.ebi.escience.scufl.tools;
7   
8   import org.embl.ebi.escience.scufl.ScuflModel;
9   import org.embl.ebi.escience.scufl.parser.XScuflParser;
10  import org.embl.ebi.escience.scufl.view.DotView;
11  
12  // IO Imports
13  import java.io.File;
14  import java.io.FileWriter;
15  import java.io.IOException;
16  import java.io.PrintWriter;
17  
18  import java.lang.ArrayIndexOutOfBoundsException;
19  import java.lang.Exception;
20  import java.lang.String;
21  import java.lang.System;
22  
23  
24  
25  /**
26   * Command line tool to read in an XScufl definition and produce the dot
27   * file corresponding to it.
28   * @author Tom Oinn
29   */
30  public class XScufl2Dot {
31  
32      public static void main(String[] args) throws Exception {
33    // First command line argument is the location of the
34    // xscufl file to load into the data model.
35    try {
36        int portPolicy = DotView.ALL;
37        String filename = args[0];
38        if (args.length == 3) {
39      // defaults to showing all ports.
40      String portPolicyString = args[2];
41      if (portPolicyString.equalsIgnoreCase("none")) {
42          portPolicy = DotView.NONE;
43      }
44      else if (portPolicyString.equalsIgnoreCase("bound")) {
45          portPolicy = DotView.BOUND;
46      }
47      
48        }
49        String outfilename = args[1];
50        PrintWriter out = new PrintWriter(new FileWriter(outfilename));
51  
52        // Create a new scuflmodel
53        ScuflModel model = new ScuflModel();
54        // Register a dot view with it
55        DotView view = new DotView(model);
56        //model.addListener(new ScuflModelEventPrinter(null));
57        // Decide how much information to show
58        view.setPortDisplay(portPolicy);
59        File inputFile = new File(filename);
60        XScuflParser.populate(inputFile.toURL().openStream(), model, null);
61        out.println(view.getDot());
62        out.flush();
63        out.close();
64    }
65    catch (ArrayIndexOutOfBoundsException aioobe) {
66        System.out.println("Usage : ... XScufl2Dot <xscuflfilename> <outputfilename> [none|bound|all]");
67    }
68    catch (IOException ioe) {
69        System.out.println("IOException : "+ioe.getMessage());
70    }
71      }
72  
73  }