X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqCanvas.java;h=f885100b807891e996bcf445147472106a5b026a;hb=f67e3c63a48403f4bbb9066595e4cb5a00089234;hp=1be4728ec27b23fa26e33c8c98b637e49307711e;hpb=f2a83f0360d406859b80cc798099a9d270461bb3;p=jalview.git diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 1be4728..f885100 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -43,7 +43,6 @@ import java.awt.Shape; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.util.List; -import java.util.function.Consumer; import javax.swing.JComponent; @@ -1099,97 +1098,72 @@ public class SeqCanvas extends JComponent implements ViewportListenerI * @param yOffset * vertical offset at which to draw (for wrapped alignments) */ - private void draw(final Graphics g, final int startRes, final int endRes, - final int startSeq, final int endSeq, final int offset) + private void draw(Graphics g, int startRes, int endRes, int startSeq, + int endSeq, int offset) { + int charHeight = av.getCharHeight(); + int charWidth = av.getCharWidth(); + g.setFont(av.getFont()); seqRdr.prepare(g, av.isRenderGaps()); - // First draw the sequences - av.getAlignment().forEachSequence(new Consumer() - { - int i = startSeq; + SequenceI nextSeq; - @Override - public void accept(SequenceI s) + // / First draw the sequences + // /////////////////////////// + for (int i = startSeq; i <= endSeq; i++) + { + nextSeq = av.getAlignment().getSequenceAt(i); + if (nextSeq == null) { - int heightPosition = offset + ((i - startSeq) * av.getCharHeight()); - drawSequence(s, g, startRes, endRes, heightPosition, i); - i++; + // occasionally, a race condition occurs such that the alignment row is + // empty + continue; } - }, startSeq, endSeq + 1); - - // now selection groups - if (av.getSelectionGroup() != null - || av.getAlignment().getGroups().size() > 0) - { - drawGroupsBoundaries(g, startRes, endRes, startSeq, endSeq, offset); - } - - } - - /** - * Draw a single sequence - * - * @param nextSeq - * the next sequence to draw - * @param g - * graphics context - * @param startRes - * offset of the first column in the visible region (0..) - * @param endRes - * offset of the last column in the visible region (0..) - * @param heightPosition - * vertical location of the sequence in the alignment - * @param i - * index of sequence - */ - private void drawSequence(SequenceI nextSeq, Graphics g, int startRes, - int endRes, int heightPosition, int i) - { - int charWidth = av.getCharWidth(); - - if (nextSeq == null) - { - // occasionally, a race condition occurs such that the alignment row is - // empty - // TODO Don't think this will happen any more? - return; - } - seqRdr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq), - startRes, endRes, heightPosition); + seqRdr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq), + startRes, endRes, offset + ((i - startSeq) * charHeight)); - if (av.isShowSequenceFeatures()) - { - fr.drawSequence(g, nextSeq, startRes, endRes, heightPosition, false); - } + if (av.isShowSequenceFeatures()) + { + fr.drawSequence(g, nextSeq, startRes, endRes, + offset + ((i - startSeq) * charHeight), false); + } - /* - * highlight search Results once sequence has been drawn - */ - if (av.hasSearchResults()) - { - SearchResultsI searchResults = av.getSearchResults(); - int[] visibleResults = searchResults.getResults(nextSeq, startRes, - endRes); - if (visibleResults != null) + /* + * highlight search Results once sequence has been drawn + */ + if (av.hasSearchResults()) { - for (int r = 0; r < visibleResults.length; r += 2) + SearchResultsI searchResults = av.getSearchResults(); + int[] visibleResults = searchResults.getResults(nextSeq, startRes, + endRes); + if (visibleResults != null) { - seqRdr.drawHighlightedText(nextSeq, visibleResults[r], - visibleResults[r + 1], - (visibleResults[r] - startRes) * charWidth, - heightPosition); + for (int r = 0; r < visibleResults.length; r += 2) + { + seqRdr.drawHighlightedText(nextSeq, visibleResults[r], + visibleResults[r + 1], + (visibleResults[r] - startRes) * charWidth, + offset + ((i - startSeq) * charHeight)); + } } } + + if (av.cursorMode && cursorY == i && cursorX >= startRes + && cursorX <= endRes) + { + seqRdr.drawCursor(nextSeq, cursorX, + (cursorX - startRes) * charWidth, + offset + ((i - startSeq) * charHeight)); + } } - if (av.cursorMode && cursorY == i && cursorX >= startRes - && cursorX <= endRes) + if (av.getSelectionGroup() != null + || av.getAlignment().getGroups().size() > 0) { - seqRdr.drawCursor(nextSeq, cursorX, (cursorX - startRes) * charWidth, - heightPosition); + drawGroupsBoundaries(g, startRes, endRes, startSeq, endSeq, offset); } + } void drawGroupsBoundaries(Graphics g1, int startRes, int endRes,