- 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
+ int pwidth = (int) pf.getImageableWidth();\r
+ int pheight = (int) pf.getImageableHeight();\r
+\r
+ if (av.getWrapAlignment())\r
+ return printWrappedAlignment(pg, pwidth,pheight, pi);\r
+ else\r
+ return printUnwrapped(pg,pwidth, pheight,pi);\r
+ }\r
+\r
+ public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi) throws PrinterException\r
+ {\r
+\r
+ int idWidth = calculateIdWidth().width + 4;\r
+ FontMetrics fm = getFontMetrics(av.getFont());\r
+ int scaleHeight = av.charHeight + fm.getDescent();\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
+\r
+ int totalSeq = (int) ( (pheight - scaleHeight) / av.getCharHeight()) - 1;\r
+\r
+ int pagesWide = av.getAlignment().getWidth() / totalRes + 1;\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()-1)\r
+ endRes = av.getAlignment().getWidth()-1;\r
+\r
+ startSeq = (pi / pagesWide) * totalSeq;\r
+ endSeq = startSeq + totalSeq;\r
+ if (endSeq > av.getAlignment().getHeight())\r
+ endSeq = av.getAlignment().getHeight();\r
+\r
+ int pagesHigh = ( (av.alignment.getHeight() / totalSeq) + 1) * pheight;\r
+\r
+ if (av.showAnnotation)\r
+ pagesHigh += annotationPanel.getHeight();\r
+\r
+ pagesHigh /= pheight;\r
+\r
+ if (pi >= pagesWide * pagesHigh)\r
+ return Printable.NO_SUCH_PAGE;\r
+\r
+ //draw Scale\r
+ pg.translate(idWidth, 0);\r
+ scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight);\r
+ pg.translate( -idWidth, scaleHeight);\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.getSelectionGroup() != null &&\r
+ av.getSelectionGroup().sequences.\r
+ 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,\r
+ jalview.analysis.AlignmentUtil.getPixelHeight(startSeq, i,\r
+ av.getCharHeight()),\r
+ idWidth,\r
+ av.getCharHeight());\r
+\r
+ pg.setColor(currentTextColor);\r
+\r
+ String string = av.getAlignment().getSequenceAt(i).getName();\r
+ if (av.getShowFullId())\r
+ string = av.getAlignment().getSequenceAt(i).getDisplayId();\r
+\r
+ pg.drawString(string, 0, jalview.analysis.AlignmentUtil.getPixelHeight\r
+ (startSeq, i, av.getCharHeight()) + av.getCharHeight() -\r
+ (av.getCharHeight() / 5));\r
+ }\r
+\r
+ // draw main sequence panel\r
+ pg.translate(idWidth, 0);\r
+ seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq,\r
+ startRes, startSeq, 0);\r
+\r
+\r
+ if (av.showAnnotation && endSeq == av.alignment.getHeight())\r
+ {\r
+ pg.translate( -idWidth, (endSeq - startSeq) * av.charHeight);\r
+ alabels.drawComponent( (Graphics2D) pg);\r
+ pg.translate(idWidth, 0);\r
+ annotationPanel.drawComponent( (Graphics2D) pg, startRes, endRes+1);\r
+ }\r
+\r
+ return Printable.PAGE_EXISTS;\r
+\r
+ }\r
+\r
+\r
+ public int printWrappedAlignment(Graphics pg, int pwidth, int pheight, int pi) throws PrinterException\r
+ {\r
+ int idWidth = calculateIdWidth().width + 4;\r
+\r
+ int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth - idWidth);\r
+ int totalHeight = totalHeight = (av.alignment.getHeight() + 2) *\r
+ ( (av.alignment.getWidth()\r
+ / resWidth) + 1) * av.charHeight;\r
+\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
+ do\r