+ int idWidth = calculateIdWidth().width + 4;\r
+\r
+ int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth -\r
+ idWidth);\r
+ int totalHeight = totalHeight = (av.alignment.getHeight() + 2) * ((av.alignment.getWidth() / resWidth) +\r
+ 1) * av.charHeight;\r
+\r
+ pg.setColor(Color.white);\r
+ pg.fillRect(0, 0, pwidth, pheight);\r
+ pg.setFont(av.getFont());\r
+\r
+ ////////////////\r
+ // Draw the ids\r
+ pg.setColor(Color.black);\r
+\r
+ pg.translate(0, -pi * pheight);\r
+\r
+ pg.setClip(0, pi * pheight, pwidth, pheight);\r
+\r
+ int ypos = 2 * av.charHeight;\r
+\r
+ do\r
+ {\r
+ for (int i = 0; i < av.alignment.getHeight(); i++)\r
+ {\r
+ SequenceI s = av.alignment.getSequenceAt(i);\r
+ String string = s.getName();\r
+\r
+ if (av.getShowFullId())\r
+ {\r
+ string = s.getDisplayId();\r
+ }\r
+\r
+ pg.drawString(string, 0,\r
+ ((i * av.charHeight) + ypos + av.charHeight) -\r
+ (av.charHeight / 5));\r
+ }\r
+\r
+ ypos += ((av.alignment.getHeight() + 2) * av.charHeight);\r
+ }\r
+ while (ypos < totalHeight);\r
+\r
+ pg.translate(idWidth, 0);\r
+\r
+ seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight, 0);\r
+\r
+ if ((pi * pheight) < totalHeight)\r
+ {\r
+ return Printable.PAGE_EXISTS;\r
+ }\r
+ else\r
+ {\r
+ return Printable.NO_SUCH_PAGE;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ */\r
+ public void makeEPS(File epsFile)\r
+ {\r
+ if(epsFile == null)\r
+ {\r
+ jalview.io.JalviewFileChooser chooser = new jalview.io.\r
+ JalviewFileChooser(jalview.bin.Cache.getProperty(\r
+ "LAST_DIRECTORY"), new String[]\r
+ {"eps"},\r
+ new String[]\r
+ {"Encapsulated Postscript"},\r
+ "Encapsulated Postscript");\r
+ chooser.setFileView(new jalview.io.JalviewFileView());\r
+ chooser.setDialogTitle("Create EPS file from alignment");\r
+ chooser.setToolTipText("Save");\r
+\r
+ int value = chooser.showSaveDialog(this);\r
+\r
+ if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)\r
+ {\r
+ return;\r
+ }\r
+\r
+ epsFile = chooser.getSelectedFile();\r
+\r
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY",\r
+ chooser.getSelectedFile().getParent());\r
+ }\r
+\r
+ int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30;\r
+ int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth);\r
+\r
+ if (av.getWrapAlignment())\r
+ {\r
+ height = ( (av.alignment.getWidth() / av.getChunkWidth()) + 1) *\r
+ av.chunkHeight;\r
+ width = seqPanel.getWidth() + idPanel.getWidth();\r
+\r
+ }\r
+\r
+\r
+ if (av.getShowAnnotation())\r
+ {\r
+ height += annotationPanel.getPreferredSize().height;\r
+ }\r
+\r
+ try\r
+ {\r
+ FileOutputStream out = new FileOutputStream(epsFile);\r
+ EpsGraphics2D pg = new EpsGraphics2D("Example", out, 0, 0, width,\r
+ height);\r
+\r
+ if (av.getWrapAlignment())\r
+ {\r
+ printWrappedAlignment(pg, width, height, 0);\r
+ }\r
+ else\r
+ {\r
+ printUnwrapped(pg, width, height, 0);\r
+ }\r
+\r
+ pg.flush();\r
+ pg.close();\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ ex.printStackTrace();\r
+ }\r
+ }\r
+\r
+\r
+ public void makePNGImageMap(File imgMapFile, String imageName)\r
+ {\r
+ ///////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS\r
+ //////////////////////////////////////////////\r
+ int idWidth = calculateIdWidth().width + 4;\r
+ FontMetrics fm = getFontMetrics(av.getFont());\r
+ int scaleHeight = av.charHeight + fm.getDescent();\r
+\r
+ // Gen image map\r
+ //////////////////////////////////\r
+ if(imgMapFile!=null)\r
+ {\r
+ try\r
+ {\r
+ PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));\r
+ out.println(jalview.io.HTMLOutput.getImageMapHTML());\r
+ out.println("<img src=\"" + imageName +\r
+ "\" border=\"0\" usemap=\"#Map\" >"\r
+ +"<map name=\"Map\">");\r
+\r
+ for (int s = 0; s < av.alignment.getHeight(); s++)\r
+ {\r
+ SequenceI seq = av.alignment.getSequenceAt(s);\r
+ SequenceGroup[] groups = av.alignment.findAllGroups(seq);\r
+ for (int i = 0; i < groups.length; i++)\r
+ {\r
+ int sy = s * av.charHeight + scaleHeight;\r
+ for (int res = groups[i].getStartRes();\r
+ res < groups[i].getEndRes() + 1; res++)\r
+ {\r
+ int alIndex = seq.findPosition(res);\r
+ Object obj = ResidueProperties.aa2Triplet.get(\r
+ seq.getCharAt(res) + "");\r
+ if (obj == null)\r
+ continue;\r
+\r
+ String triplet = obj.toString();\r
+\r
+ out.println(\r
+ "<area shape=\"rect\" coords=\""\r
+ + (idWidth + res * av.charWidth) + ","\r
+ + sy + ","\r
+ + (idWidth + (res + 1) * av.charWidth) + ","\r
+ + (av.charHeight + sy) + "\""\r
+ + " onMouseOver=\"toolTip('"\r
+ + alIndex + " " + triplet +\r
+ "<br><em>" + groups[i].getName() +\r
+ "</em>')\"; onMouseOut=\"toolTip()\"; "\r
+ + " href=\"#\">");\r
+ }\r
+ }\r
+ }\r
+\r
+ out.println("</map></body></html>");\r
+ out.close();\r
+\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ ex.printStackTrace();\r
+ }\r
+ }///////////END OF IMAGE MAP\r
+\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ */\r
+ public void makePNG(File pngFile)\r
+ {\r
+ if(pngFile==null)\r