From: gmungoc Date: Fri, 19 May 2017 15:59:48 +0000 (+0100) Subject: JAL-2526 removed redundant call to Sequence.findPosition() X-Git-Tag: Release_2_10_2~3^2~76 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f49beadc8208986d730f7ed5f4c5cb99329ed92f;p=jalview.git JAL-2526 removed redundant call to Sequence.findPosition() --- diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index de44aa0..7dfac5e 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -183,7 +183,7 @@ public class SeqPanel extends JPanel implements MouseListener, * @param evt * @return */ - int findRes(MouseEvent evt) + int findColumn(MouseEvent evt) { int res = 0; int x = evt.getX(); @@ -642,7 +642,7 @@ public class SeqPanel extends JPanel implements MouseListener, } int seq = findSeq(evt); - int res = findRes(evt); + int res = findColumn(evt); if (seq < 0 || res < 0) { @@ -741,25 +741,27 @@ public class SeqPanel extends JPanel implements MouseListener, mouseDragged(evt); } - int res = findRes(evt); + final int column = findColumn(evt); int seq = findSeq(evt); - int pos; - if (res < 0 || seq < 0 || seq >= av.getAlignment().getHeight()) + if (column < 0 || seq < 0 || seq >= av.getAlignment().getHeight()) { return; } SequenceI sequence = av.getAlignment().getSequenceAt(seq); - if (res >= sequence.getLength()) + if (column >= sequence.getLength()) { return; } - pos = setStatusMessage(sequence, res, seq); + /* + * set status bar message, returning residue position in sequence + */ + final int pos = setStatusMessage(sequence, column, seq); if (ssm != null && pos > -1) { - mouseOverSequence(sequence, res, pos); + mouseOverSequence(sequence, column, pos); } tooltipText.setLength(6); // Cuts the buffer back to @@ -769,7 +771,8 @@ public class SeqPanel extends JPanel implements MouseListener, { for (int g = 0; g < groups.length; g++) { - if (groups[g].getStartRes() <= res && groups[g].getEndRes() >= res) + if (groups[g].getStartRes() <= column + && groups[g].getEndRes() >= column) { if (!groups[g].getName().startsWith("JTreeGroup") && !groups[g].getName().startsWith("JGroup")) @@ -785,14 +788,11 @@ public class SeqPanel extends JPanel implements MouseListener, } } - // use aa to see if the mouse pointer is on a if (av.isShowSequenceFeatures()) { - int rpos; List features = ap.getFeatureRenderer() - .findFeaturesAtRes(sequence.getDatasetSequence(), - rpos = sequence.findPosition(res)); - seqARep.appendFeatures(tooltipText, rpos, features, + .findFeaturesAtRes(sequence.getDatasetSequence(), pos); + seqARep.appendFeatures(tooltipText, pos, features, this.ap.getSeqPanel().seqCanvas.fr.getMinMax()); } if (tooltipText.length() == 6) // @@ -859,17 +859,19 @@ public class SeqPanel extends JPanel implements MouseListener, // avcontroller or viewModel /** - * Set status message in alignment panel + * Sets the status message in alignment panel, showing the sequence number + * (index) and id, residue and residue position for the given sequence and + * column position. Returns the calculated residue position in the sequence. * * @param sequence * aligned sequence object - * @param res + * @param column * alignment column * @param seq * index of sequence in alignment * @return position of res in sequence */ - int setStatusMessage(SequenceI sequence, int res, int seq) + int setStatusMessage(SequenceI sequence, final int column, int seq) { StringBuilder text = new StringBuilder(32); @@ -884,7 +886,7 @@ public class SeqPanel extends JPanel implements MouseListener, /* * Try to translate the display character to residue name (null for gap). */ - final String displayChar = String.valueOf(sequence.getCharAt(res)); + final String displayChar = String.valueOf(sequence.getCharAt(column)); if (av.getAlignment().isNucleotide()) { residue = ResidueProperties.nucleotideName.get(displayChar); @@ -905,9 +907,9 @@ public class SeqPanel extends JPanel implements MouseListener, } int pos = -1; + pos = sequence.findPosition(column); if (residue != null) { - pos = sequence.findPosition(res); text.append(" (").append(Integer.toString(pos)).append(")"); } ap.alignFrame.statusBar.setText(text.toString()); @@ -1055,7 +1057,7 @@ public class SeqPanel extends JPanel implements MouseListener, return; } - int res = findRes(evt); + int res = findColumn(evt); if (res < 0) { @@ -1552,7 +1554,7 @@ public class SeqPanel extends JPanel implements MouseListener, List features = seqCanvas.getFeatureRenderer() .findFeaturesAtRes(sequence.getDatasetSequence(), - sequence.findPosition(findRes(evt))); + sequence.findPosition(findColumn(evt))); if (!features.isEmpty()) { @@ -1614,7 +1616,7 @@ public class SeqPanel extends JPanel implements MouseListener, */ public void doMousePressedDefineMode(MouseEvent evt) { - final int res = findRes(evt); + final int res = findColumn(evt); final int seq = findSeq(evt); oldSeq = seq; needOverviewUpdate = false; @@ -1673,7 +1675,7 @@ public class SeqPanel extends JPanel implements MouseListener, if (av.cursorMode) { - seqCanvas.cursorX = findRes(evt); + seqCanvas.cursorX = findColumn(evt); seqCanvas.cursorY = findSeq(evt); seqCanvas.repaint(); return; @@ -1729,7 +1731,7 @@ public class SeqPanel extends JPanel implements MouseListener, */ void showPopupMenu(MouseEvent evt) { - final int res = findRes(evt); + final int res = findColumn(evt); final int seq = findSeq(evt); SequenceI sequence = av.getAlignment().getSequenceAt(seq); List allFeatures = ap.getFeatureRenderer() @@ -1800,7 +1802,7 @@ public class SeqPanel extends JPanel implements MouseListener, */ public void doMouseDraggedDefineMode(MouseEvent evt) { - int res = findRes(evt); + int res = findColumn(evt); int y = findSeq(evt); if (wrappedBlock != startWrapBlock)