X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSeqPanel.java;h=31bf6a48af3a14ba96afd2d99d026c0171919f19;hb=25d8a7ecd5e259b37f54e33cc3989f29cca4bf4f;hp=4dd131ad1bf9583e495b2361ac83e9db2f29e2fc;hpb=4099019578bbeb81b76154922851ada38fb0017d;p=jalview.git diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 4dd131a..31bf6a4 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -481,7 +481,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, * Convert position in sequence (base 1) to sequence character array * index (base 0) */ - int start = m.getStart() - 1; + int start = m.getStart() - m.getSequence().getStart(); setStatusMessage(seq, start, sequenceIndex); return true; } @@ -489,6 +489,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, return false; } + @Override public void mousePressed(MouseEvent evt) { lastMousePress = evt.getPoint(); @@ -539,6 +540,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, return; } + @Override public void mouseClicked(MouseEvent evt) { SequenceI sequence = av.getAlignment().getSequenceAt(findSeq(evt)); @@ -564,14 +566,15 @@ public class SeqPanel extends Panel implements MouseMotionListener, } if (features != null && features.length > 0) { - seqCanvas.getFeatureRenderer().amendFeatures(new SequenceI[] - { sequence }, features, false, ap); + seqCanvas.getFeatureRenderer().amendFeatures( + new SequenceI[] { sequence }, features, false, ap); seqCanvas.highlightSearchResults(null); } } } + @Override public void mouseReleased(MouseEvent evt) { mouseDragging = false; @@ -607,8 +610,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, } int cHeight = av.getAlignment().getHeight() * av.getCharHeight() - + hgap - + seqCanvas.getAnnotationHeight(); + + hgap + seqCanvas.getAnnotationHeight(); int y = evt.getY(); y -= hgap; @@ -665,8 +667,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, } int cHeight = av.getAlignment().getHeight() * av.getCharHeight() - + hgap - + seqCanvas.getAnnotationHeight(); + + hgap + seqCanvas.getAnnotationHeight(); y -= hgap; @@ -717,6 +718,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, String lastMessage; + @Override public void mouseOverSequence(SequenceI sequence, int index, int pos) { String tmp = sequence.hashCode() + index + ""; @@ -728,6 +730,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, lastMessage = tmp; } + @Override public void highlightSequence(SearchResults results) { if (av.isFollowHighlight()) @@ -748,12 +751,14 @@ public class SeqPanel extends Panel implements MouseMotionListener, return this.ap == null ? null : this.ap.av; } + @Override public void updateColours(SequenceI seq, int index) { System.out.println("update the seqPanel colours"); // repaint(); } + @Override public void mouseMoved(MouseEvent evt) { int res = findRes(evt); @@ -800,8 +805,8 @@ public class SeqPanel extends Panel implements MouseMotionListener, } else { - obj = "X".equalsIgnoreCase(ch) ? "X" - : ResidueProperties.aa2Triplet.get(ch); + obj = "X".equalsIgnoreCase(ch) ? "X" : ResidueProperties.aa2Triplet + .get(ch); if (obj != null) { text.append(" Residue: ").append(obj); @@ -885,13 +890,15 @@ public class SeqPanel extends Panel implements MouseMotionListener, for (int i = 0; i < features.length; i++) { if (av.getFeaturesDisplayed() == null - || !av.getFeaturesDisplayed().isVisible(features[i].getType())) + || !av.getFeaturesDisplayed().isVisible( + features[i].getType())) { continue; } if (features[i].featureGroup != null - && !seqCanvas.fr.checkGroupVisibility(features[i].featureGroup,false)) + && !seqCanvas.fr.checkGroupVisibility( + features[i].featureGroup, false)) { continue; } @@ -912,6 +919,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, Tooltip tooltip; + @Override public void mouseDragged(MouseEvent evt) { if (mouseWheelPressed) @@ -1047,8 +1055,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (editCommand == null) { editCommand = new EditCommand(MessageManager.formatMessage( - "label.edit_params", new String[] - { label })); + "label.edit_params", new String[] { label })); } } @@ -1282,14 +1289,14 @@ public class SeqPanel extends Panel implements MouseMotionListener, { for (int j = lastres; j < startres; j++) { - insertChar(j, new SequenceI[] - { seq }, fixedRight); + insertChar(j, new SequenceI[] { seq }, fixedRight); } } else { - editCommand.appendEdit(Action.INSERT_GAP, new SequenceI[] - { seq }, lastres, startres - lastres, av.getAlignment(), true); + editCommand.appendEdit(Action.INSERT_GAP, + new SequenceI[] { seq }, lastres, startres - lastres, + av.getAlignment(), true); } } else @@ -1304,8 +1311,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, endEditing(); break; } - deleteChar(startres, new SequenceI[] - { seq }, fixedRight); + deleteChar(startres, new SequenceI[] { seq }, fixedRight); } } else @@ -1323,8 +1329,9 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (max > 0) { - editCommand.appendEdit(Action.DELETE_GAP, new SequenceI[] - { seq }, startres, max, av.getAlignment(), true); + editCommand.appendEdit(Action.DELETE_GAP, + new SequenceI[] { seq }, startres, max, + av.getAlignment(), true); } } } @@ -1660,6 +1667,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, seqCanvas.repaint(); } + @Override public void mouseEntered(MouseEvent e) { if (oldSeq < 0) @@ -1674,6 +1682,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, } } + @Override public void mouseExited(MouseEvent e) { if (av.getWrapAlignment()) @@ -1733,6 +1742,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, running = false; } + @Override public void run() { running = true; @@ -1777,6 +1787,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, /** * modify current selection according to a received message. */ + @Override public void selection(SequenceGroup seqsel, ColumnSelection colsel, SelectionSource source) { @@ -1802,9 +1813,12 @@ public class SeqPanel extends Panel implements MouseMotionListener, // do we want to thread this ? (contention with seqsel and colsel locks, I // suspect) - // rules are: colsel is copied if there is a real intersection between - // sequence selection - boolean repaint = false, copycolsel = true; + /* + * only copy colsel if there is a real intersection between + * sequence selection and this panel's alignment + */ + boolean repaint = false; + boolean copycolsel = false; if (av.getSelectionGroup() == null || !av.isSelectionGroupChanged(true)) { SequenceGroup sgroup = null; @@ -1821,11 +1835,9 @@ public class SeqPanel extends Panel implements MouseMotionListener, } sgroup = seqsel.intersect(av.getAlignment(), (av.hasHiddenRows()) ? av.getHiddenRepSequences() : null); - if ((sgroup == null || sgroup.getSize() == 0) - && (colsel == null || colsel.size() == 0)) + if ((sgroup != null && sgroup.getSize() > 0)) { - // don't copy columns if the region didn't intersect. - copycolsel = false; + copycolsel = true; } } if (sgroup != null && sgroup.getSize() > 0) @@ -1844,7 +1856,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, { // the current selection is unset or from a previous message // so import the new colsel. - if (colsel == null || colsel.size() == 0) + if (colsel == null || colsel.isEmpty()) { if (av.getColumnSelection() != null) { @@ -1929,33 +1941,34 @@ public class SeqPanel extends Panel implements MouseMotionListener, protected boolean selectionFromTranslation(SequenceGroup seqsel, ColumnSelection colsel, SelectionSource source) { - if (!(source instanceof AlignViewportI)) { + if (!(source instanceof AlignViewportI)) + { return false; } final AlignViewportI sourceAv = (AlignViewportI) source; - if (sourceAv.getCodingComplement() != av && av.getCodingComplement() != sourceAv) + if (sourceAv.getCodingComplement() != av + && av.getCodingComplement() != sourceAv) { return false; } - + /* * Map sequence selection */ SequenceGroup sg = MappingUtils.mapSequenceGroup(seqsel, sourceAv, av); av.setSelectionGroup(sg); av.isSelectionGroupChanged(true); - + /* * Map column selection */ ColumnSelection cs = MappingUtils.mapColumnSelection(colsel, sourceAv, av); av.setColumnSelection(cs); - av.isColSelChanged(true); - + ap.scalePanelHolder.repaint(); ap.repaint(); - + return true; }