-
- // draw Scale
- pg.translate(idWidth, 0);
- scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth,
- scaleHeight);
- pg.translate(-idWidth, scaleHeight);
-
- // //////////////
- // Draw the ids
- Color currentColor = null;
- Color currentTextColor = null;
-
- pg.setFont(idPanel.idCanvas.idfont);
-
- SequenceI seq;
- for (int i = startSeq; i < endSeq; i++)
- {
- seq = av.getAlignment().getSequenceAt(i);
- if ((av.getSelectionGroup() != null)
- && av.getSelectionGroup().getSequences(null).contains(seq))
- {
- currentColor = Color.gray;
- currentTextColor = Color.black;
- }
- else
- {
- currentColor = av.getSequenceColour(seq);
- currentTextColor = Color.black;
- }
-
- pg.setColor(currentColor);
- pg.fillRect(0, (i - startSeq) * av.charHeight, idWidth, av
- .getCharHeight());
-
- pg.setColor(currentTextColor);
-
- int xPos = 0;
- if (av.rightAlignIds)
- {
- fm = pg.getFontMetrics();
- xPos = idWidth
- - fm.stringWidth(seq.getDisplayId(av.getShowJVSuffix()))
- - 4;
- }
-
- pg.drawString(seq.getDisplayId(av.getShowJVSuffix()), xPos,
- (((i - startSeq) * av.charHeight) + av.getCharHeight())
- - (av.getCharHeight() / 5));
- }
-
- pg.setFont(av.getFont());
-
- // draw main sequence panel
- pg.translate(idWidth, 0);
- seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, 0);
-
- if (av.showAnnotation && (endSeq == av.alignment.getHeight()))
- {
- pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
- alabels.drawComponent((Graphics2D) pg, idWidth);
- pg.translate(idWidth + 3, 0);
- annotationPanel.drawComponent((Graphics2D) pg, startRes, endRes + 1);
+ final int alignmentDrawnHeight = (endSeq - startSeq) * charHeight + 3;
+
+ /*
+ * draw the Scale at horizontal offset, then reset to top left (0, 0)
+ */
+ alignmentGraphics.translate(alignmentGraphicsOffset, 0);
+ getScalePanel().drawScale(alignmentGraphics, startRes, endRes,
+ pageWidth - idWidth, scaleHeight);
+ alignmentGraphics.translate(-alignmentGraphicsOffset, 0);
+
+ /*
+ * Draw the sequence ids, offset for scale height,
+ * then reset to top left (0, 0)
+ */
+ idGraphics.translate(0, scaleHeight);
+ IdCanvas idCanvas = getIdPanel().getIdCanvas();
+ List<SequenceI> selection = av.getSelectionGroup() == null ? null
+ : av.getSelectionGroup().getSequences(null);
+ idCanvas.drawIds((Graphics2D) idGraphics, av, startSeq, endSeq - 1,
+ selection);
+
+ idGraphics.setFont(av.getFont());
+ idGraphics.translate(0, -scaleHeight);
+
+ /*
+ * draw the sequences, offset for scale height, and id width (if using a
+ * single graphics context), then reset to (0, scale height)
+ */
+ alignmentGraphics.translate(alignmentGraphicsOffset, scaleHeight);
+ getSeqPanel().seqCanvas.drawPanelForPrinting(alignmentGraphics,
+ startRes, endRes, startSeq, endSeq - 1);
+ alignmentGraphics.translate(-alignmentGraphicsOffset, 0);
+
+ if (av.isShowAnnotation() && (endSeq == alignmentHeight))
+ {
+ /*
+ * draw annotation labels; drawComponent() translates by
+ * getScrollOffset(), so compensate for that first;
+ * then reset to (0, scale height)
+ */
+ int offset = getAlabels().getScrollOffset();
+ idGraphics.translate(0, -offset);
+ idGraphics.translate(0, alignmentDrawnHeight);
+ getAlabels().drawComponent(idGraphics, idWidth);
+ idGraphics.translate(0, -alignmentDrawnHeight);
+
+ /*
+ * draw the annotations starting at
+ * (idOffset, alignmentHeight) from (0, scaleHeight)
+ */
+ alignmentGraphics.translate(alignmentGraphicsOffset,
+ alignmentDrawnHeight);
+ updateLayout();
+ getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av,
+ alignmentGraphics, -1, startRes, endRes + 1);