JAL-2277 Improvement to support html+svg export in wrap mode bug/JAL-2277_html-output-wrapped-mode
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 25 Oct 2016 10:22:10 +0000 (11:22 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 25 Oct 2016 10:22:10 +0000 (11:22 +0100)
src/jalview/io/HtmlSvgOutput.java

index 68173ff..decb06f 100644 (file)
@@ -148,8 +148,16 @@ public class HtmlSvgOutput
             g2.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
                     SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
           }
+          if (av.getWrapAlignment())
+          {
+            printWrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
+                    g1, g2);
+          }
+          else
+          {
           printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
                   g1, g2);
+          }
 
           String titleSvgData = g1.getSVGDocument();
           String alignSvgData = g2.getSVGDocument();
@@ -207,7 +215,8 @@ public class HtmlSvgOutput
                             exportData.getStartEndPostions(),
                             av.getColumnSelection());
           }
-          String htmlData = getHtml(titleSvgData, alignSvgData, jsonData);
+          String htmlData = getHtml(titleSvgData, alignSvgData, jsonData,
+                  av.getWrapAlignment());
           FileOutputStream out = new FileOutputStream(fileX);
           out.write(htmlData.getBytes());
           out.flush();
@@ -388,8 +397,14 @@ public class HtmlSvgOutput
     return Printable.PAGE_EXISTS;
   }
 
+  public int printWrapped(int pwidth, int pheight, int pi, Graphics... pg)
+          throws PrinterException
+  {
+    return ap.printWrappedAlignment(pg[1], pwidth, pheight, pi);
+  }
+
   private String getHtml(String titleSvg, String alignmentSvg,
-          String jsonData)
+          String jsonData, boolean wrapped)
   {
     StringBuilder htmlSvg = new StringBuilder();
     htmlSvg.append("<html>\n");
@@ -429,8 +444,9 @@ public class HtmlSvgOutput
               + ".facebox_hide { z-index:-100; }\n"
               + ".facebox_overlayBG { background-color: #000;  z-index: 99;  }");
     }
-
     htmlSvg.append("</style>");
+    if (!wrapped)
+    {
     htmlSvg.append("<div class=\"main-container\" \n>");
     htmlSvg.append("<div class=\"titlex\">\n");
     htmlSvg.append("<div class=\"sub-category-container\"> \n");
@@ -451,6 +467,15 @@ public class HtmlSvgOutput
             + "subCatContainer.scrollTop($(this).scrollTop());\n});\n");
 
     htmlSvg.append("</script>\n");
+    }
+    else
+    {
+      htmlSvg.append("<div>\n")
+              .append(alignmentSvg).append("</div>");
+      htmlSvg.append("<script language=\"JavaScript\" type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js\"></script>\n"
+              + "<script language=\"JavaScript\" type=\"text/javascript\"  src=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js\"></script>\n");
+
+    }
 
     // javascript for launching file in Jalview