JAL-2277 Refactored out duplicated method - printUnwrapped() in HtmlSvgOutput, extern...
[jalview.git] / src / jalview / io / HtmlSvgOutput.java
index 68f9924..e6e698c 100644 (file)
@@ -1,21 +1,41 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.io;
 
-import jalview.datamodel.SequenceI;
+import jalview.api.AlignExportSettingI;
+import jalview.api.FeatureRenderer;
+import jalview.datamodel.AlignmentExportData;
 import jalview.gui.AlignViewport;
 import jalview.gui.AlignmentPanel;
-import jalview.gui.AnnotationPanel;
-import jalview.gui.FeatureRenderer;
 import jalview.gui.HTMLOptions;
+import jalview.gui.IProgressIndicator;
+import jalview.gui.OOMWarning;
 import jalview.math.AlignmentDimension;
 import jalview.util.MessageManager;
 
-import java.awt.Color;
-import java.awt.FontMetrics;
 import java.awt.Graphics;
-import java.awt.print.Printable;
 import java.awt.print.PrinterException;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 
 import org.jfree.graphics2d.svg.SVGGraphics2D;
 import org.jfree.graphics2d.svg.SVGHints;
@@ -25,250 +45,353 @@ public class HtmlSvgOutput
   AlignViewport av;
 
   FeatureRenderer fr;
+
   AlignmentPanel ap;
 
-  AnnotationPanel annotationPanel;
+  private IProgressIndicator pIndicator;
 
-  public HtmlSvgOutput(File file, AlignmentPanel ap)
-  {
+  private long pSessionId;
+
+  private boolean headless;
 
-      this.av = ap.av;
-      this.ap = ap;
-      this.annotationPanel = ap.getAnnotationPanel();
-    generateHtmlSvgOutput(file);
+  public HtmlSvgOutput(AlignmentPanel ap)
+  {
+    this.av = ap.av;
+    this.ap = ap;
+    fr = ap.cloneFeatureRenderer();
   }
 
   public void generateHtmlSvgOutput(File file)
   {
+    pIndicator = ap.alignFrame;
+    pSessionId = System.currentTimeMillis();
     try
     {
-      if (file == null /*
-                        * && !(System.getProperty("java.awt.headless") != null
-                        * && System
-                        * .getProperty("java.awt.headless").equals("true"))
-                        */)
+      headless = (System.getProperty("java.awt.headless") != null && System
+              .getProperty("java.awt.headless").equals("true"));
+      if (file == null)
       {
+        setProgressMessage(MessageManager.formatMessage(
+                "status.waiting_for_user_to_select_output_file", "HTML"));
+        JalviewFileChooser chooser = getHTMLChooser();
+        chooser.setFileView(new jalview.io.JalviewFileView());
+        chooser.setDialogTitle(ap.alignFrame.getTitle());
+        chooser.setToolTipText(MessageManager.getString("action.save"));
+        int value = chooser.showSaveDialog(ap.alignFrame);
 
-      JalviewFileChooser chooser = getHTMLChooser();
-      chooser.setFileView(new jalview.io.JalviewFileView());
-      chooser.setDialogTitle(ap.alignFrame.getTitle());
-      chooser.setToolTipText(MessageManager.getString("action.save"));
-      int value = chooser.showSaveDialog(ap.alignFrame);
-
-      if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
-      {
-        jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
-                .getSelectedFile().getParent());
-        file = chooser.getSelectedFile();
-      }
+        if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
+        {
+          jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
+                  .getSelectedFile().getParent());
+          file = chooser.getSelectedFile();
+          ap.alignFrame.repaint();
+        }
+        else
+        {
+          setProgressMessage(MessageManager.formatMessage(
+                  "status.cancelled_image_export_operation", "HTML"));
+          return;
+        }
       }
+    } catch (Exception e)
+    {
+      pIndicator.setProgressBar(MessageManager.formatMessage(
+              "info.error_creating_file", "HTML"), pSessionId);
+      e.printStackTrace();
+      return;
+    }
+    final File fileX = file;
+    new Thread()
+    {
+      @Override
+      public void run()
+      {
+        try
+        {
+          setProgressMessage(null);
+          setProgressMessage(MessageManager.formatMessage(
+                  "status.exporting_alignment_as_x_file", "HTML"));
+          AlignmentDimension aDimension = ap.getAlignmentDimension();
+          SVGGraphics2D idPanelGraphics = new SVGGraphics2D(
+                  aDimension.getWidth(),
+                  aDimension.getHeight());
+          SVGGraphics2D alignPanelGraphics = new SVGGraphics2D(
+                  aDimension.getWidth(),
+                  aDimension.getHeight());
 
-      AlignmentDimension aDimension = ap.getAlignmentDimension();
-      SVGGraphics2D g1 = new SVGGraphics2D(aDimension.getWidth(),
-              aDimension.getHeight());
-      SVGGraphics2D g2 = new SVGGraphics2D(aDimension.getWidth(),
-              aDimension.getHeight());
+          String renderStyle = jalview.bin.Cache.getDefault(
+                  "HTML_RENDERING", "Prompt each time");
 
-      String renderStyle = jalview.bin.Cache.getDefault("HTML_RENDERING",
-              "Prompt each time");
+          // If we need to prompt, and if the GUI is visible then
+          // Prompt for rendering style
+          if (renderStyle.equalsIgnoreCase("Prompt each time")
+                  && !(System.getProperty("java.awt.headless") != null && System
+                          .getProperty("java.awt.headless").equals("true")))
+          {
+            HTMLOptions svgOption = new HTMLOptions();
+            renderStyle = svgOption.getValue();
 
-      // If we need to prompt, and if the GUI is visible then
-      // Prompt for rendering style
-      if (renderStyle.equalsIgnoreCase("Prompt each time")
-              && !(System.getProperty("java.awt.headless") != null && System
-                      .getProperty("java.awt.headless").equals("true")))
-      {
-        HTMLOptions svgOption = new HTMLOptions();
-        renderStyle = svgOption.getValue();
+            if (renderStyle == null || svgOption.cancelled)
+            {
+              setProgressMessage(MessageManager.formatMessage(
+                      "status.cancelled_image_export_operation", "HTML"));
+              return;
+            }
+          }
+
+          if (renderStyle.equalsIgnoreCase("Lineart"))
+          {
+            idPanelGraphics.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
+                    SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
+            alignPanelGraphics.setRenderingHint(
+                    SVGHints.KEY_DRAW_STRING_TYPE,
+                    SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
+          }
+          if (av.getWrapAlignment())
+          {
+            printWrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
+                    alignPanelGraphics);
+          }
+          else
+          {
+          printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
+ idPanelGraphics, alignPanelGraphics);
+          }
+
+          String idPanelSvgData = idPanelGraphics.getSVGDocument();
+          String alignPanelSvgData = alignPanelGraphics.getSVGDocument();
+          String jsonData = null;
+          boolean isEmbbedBioJSON = Boolean.valueOf(jalview.bin.Cache
+                  .getDefault("EXPORT_EMBBED_BIOJSON", "true"));
+          if (isEmbbedBioJSON)
+          {
+            AlignExportSettingI exportSettings = new AlignExportSettingI()
+            {
+              @Override
+              public boolean isExportHiddenSequences()
+              {
+                return true;
+              }
+
+              @Override
+              public boolean isExportHiddenColumns()
+              {
+                return true;
+              }
+
+              @Override
+              public boolean isExportAnnotations()
+              {
+                return true;
+              }
+
+              @Override
+              public boolean isExportFeatures()
+              {
+                return true;
+              }
+
+              @Override
+              public boolean isExportGroups()
+              {
+                return true;
+              }
 
-        if (renderStyle == null || svgOption.cancelled)
+              @Override
+              public boolean isCancelled()
+              {
+                return false;
+              }
+
+            };
+            AlignmentExportData exportData = jalview.gui.AlignFrame
+                    .getAlignmentForExport(JSONFile.FILE_DESC, av,
+                            exportSettings);
+            jsonData = new FormatAdapter(ap, exportData.getSettings())
+                    .formatSequences(JSONFile.FILE_DESC,
+                            exportData.getAlignment(),
+                            exportData.getOmitHidden(),
+                            exportData.getStartEndPostions(),
+                            av.getColumnSelection());
+          }
+          String htmlData = getHtml(idPanelSvgData, alignPanelSvgData, jsonData,
+                  av.getWrapAlignment());
+          FileOutputStream out = new FileOutputStream(fileX);
+          out.write(htmlData.getBytes());
+          out.flush();
+          out.close();
+          if (!(System.getProperty("java.awt.headless") != null && System
+                  .getProperty("java.awt.headless").equals("true")))
+          {
+            jalview.util.BrowserLauncher.openURL("file:///" + fileX);
+          }
+        } catch (OutOfMemoryError err)
         {
-          return;
+          System.out.println("########################\n"
+                  + "OUT OF MEMORY " + fileX + "\n"
+                  + "########################");
+          new OOMWarning("Creating Image for " + fileX, err);
+        } catch (Exception e)
+        {
+          e.printStackTrace();
+          pIndicator.setProgressBar(MessageManager.formatMessage(
+                  "info.error_creating_file", "HTML"), pSessionId);
         }
+        setProgressMessage(MessageManager.formatMessage(
+                "status.export_complete", "HTML"));
       }
+    }.start();
 
-      if (renderStyle.equalsIgnoreCase("lineart"))
-      {
-        g1.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
-                SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
-        g2.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
-                SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
-      }
-      printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0, g1,
-              g2);
-      FileOutputStream out = new FileOutputStream(file);
-
-      String titleSvgData = g1.getSVGDocument();
-      String alignSvgData = g2.getSVGDocument();
-      String htmlData = getHtml(titleSvgData, alignSvgData);
-
-      out.write(htmlData.getBytes());
-      out.flush();
-      out.close();
-      if (!(System.getProperty("java.awt.headless") != null && System
-              .getProperty("java.awt.headless").equals("true")))
-      {
-      jalview.util.BrowserLauncher.openURL("file:///" + file);
-      }
-    } catch (Exception e)
+  }
+
+  private void setProgressMessage(String message)
+  {
+    if (pIndicator != null && !headless)
     {
-      e.printStackTrace();
+      pIndicator.setProgressBar(message, pSessionId);
+    }
+    else
+    {
+      System.out.println(message);
     }
   }
-  
+
   static JalviewFileChooser getHTMLChooser()
   {
     return new jalview.io.JalviewFileChooser(
-            jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
-            { "html" }, new String[]
-            { "Hypertext Markup Language" }, "Hypertext Markup Language");
+            jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
+            new String[] { "html" },
+            new String[] { "Hypertext Markup Language" },
+            "Hypertext Markup Language");
   }
 
   public int printUnwrapped(int pwidth, int pheight, int pi, Graphics... pg)
           throws PrinterException
   {
-    int idWidth = ap.getVisibleIdWidth(false);
-    FontMetrics fm = ap.getFontMetrics(av.getFont());
-    int scaleHeight = av.getCharHeight() + fm.getDescent();
-
-    pg[0].setColor(Color.white);
-    pg[0].fillRect(0, 0, pwidth, pheight);
-    pg[0].setFont(av.getFont());
-
-    // //////////////////////////////////
-    // / How many sequences and residues can we fit on a printable page?
-    int totalRes = (pwidth - idWidth) / av.getCharWidth();
-    int totalSeq = (pheight - scaleHeight) / av.getCharHeight() - 1;
-    int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;
-
-    // ///////////////////////////
-    // / Only print these sequences and residues on this page
-    int startRes;
-
-    // ///////////////////////////
-    // / Only print these sequences and residues on this page
-    int endRes;
-
-    // ///////////////////////////
-    // / Only print these sequences and residues on this page
-    int startSeq;
-
-    // ///////////////////////////
-    // / Only print these sequences and residues on this page
-    int endSeq;
-    startRes = (pi % pagesWide) * totalRes;
-    endRes = (startRes + totalRes) - 1;
-
-    if (endRes > (av.getAlignment().getWidth() - 1))
+    return ap.printUnwrapped(pwidth, pheight, pi, pg);
+  }
+
+  public int printWrapped(int pwidth, int pheight, int pi, Graphics... pg)
+          throws PrinterException
+  {
+    return ap.printWrappedAlignment(pwidth, pheight, pi, pg[0]);
+  }
+
+  private String getHtml(String titleSvg, String alignmentSvg,
+          String jsonData, boolean wrapped)
+  {
+    StringBuilder htmlSvg = new StringBuilder();
+    htmlSvg.append("<html>\n");
+    if (jsonData != null)
     {
-      endRes = av.getAlignment().getWidth() - 1;
+      htmlSvg.append("<button onclick=\"javascipt:openJalviewUsingCurrentUrl();\">Launch in Jalview</button> &nbsp;");
+      htmlSvg.append("<input type=\"submit\" value=\"View raw BioJSON Data\" onclick=\"jQuery.facebox({ div:'#seqData' }); return false;\" />");
+      htmlSvg.append("<div style=\"display: none;\" name=\"seqData\" id=\"seqData\" >"
+              + jsonData + "</div>");
+      htmlSvg.append("<br/>&nbsp;");
     }
-    startSeq = (pi / pagesWide) * totalSeq;
-    endSeq = startSeq + totalSeq;
-    if (endSeq > av.getAlignment().getHeight())
+    htmlSvg.append("\n<style type=\"text/css\"> "
+            + "div.parent{ width:100%;<!-- overflow: auto; -->}\n"
+            + "div.titlex{ width:11%; float: left; }\n"
+            + "div.align{ width:89%; float: right; }\n"
+            + "div.main-container{ border: 2px solid blue; border: 2px solid blue; width: 99%;   min-height: 99%; }\n"
+            + ".sub-category-container {overflow-y: scroll; overflow-x: hidden; width: 100%; height: 100%;}\n"
+            + "object {pointer-events: none;}");
+    if (jsonData != null)
     {
-      endSeq = av.getAlignment().getHeight();
+      // facebox style sheet for displaying raw BioJSON data
+      htmlSvg.append("#facebox { position: absolute;  top: 0;   left: 0; z-index: 100; text-align: left; }\n"
+              + "#facebox .popup{ position:relative; border:3px solid rgba(0,0,0,0); -webkit-border-radius:5px;"
+              + "-moz-border-radius:5px; border-radius:5px; -webkit-box-shadow:0 0 18px rgba(0,0,0,0.4); -moz-box-shadow:0 0 18px rgba(0,0,0,0.4);"
+              + "box-shadow:0 0 18px rgba(0,0,0,0.4); }\n"
+              + "#facebox .content { display:table; width: 98%; padding: 10px; background: #fff; -webkit-border-radius:4px; -moz-border-radius:4px;"
+              + " border-radius:4px; }\n"
+              + "#facebox .content > p:first-child{ margin-top:0; }\n"
+              + "#facebox .content > p:last-child{ margin-bottom:0; }\n"
+              + "#facebox .close{ position:absolute; top:5px; right:5px; padding:2px; background:#fff; }\n"
+              + "#facebox .close img{ opacity:0.3; }\n"
+              + "#facebox .close:hover img{ opacity:1.0; }\n"
+              + "#facebox .loading { text-align: center; }\n"
+              + "#facebox .image { text-align: center;}\n"
+              + "#facebox img { border: 0;  margin: 0; }\n"
+              + "#facebox_overlay { position: fixed; top: 0px; left: 0px; height:100%; width:100%; }\n"
+              + ".facebox_hide { z-index:-100; }\n"
+              + ".facebox_overlayBG { background-color: #000;  z-index: 99;  }");
     }
-    int pagesHigh = ((av.getAlignment().getHeight() / totalSeq) + 1)
-            * pheight;
-    if (av.isShowAnnotation())
+    htmlSvg.append("</style>");
+    if (!wrapped)
     {
-      pagesHigh += ap.getAnnotationPanel().adjustPanelHeight() + 3;
+    htmlSvg.append("<div class=\"main-container\" \n>");
+    htmlSvg.append("<div class=\"titlex\">\n");
+    htmlSvg.append("<div class=\"sub-category-container\"> \n");
+    htmlSvg.append(titleSvg);
+    htmlSvg.append("</div>");
+    htmlSvg.append("</div>\n\n<!-- ========================================================================================== -->\n\n");
+    htmlSvg.append("<div class=\"align\" >");
+    htmlSvg.append(
+            "<div class=\"sub-category-container\"> <div style=\"overflow-x: scroll;\">")
+            .append(alignmentSvg).append("</div></div>").append("</div>");
+    htmlSvg.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"
+            + "<script>\n"
+            + "var subCatContainer = $(\".sub-category-container\");\n"
+            + "subCatContainer.scroll(\nfunction() {\n"
+            + "subCatContainer.scrollTop($(this).scrollTop());\n});\n");
+
+    htmlSvg.append("</script>\n");
     }
-    pagesHigh /= pheight;
-    if (pi >= (pagesWide * pagesHigh))
+    else
     {
-      return Printable.NO_SUCH_PAGE;
+      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");
+
     }
 
-    // draw Scale
-    pg[1].translate(0, 0);
-    ap.getScalePanel().drawScale(pg[1], startRes, endRes, pwidth - idWidth,
-            scaleHeight);
-    pg[1].translate(-idWidth, scaleHeight);
-
-    // //////////////
-    // Draw the ids
-    Color currentColor = null;
-    Color currentTextColor = null;
-    pg[0].translate(0, scaleHeight);
-    pg[0].setFont(ap.getIdPanel().getIdCanvas().getIdfont());
-    SequenceI seq;
-    for (int i = startSeq; i < endSeq; i++)
+    // javascript for launching file in Jalview
+
+    htmlSvg.append("<script language=\"JavaScript\">\n");
+    htmlSvg.append("function openJalviewUsingCurrentUrl(){\n");
+    htmlSvg.append("    var json = JSON.parse(document.getElementById(\"seqData\").innerHTML);\n");
+    htmlSvg.append("    var jalviewVersion = json['appSettings'].version;\n");
+    htmlSvg.append("    var url = json['appSettings'].webStartUrl;\n");
+    htmlSvg.append("    var myForm = document.createElement(\"form\");\n\n");
+    htmlSvg.append("    var heap = document.createElement(\"input\");\n");
+    htmlSvg.append("    heap.setAttribute(\"name\", \"jvm-max-heap\") ;\n");
+    htmlSvg.append("    heap.setAttribute(\"value\", \"2G\");\n\n");
+    htmlSvg.append("    var target = document.createElement(\"input\");\n");
+    htmlSvg.append("    target.setAttribute(\"name\", \"open\");\n");
+    htmlSvg.append("    target.setAttribute(\"value\", document.URL);\n\n");
+    htmlSvg.append("    var jvVersion = document.createElement(\"input\");\n");
+    htmlSvg.append("    jvVersion.setAttribute(\"name\", \"version\") ;\n");
+    htmlSvg.append("    jvVersion.setAttribute(\"value\", jalviewVersion);\n\n");
+    htmlSvg.append("    myForm.action = url;\n");
+    htmlSvg.append("    myForm.appendChild(heap);\n");
+    htmlSvg.append("    myForm.appendChild(target);\n");
+    htmlSvg.append("    myForm.appendChild(jvVersion);\n");
+    htmlSvg.append("    document.body.appendChild(myForm);\n");
+    htmlSvg.append("    myForm.submit() ;\n");
+    htmlSvg.append("    document.body.removeChild(myForm);\n");
+    htmlSvg.append("}\n");
+
+    // jquery facebox for displaying raw BioJSON data");
+    if (jsonData != null)
     {
-      seq = av.getAlignment().getSequenceAt(i);
-      if ((av.getSelectionGroup() != null)
-              && av.getSelectionGroup().getSequences(null).contains(seq))
-      {
-        currentColor = Color.gray;
-        currentTextColor = Color.black;
-      }
-      else
+      File faceBoxJsFile = new File("examples/javascript/facebox-1.3.js");
+      try
       {
-        currentColor = av.getSequenceColour(seq);
-        currentTextColor = Color.black;
-      }
-      pg[0].setColor(currentColor);
-      pg[0].fillRect(0, (i - startSeq) * av.getCharHeight(), idWidth,
-              av.getCharHeight());
-      pg[0].setColor(currentTextColor);
-      int xPos = 0;
-      if (av.isRightAlignIds())
+        htmlSvg.append(HtmlFile.readFileAsString(faceBoxJsFile));
+      } catch (IOException e)
       {
-        fm = pg[0].getFontMetrics();
-        xPos = idWidth
-                - fm.stringWidth(seq.getDisplayId(av.getShowJVSuffix()))
-                - 4;
+        e.printStackTrace();
       }
-      pg[0].drawString(
-              seq.getDisplayId(av.getShowJVSuffix()),
-              xPos,
-              (((i - startSeq) * av.getCharHeight()) + av.getCharHeight())
-                      - (av.getCharHeight() / 5));
-    }
-    pg[0].setFont(av.getFont());
-    pg[0].translate(idWidth, 0);
-
-    // draw main sequence panel
-    pg[1].translate(idWidth, 0);
-    ap.getSeqPanel().seqCanvas.drawPanel(pg[1], startRes, endRes, startSeq,
-            endSeq, 0);
-    if (av.isShowAnnotation() && (endSeq == av.getAlignment().getHeight()))
-    {
-      // draw annotation label - need to offset for current scroll position
-      int offset = -ap.getAlabels().getScrollOffset();
-      pg[0].translate(0, offset);
-      pg[0].translate(-idWidth - 3,
-              (endSeq - startSeq) * av.getCharHeight() + 3);
-      ap.getAlabels().drawComponent(pg[0], idWidth);
-      pg[0].translate(idWidth + 3, 0);
-      pg[0].translate(0, -offset);
-
-      // draw annotation - need to offset for current scroll position
-      pg[1].translate(0, offset);
-      pg[1].translate(-idWidth - 3,
-              (endSeq - startSeq) * av.getCharHeight() + 3);
-      pg[1].translate(idWidth + 3, 0);
-      ap.getAnnotationPanel().renderer.drawComponent(
-              ap.getAnnotationPanel(), av, pg[1], -1, startRes, endRes + 1);
-      pg[1].translate(0, -offset);
     }
 
-    return Printable.PAGE_EXISTS;
-  }
-  
-  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>"
-            + "<div style=\"width:100%; height:100%; overflow: hidden\">"
-            + "<div class=\"title\">");
-    htmlSvg.append(titleSvg);
-    htmlSvg.append("</div><div class=\"align\">").append(alignmentSvg);
-    htmlSvg.append("</div>");
+    htmlSvg.append("</script>\n");
+    htmlSvg.append("</html>");
     return htmlSvg.toString();
   }
 }