// selectImage will hold any selection we have
// lcimg is a local *copy* of img which we'll draw selectImage on top of
- BufferedImage selectImage = drawSelectionGroup();
+ ViewportRanges ranges = av.getRanges();
+ BufferedImage selectImage = drawSelectionGroup(
+ av.getRanges().getStartRes(), av.getRanges().getEndRes(),
+ ranges.getStartSeq(), ranges.getEndSeq());
if (fastPaint || (getVisibleRect().width != g.getClipBounds().width)
|| (getVisibleRect().height != g.getClipBounds().height))
gg.setColor(Color.white);
gg.fillRect(0, 0, img.getWidth(), img.getHeight());
- ViewportRanges ranges = av.getRanges();
if (av.getWrapAlignment())
{
drawWrappedPanel(gg, getWidth(), getHeight(), ranges.getStartRes());
}
+
/*
* Draw the selection group as a separate image and overlay
*/
- private BufferedImage drawSelectionGroup()
+ private BufferedImage drawSelectionGroup(int startRes, int endRes,
+ int startSeq, int endSeq)
{
- // get a new image of the correct size
+ // get a new image of the correct size
BufferedImage selectionImage = setupImage();
if (selectionImage == null)
return null;
}
+ // set up drawing colour
+ Graphics2D g = (Graphics2D) selectionImage.getGraphics();
+ g.translate(LABEL_WEST, 0);
+ // set background to transparent
+ g.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
+ g.fillRect(0, 0, selectionImage.getWidth(), selectionImage.getHeight());
+
+ g.setComposite(AlphaComposite.Src);
+ g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT,
+ BasicStroke.JOIN_ROUND, 3f, new float[]
+ { 5f, 3f }, 0f));
+ g.setColor(Color.RED);
+
+ if (!av.hasHiddenColumns())
+ {
+ drawSelectionGroupPart(g, group, startRes, endRes, startSeq, endSeq);
+ }
+ else
+ {
+ // package into blocks of visible columns
+ // Graphics2D g = (Graphics2D) selectionImage.getGraphics();
+ // Graphics g1 = selectionImage.getGraphics();
+
+ int screenY = 0;
+ int blockStart = startRes;
+ int blockEnd = endRes;
+
+ for (int[] region : av.getAlignment().getHiddenColumns()
+ .getHiddenColumnsCopy())
+ {
+ int hideStart = region[0];
+ int hideEnd = region[1];
+
+ if (hideStart <= blockStart)
+ {
+ blockStart += (hideEnd - hideStart) + 1;
+ continue;
+ }
+
+ blockEnd = hideStart - 1;
+
+ g.translate(screenY * charWidth, 0);
+
+ drawSelectionGroupPart(g, group,
+ blockStart, blockEnd, startSeq, endSeq);
+
+ g.translate(-screenY * charWidth, 0);
+ screenY += blockEnd - blockStart + 1;
+ blockStart = hideEnd + 1;
+
+ if (screenY > (endRes - startRes))
+ {
+ // already rendered last block
+ break;
+ }
+ }
+
+ if (screenY <= (endRes - startRes))
+ {
+ // remaining visible region to render
+ blockEnd = blockStart + (endRes - startRes) - screenY;
+ g.translate(screenY * charWidth, 0);
+ drawSelectionGroupPart(g, group,
+ blockStart, blockEnd, startSeq, endSeq);
+
+ g.translate(-screenY * charWidth, 0);
+ }
+ }
+ g.translate(-LABEL_WEST, 0);
+ return selectionImage;
+ }
+
+ /*
+ * Draw the selection group as a separate image and overlay
+ */
+ private void drawSelectionGroupPart(Graphics2D g, SequenceGroup group,
+ int startRes, int endRes, int startSeq, int endSeq)
+ {
// set up values in case the alignment is wrapped
int verticalOffset = 0;
int horizontalOffset = 0;
horizontalOffset = (slice * cWidth);
}
- // set up drawing colour
- Graphics2D g = (Graphics2D) selectionImage.getGraphics();
- g.translate(LABEL_WEST, 0);
- // set background to transparent
- g.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
- g.fillRect(0, 0, selectionImage.getWidth(), selectionImage.getHeight());
-
- g.setComposite(AlphaComposite.Src);
- g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT,
- BasicStroke.JOIN_ROUND, 3f, new float[]
- { 5f, 3f }, 0f));
- g.setColor(Color.RED);
-
int visWidth = av.getRanges().getViewportWidth() * charWidth;
- int startRes = av.getRanges().getStartRes();
-
// set x start and end positions of group
int startx = (group.getStartRes() - startRes - horizontalOffset)
* charWidth;
int bottom = -1;
// get sequences to determine y positions of group
- int startSeq = av.getRanges().getStartSeq();
- for (i = startSeq; i <= av.getRanges().getEndSeq(); ++i)
+ for (i = startSeq; i <= endSeq; ++i)
{
int sy = verticalOffset + (i - startSeq) * charHeight;
inGroup = false;
}
- g.translate(-LABEL_WEST, 0);
- return selectionImage;
}
/**