+ public int print(Graphics pg, PageFormat pf, int pi) throws PrinterException\r
+ {\r
+\r
+ pg.translate((int)pf.getImageableX(), (int)pf.getImageableY());\r
+\r
+ int pwidth = (int)pf.getImageableWidth();\r
+ int pheight = (int)pf.getImageableHeight();\r
+ int idWidth = (int)idPanel.idCanvas.getLabelWidth().getWidth();\r
+\r
+ pg.setColor(Color.white);\r
+ pg.fillRect(0,0,pwidth, pheight);\r
+ pg.setFont( av.getFont() );\r
+\r
+ ////////////////////////////////////\r
+ /// How many sequences and residues can we fit on a printable page?\r
+ int totalRes = (pwidth - idWidth)/av.getCharWidth();\r
+ int totalSeq = (int)((pheight - 30)/av.getCharHeight())-1;\r
+ int pagesWide = av.getAlignment().getWidth() / totalRes +1;\r
+ int pagesHigh = av.getAlignment().getHeight() / totalSeq +1;\r
+\r
+ if (pi >= pagesWide*pagesHigh)\r
+ return Printable.NO_SUCH_PAGE;\r
+\r
+ /////////////////////////////\r
+ /// Only print these sequences and residues on this page\r
+ int startRes, endRes, startSeq, endSeq;\r
+ startRes = (pi % pagesWide) * totalRes;\r
+ endRes = startRes + totalRes-1;\r
+ if(endRes>av.getAlignment().getWidth())\r
+ endRes = av.getAlignment().getWidth();\r
+\r
+ startSeq = (pi / pagesWide) * totalSeq;\r
+ endSeq = startSeq + totalSeq;\r
+ if(endSeq > av.getAlignment().getHeight())\r
+ endSeq = av.getAlignment().getHeight();\r
+\r
+\r
+ ////////////////\r
+ //draw Scale\r
+ pg.translate(idWidth,0);\r
+ scalePanel.scaleCanvas.drawScale(pg, startRes, endRes, pwidth-idWidth);\r
+\r
+ pg.translate(-idWidth, 30);\r
+ ////////////////\r
+ // Draw the ids\r
+ Color currentColor=null;\r
+ Color currentTextColor=null;\r
+ for(int i=startSeq; i<endSeq; i++)\r
+ {\r
+ if (av.getSelection().contains(av.getAlignment().getSequenceAt(i)))\r
+ {\r
+ currentColor = Color.gray;\r
+ currentTextColor = Color.black;\r
+ }\r
+ else\r
+ {\r
+ currentColor = av.getAlignment().getSequenceAt(i).getColor();\r
+ currentTextColor = Color.black;\r
+ }\r
+\r
+ pg.setColor(currentColor);\r
+ pg.fillRect(0, jalview.analysis.AlignmentUtil.getPixelHeight(startSeq, i, av.getCharHeight()),\r
+ idWidth,\r
+ av.getCharHeight());\r
+\r
+ pg.setColor(currentTextColor);\r
+\r
+ String string = av.getAlignment().getSequenceAt(i).getDisplayId();\r
+ pg.drawString(string, 0, jalview.analysis.AlignmentUtil.getPixelHeight\r
+ (startSeq, i, av.getCharHeight()) + av.getCharHeight() - (av.getCharHeight() / 5));\r
+ }\r
+\r
+ // draw main sequence panel\r
+ pg.translate(idWidth,0);\r
+ pg.setClip(0,0,pwidth-idWidth, pheight);\r
+ seqPanel.seqCanvas.drawPanel(pg,startRes,endRes,startSeq,endSeq,startRes,startSeq,0);\r
+\r
+ return Printable.PAGE_EXISTS;\r
+ }\r