X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fappletgui%2FSeqPanel.java;h=f9304cf562f6b6ef5cef349df5f6606c8a2a86ba;hb=449db06a788539e8ea7463ff4b56f012280994d0;hp=f4f2cfd2bebf7e3aef5ed8ed85b38ed687497335;hpb=890bd0eac47a4b0f55bd062a359c16a43c3780a0;p=jalview.git diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index f4f2cfd..f9304cf 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -448,7 +448,40 @@ public class SeqPanel } public void mouseClicked(MouseEvent evt) - {} + { + SequenceI sequence = av.alignment.getSequenceAt(findSeq(evt)); + if (evt.getClickCount() > 1) + { + if (av.getSelectionGroup().getSize() == 1 + && av.getSelectionGroup().getEndRes() + - av.getSelectionGroup().getStartRes() < 2) + { + av.setSelectionGroup(null); + } + + SequenceFeature[] features = findFeaturesAtRes( + sequence, + sequence.findPosition(findRes(evt)) + ); + + if (features != null && features.length > 0) + { + SearchResults highlight = new SearchResults(); + highlight.addResult(sequence, + features[0].getBegin(), + features[0].getEnd()); + seqCanvas.highlightSearchResults(highlight); + } + if (features != null && features.length > 0) + { + seqCanvas.getFeatureRenderer().amendFeatures( + new SequenceI[] + {sequence}, features, false, ap); + + seqCanvas.highlightSearchResults(null); + } + } + } public void mouseReleased(MouseEvent evt) { @@ -554,6 +587,8 @@ public class SeqPanel return seq; } + + public void doMousePressed(MouseEvent evt) { @@ -691,18 +726,13 @@ public class SeqPanel } // use aa to see if the mouse pointer is on a - if (av.showSequenceFeatures - && sequence.getSequenceFeatures() != null - && av.featuresDisplayed != null) - { - - Vector allFeatures = getAllFeaturesAtRes(sequence, + SequenceFeature [] allFeatures = findFeaturesAtRes(sequence, sequence.findPosition(res)); int index = 0; - while (index < allFeatures.size()) + while (index < allFeatures.length) { - SequenceFeature sf = (SequenceFeature) allFeatures.elementAt(index); + SequenceFeature sf = allFeatures[index]; tooltipText.append(sf.getType() + " " + sf.begin + ":" + sf.end); @@ -723,7 +753,6 @@ public class SeqPanel index++; } - } if (tooltip == null) { @@ -735,29 +764,35 @@ public class SeqPanel } } - Vector getAllFeaturesAtRes(SequenceI seq, int res) + SequenceFeature[] findFeaturesAtRes(SequenceI sequence, int res) { - Vector allFeatures = new Vector(); - int index = 0; - if (seq.getSequenceFeatures() != null) + Vector tmp = new Vector(); + SequenceFeature[] features = sequence.getSequenceFeatures(); + if (features != null) { - while (index < seq.getSequenceFeatures().length) + for (int i = 0; i < features.length; i++) { - SequenceFeature sf = seq.getSequenceFeatures()[index]; - if (sf.getBegin() <= res && - sf.getEnd() >= res) + if (av.featuresDisplayed == null + || !av.featuresDisplayed.containsKey(features[i].getType())) { - if (av.featuresDisplayed.containsKey(sf.getType())) - { - allFeatures.addElement(sf); - } + continue; + } + + if ( (features[i].getBegin() <= res) && + (features[i].getEnd() >= res)) + { + tmp.addElement(features[i]); } - index++; } } - return allFeatures; + + features = new SequenceFeature[tmp.size()]; + tmp.copyInto(features); + + return features; } + Tooltip tooltip; public void mouseDragged(MouseEvent evt) @@ -1320,21 +1355,20 @@ public class SeqPanel if ( (evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { - Vector allFeatures = getAllFeaturesAtRes(sequence, + SequenceFeature [] allFeatures = findFeaturesAtRes(sequence, sequence.findPosition(res)); Vector links = null; if (allFeatures != null) { - for (int i = 0; i < allFeatures.size(); i++) + for (int i = 0; i < allFeatures.length; i++) { - SequenceFeature sf = (SequenceFeature) allFeatures.elementAt(i); - if (sf.links != null) + if (allFeatures[i].links != null) { links = new Vector(); - for (int j = 0; j < sf.links.size(); j++) + for (int j = 0; j < allFeatures[i].links.size(); j++) { - links.addElement(sf.links.elementAt(j)); + links.addElement(allFeatures[i].links.elementAt(j)); } } }