Package de.binfalse.martin.algorithm

Examples of de.binfalse.martin.algorithm.Map2D


    String infile = null, outfile = null;
    int width = 500, height = 500;
    double startTime = 0, endTime = 60*60, startMz = 0, endMz = 1000;
    Scaler scaler = null;
    ColorModel cm = null;
    Map2D mapper = null;
    BufferedImage bi;
   
    for (int i = 0; i < args.length; i++)
    {
      if (i < args.length - 1)
      {
        if (args[i].equals ("--stime"))
        {
          startTime = Double.parseDouble (args[++i]);
          continue;
        }
        if (args[i].equals ("--etime"))
        {
          endTime = Double.parseDouble (args[++i]);
          continue;
        }
       
        if (args[i].equals ("--smz"))
        {
          startMz = Double.parseDouble (args[++i]);
          continue;
        }
        if (args[i].equals ("--emz"))
        {
          endMz = Double.parseDouble (args[++i]);
          continue;
        }
       
        if (args[i].equals ("--in"))
        {
          infile = args[++i];
          continue;
        }
        if (args[i].equals ("--out"))
        {
          outfile = args[++i];
          continue;
        }
        if (args[i].equals ("--width"))
        {
          width = Integer.parseInt (args[++i]);
          continue;
        }
        if (args[i].equals ("--height"))
        {
          height = Integer.parseInt (args[++i]);
          continue;
        }
      }
      if (args[i].equals ("--help") || args[i].equals ("-h"))
      {
        help = true;
        continue;
      }
      if (args[i].equals ("--motley"))
      {
        cm = new ColorModelMotley ();
        continue;
      }
      if (args[i].equals ("--heat"))
      {
        cm = new ColorModelHeat ();
        continue;
      }
      if (args[i].equals ("--gray"))
      {
        cm = new ColorModelGray ();
        continue;
      }
      if (args[i].equals ("--log"))
      {
        scaler = new ScalerLog ();
        continue;
      }
      if (args[i].equals ("--sqrt"))
      {
        scaler = new ScalerSQRT ();
        continue;
      }
      if (args[i].equals ("--noscale"))
      {
        scaler = new ScalerNone ();
        continue;
      }
      if (args[i].equals ("--legend"))
      {
        legend = true;
        continue;
      }
      err.add ("Don't understand " + args[i]);
    }
   
    // checks
   
    if (infile == null)
    {
      err.add ("please specify an file to read from");
    }
    else if (!new File (infile).canRead ())
    {
      err.add ("can't read " + infile);
    }
    else
    {
      String ext = infile.substring (infile.lastIndexOf(".") + 1);
      if (ext.equals ("mzxml"))
        mapper = new Map2DMZXML (new MSXMLParser (infile, true));
      else if (ext.equals ("pl"))
        mapper = new Map2DPL (new MountainList (new File (infile)));
      else
        err.add ("Don't know file format");
    }
   
    if (outfile == null)
    {
      err.add ("please specify an file to write to");
    }
    else if (new File (outfile).exists ())
    {
      err.add (outfile + " exists, we stop here to prevent loss of data...");
    }
   

    if (width < 200 || height < 200)
    {
      err.add ("Map has to be at least 200 x 200 pixels");
    }
    if (startMz < 0 || endMz <= startMz)
    {
      err.add ("endMz has to be bigger than startMz, both positive");
    }
    if (startTime < 0 || endTime <= startTime)
    {
      err.add ("endTime has to be bigger than startTime, both positive");
    }
   
   
    if (err.size () > 0 || help)
    {
      if (err.size () > 0)
      {
        System.err.println ("Following errors occoured:");
        for (int i = 0; i < err.size (); i++)
          System.err.println ("\t-> " + err.elementAt (i));
        System.err.println ();
      }
      System.out.println ("Arguments:");
      System.out.println ("I/O:");
      System.out.println ("\t--in\t\tfile to read");
      System.out.println ("\t--out\t\there we'll store the pic, only png supported yet");
      System.out.println ("Threshs:");
      System.out.println ("\t--stime\t\tstart retention time in secs - defaults to 0");
      System.out.println ("\t--etime\t\tend retention time in secs - defaults to 3600");
      System.out.println ("\t--smz\t\tmin mz - defaults to 0");
      System.out.println ("\t--emz\t\tmax mz - defaults to 1000");
      System.out.println ("Map settings:");
      System.out.println ("\t--motley\tcolorize the map - default");
      System.out.println ("\t--gray\t\tgray image map");
      System.out.println ("\t--legend\tadd a legend");
      System.out.println ("Scale settings:");
      System.out.println ("\t--log\t\tscale intensities with nat. log - default");
      System.out.println ("\t--sqrt\t\tscale intensities by sqare root");
      System.out.println ("\t--noscale\tdon't scale intensities");
      System.out.println ("help:");
      System.out.println ("\t--help\t\tprint this help message");
     
      System.exit (1);
    }
   
    if (cm == null)
      cm = new ColorModelMotley ();
    if (scaler == null)
      scaler = new ScalerLog ();
   
    if (legend)
      mapper.addLegend (null, null, null);
   
    bi = mapper.createMap (width, height, startTime, endTime, startMz, endMz, scaler, cm, null);
   
    if (bi != null)
    {
      ImageIO.write(bi, "png", new File (outfile));
    }
View Full Code Here


      if (n != javax.swing.JOptionPane.YES_OPTION)
        err.add ("Died because " + outfile + " exists");
    }
   
    String infile = jTextFieldInput.getText ();
    Map2D mapper = null;
    try
    {
      if (infile.length () < 1)
      {
        err.add ("no file to read");
      }
      else if (!new File (infile).canRead ())
      {
        err.add ("can't read " + infile);
      }
      else
      {
        try
        {
          mapper = new Map2DMZXML (new MSXMLParser (infile, true));
        }
        catch (NoClassDefFoundError e)
        {
           System.err.println( e );
          e.printStackTrace();
          javax.swing.JOptionPane.showMessageDialog(this, "Could not find Parser, please check your CLASSPATH " + e.getMessage (),
              "NoClassDefFoundError", javax.swing.JOptionPane.ERROR_MESSAGE);
          err.add ("Could not find Parser, please check your CLASSPATH");
        }
        if (jCheckBoxLegend.isSelected ())
          mapper.addLegend (null, null, null);
      }
    }
    catch (IOException e)
    {
      err.add ("Failed to read: " + infile + " (" + e.getMessage () + ")");
View Full Code Here

TOP

Related Classes of de.binfalse.martin.algorithm.Map2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.