Merge branch 'features/JAL-1605_html-svg-export' into develop
authorCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 5 Dec 2014 14:59:55 +0000 (14:59 +0000)
committerCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 5 Dec 2014 14:59:55 +0000 (14:59 +0000)
1  2 
src/jalview/bin/Jalview.java
src/jalview/gui/AlignFrame.java
src/jalview/io/HtmlSvgOutput.java

@@@ -22,6 -22,7 +22,7 @@@ package jalview.bin
  
  import jalview.gui.AlignFrame;
  import jalview.gui.Desktop;
+ import jalview.io.HtmlSvgOutput;
  import jalview.util.MessageManager;
  import jalview.util.Platform;
  import jalview.ws.jws2.Jws2Discoverer;
@@@ -79,6 -80,11 +80,6 @@@ public class Jalvie
    }
  
    /**
 -   * Put protein=true for get a protein example
 -   */
 -  private static boolean protein = false;
 -
 -  /**
     * main class for Jalview application
     * 
     * @param args
              System.out.println("Creating SVG image: " + file);
              continue;
            }
+           else if (format.equalsIgnoreCase("html"))
+           {
+             File imageFile = new java.io.File(file);
+             imageName = imageFile.getName();
+             new HtmlSvgOutput(new java.io.File(file), af.alignPanel);
+             System.out.println("Creating HTML image: " + file);
+             continue;
+           }
            else if (format.equalsIgnoreCase("imgMap"))
            {
              af.createImageMap(new java.io.File(file), imageName);
      // ////////////////////
  
      if (!headless && file == null && vamsasImport == null
 -            && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true)
 -            && protein == true)
 +            && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
      {
        file = jalview.bin.Cache.getDefault(
                "STARTUP_FILE",
                      + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
                      + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
                      + "-png FILE\tCreate PNG image FILE from alignment.\n"
+                     + "-svg FILE\tCreate SVG image FILE from alignment.\n"
+                     + "-html FILE\tCreate HTML file from alignment.\n"
                      + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
                      + "-eps FILE\tCreate EPS file FILE from alignment.\n"
                      + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
                public void run()
                {
                  Cache.log
 -                        .info("Initialising googletracker for usage stats.");
 +                        .debug("Initialising googletracker for usage stats.");
                  Cache.initGoogleTracker();
                  Cache.log.debug("Tracking enabled.");
                }
              {
                public void run()
                {
 -                Cache.log.info("Not enabling Google Tracking.");
 +                Cache.log.debug("Not enabling Google Tracking.");
                }
              }, null, true);
      desktop.addDialogThread(prompter);
@@@ -30,7 -30,6 +30,7 @@@ import jalview.analysis.ParseProperties
  import jalview.analysis.SequenceIdMatcher;
  import jalview.api.AlignViewControllerGuiI;
  import jalview.api.AlignViewControllerI;
 +import jalview.api.AlignmentViewPanel;
  import jalview.api.analysis.ScoreModelI;
  import jalview.bin.Cache;
  import jalview.commands.CommandI;
@@@ -55,7 -54,6 +55,7 @@@ import jalview.datamodel.SequenceGroup
  import jalview.datamodel.SequenceI;
  import jalview.io.AlignmentProperties;
  import jalview.io.AnnotationFile;
 +import jalview.io.BioJsHTMLOutput;
  import jalview.io.FeaturesFile;
  import jalview.io.FileLoader;
  import jalview.io.FormatAdapter;
@@@ -117,7 -115,6 +117,7 @@@ import java.beans.PropertyChangeEvent
  import java.io.File;
  import java.net.URL;
  import java.util.ArrayList;
 +import java.util.Arrays;
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.List;
@@@ -1233,15 -1230,9 +1233,15 @@@ public class AlignFrame extends GAlignF
      // new HTMLOutput(alignPanel,
      // alignPanel.getSeqPanel().seqCanvas.getSequenceRenderer(),
      // alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
-     new HtmlSvgOutput(alignPanel);
+     new HtmlSvgOutput(null, alignPanel);
    }
  
 +  @Override
 +  public void bioJSMenuItem_actionPerformed(ActionEvent e)
 +  {
 +    new BioJsHTMLOutput(alignPanel,
 +            alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
 +  }
    public void createImageMap(File file, String image)
    {
      alignPanel.makePNGImageMap(file, image);
      else if (viewport.getSelectionGroup() != null
              && viewport.getSelectionGroup().getSize() == 1)
      {
 -      int option = JOptionPane
 -              .showConfirmDialog(
 -this,
 -                      "More than one sequece group selection is required for this Job, click \n'Cancel' to edit your selection or 'Ok' to submit the entire sequence.",
 -                      "Invalid selection",
 -                      JOptionPane.OK_CANCEL_OPTION);
 +      int option = JOptionPane.showConfirmDialog(this,
 +              MessageManager.getString("warn.oneseq_msainput_selection"),
 +              MessageManager.getString("label.invalid_selection"),
 +              JOptionPane.OK_CANCEL_OPTION);
        if (option == JOptionPane.OK_OPTION)
        {
          msa = viewport.getAlignmentView(false);
        }
      }
      else
      {
 -      /*
 -       * Vector seqs = viewport.getAlignment().getSequences();
 -       * 
 -       * if (seqs.size() > 1) { msa = new SequenceI[seqs.size()];
 -       * 
 -       * for (int i = 0; i < seqs.size(); i++) { msa[i] = (SequenceI)
 -       * seqs.elementAt(i); } }
 -       */
        msa = viewport.getAlignmentView(false);
      }
      return msa;
              .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
      alignPanel.paintAlignment(true);
    }
 +
 +  /**
 +   * 
 +   * @return alignment panels in this alignemnt frame
 +   */
 +  public List<AlignmentViewPanel> getAlignPanels()
 +  {
 +    return alignPanels == null ? Arrays.asList(alignPanel) : alignPanels;
 +  }
  }
  
  class PrintThread extends Thread
@@@ -29,20 -29,26 +29,26 @@@ public class HtmlSvgOutpu
  
    AnnotationPanel annotationPanel;
  
-   public HtmlSvgOutput(AlignmentPanel ap)
+   public HtmlSvgOutput(File file, AlignmentPanel ap)
    {
  
        this.av = ap.av;
        this.ap = ap;
        this.annotationPanel = ap.getAnnotationPanel();
-     generateHtmlSvgOutput();
+     generateHtmlSvgOutput(file);
    }
  
-   public void generateHtmlSvgOutput()
+   public void generateHtmlSvgOutput(File file)
    {
-     File file = null;
      try
      {
+       if (file == null /*
+                         * && !(System.getProperty("java.awt.headless") != null
+                         * && System
+                         * .getProperty("java.awt.headless").equals("true"))
+                         */)
+       {
        JalviewFileChooser chooser = getHTMLChooser();
        chooser.setFileView(new jalview.io.JalviewFileView());
        chooser.setDialogTitle(ap.alignFrame.getTitle());
@@@ -55,6 -61,7 +61,7 @@@
                  .getSelectedFile().getParent());
          file = chooser.getSelectedFile();
        }
+       }
  
        AlignmentDimension aDimension = ap.getAlignmentDimension();
        SVGGraphics2D g1 = new SVGGraphics2D(aDimension.getWidth(),
    private String getHtml(String titleSvg, String alignmentSvg)
    {
      StringBuilder htmlSvg = new StringBuilder();
 -    htmlSvg.append("<html><style type=\"text/css\">" + "div.title {"
 -            + "height: 100%;" + "width: 9%;" + "float: left;" + "}"
 -            + "div.align {" + "height: 100%;" + "width: 91%;"
 -            + "overflow: scroll;" + "float: right;" + "}" + "</style>"
 +    htmlSvg.append("<html><style type=\"text/css\"> div.title {"
 +            + "height: 100%; width:11%; float: left; }"
 +            + "div.align { height: 100%; width:89%;"
 +            + "overflow: scroll; float: right; } </style>"
              + "<div style=\"width:100%; height:100%; overflow: hidden\">"
              + "<div class=\"title\">");
      htmlSvg.append(titleSvg);