X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSeqPanel.java;h=7c524ad3fcc6feaa8101f4ecfd9d5e9c35486859;hb=dea32f71ff7f8a80cc8494864b6605921d81fafa;hp=ee7676ce79e749da0ef7467b38a8e816d9053c91;hpb=da18eb63c94018e134fb60d70e6de43e99bbff50;p=jalview.git diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index ee7676c..7c524ad 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -152,6 +152,8 @@ public class SeqPanel ap.repaint(); } + int startWrapBlock=-1; + int wrappedBlock=-1; int findRes(MouseEvent evt) { int res = 0; @@ -159,16 +161,26 @@ public class SeqPanel if (av.wrapAlignment) { + + int hgap = av.charHeight; + if (av.scaleAboveWrapped) + hgap += av.charHeight; + + int cHeight = av.getAlignment().getHeight() * av.charHeight + + hgap + seqCanvas.getAnnotationHeight(); + int y = evt.getY(); - y -= (2 * av.charHeight); + y -= hgap; x -= seqCanvas.LABEL_WEST; - int chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; - int cwidth = seqCanvas.getWrappedCanvasWidth(this.getSize().width); - int block = y/chunkHeight; - block += av.getStartRes()/cwidth; - res = block*cwidth + x / av.getCharWidth(); + int cwidth = seqCanvas.getWrappedCanvasWidth(getSize().width); + + wrappedBlock = y / cHeight; + wrappedBlock += av.getStartRes() / cwidth; + + res = wrappedBlock * cwidth + x / av.getCharWidth(); + } else { @@ -181,14 +193,22 @@ public class SeqPanel int findSeq(MouseEvent evt) { + int seq = 0; int y = evt.getY(); if (av.wrapAlignment) { - y -= (2 * av.charHeight); - int chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; - seq = ( (y % chunkHeight) / av.getCharHeight()); + int hgap = av.charHeight; + if (av.scaleAboveWrapped) + hgap += av.charHeight; + + int cHeight = av.getAlignment().getHeight() * av.charHeight + + hgap + seqCanvas.getAnnotationHeight(); + + y -= hgap; + + seq = ( (y % cHeight) / av.getCharHeight()); } else { @@ -231,7 +251,7 @@ public class SeqPanel int res = findRes(evt); int seq = findSeq(evt); - if (seq >= av.getAlignment().getHeight() || seq<0) + if (seq >= av.getAlignment().getHeight() || seq<0 || res<0) { return; } @@ -242,19 +262,37 @@ public class SeqPanel return; } - Object obj = ResidueProperties.aa2Triplet.get(sequence.getCharAt(res) + ""); - String aa = ""; + StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " + + sequence.getName()); + + Object obj = null; + if (av.alignment.isNucleotide()) + { + obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res) + + ""); + if(obj!=null) + text.append(" Nucleotide: "); + } + else + { + obj = ResidueProperties.aa2Triplet.get(sequence.getCharAt(res) + ""); + if(obj!=null) + text.append(" Residue: "); + } + if (obj != null) { - aa = obj.toString(); + + if (obj != "") + { + text.append(obj + " (" + + av.getAlignment().getSequenceAt(seq).findPosition(res) + ")"); + } } - StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " + - sequence.getName()); - if (aa != "") + if(seqCanvas.pdbCanvas!=null && sequence==seqCanvas.pdbCanvas.sequence) { - text.append(" Residue: " + aa + " (" + - av.getAlignment().getSequenceAt(seq).findPosition(res) + ")"); + seqCanvas.pdbCanvas.highlightRes(sequence.findPosition(res)); } ap.alignFrame.statusBar.setText(text.toString()); @@ -269,7 +307,7 @@ public class SeqPanel while (e.hasMoreElements()) { SequenceFeature sf = (SequenceFeature) e.nextElement(); - if (sf.getStart() <= sequence.findPosition(res) && + if (sf.getBegin() <= sequence.findPosition(res) && sf.getEnd() >= sequence.findPosition(res)) { if (sbuffer.length() > 0) @@ -457,105 +495,7 @@ public class SeqPanel ap.alignFrame.updateEditMenuBar(); } - av.updateConservation(); - av.updateConsensus(); - - - //Does the edit affect any groups? - ////////////////////////////// - Vector groupsToUpdate = new Vector(); - SequenceGroup sg = av.getSelectionGroup(); - - int s, g, gSize = av.alignment.getGroups().size(); - if (sg != null) - { - groupsToUpdate.addElement(av.getSelectionGroup()); - int sSize = sg.getSize(); - for (s = 0; s < sSize; s++) - { - SequenceI seq = sg.getSequenceAt(s); - - for (g = 0; g < gSize; g++) - { - SequenceGroup sg2 = (SequenceGroup) av.alignment.getGroups(). - elementAt( - g); - if (sg2.sequences.contains(seq)) - { - if (!groupsToUpdate.contains(sg2)) - groupsToUpdate.addElement(sg2); - continue; - } - } - } - } - else - { - SequenceI seq = av.alignment.getSequenceAt(startseq); - for (g = 0; g < gSize; g++) - { - SequenceGroup sg2 = (SequenceGroup) av.alignment.getGroups().elementAt( - g); - if (sg2.sequences.contains(seq)) - { - if (!groupsToUpdate.contains(sg2)) - groupsToUpdate.addElement(sg2); - continue; - } - } - } - - gSize = groupsToUpdate.size(); - for (g = 0; g < gSize; g++) - { - ( (SequenceGroup) groupsToUpdate.elementAt(g)).recalcConservation(); - } - ////End of updating groups - ////////////////////////////////////////// - - - // Y O Y CLUSTALX - ColourSchemeI cs = av.getGlobalColourScheme(); - - if (av.getSelectionGroup() != null) - { - av.getSelectionGroup().recalcConservation(); - } - - if(cs!=null) - { - if (cs.conservationApplied()) - { - jalview.analysis.Conservation c = new jalview.analysis.Conservation("All", - ResidueProperties.propHash, 3, - av.alignment.getSequences(), - 0, av.alignment.getWidth() - 1); - c.calculate(); - c.verdict(false, av.ConsPercGaps); - - if (cs instanceof ClustalxColourScheme) - { - ((ClustalxColourScheme)cs). - resetClustalX(av.alignment.getSequences(), - av.alignment.getWidth()); - cs.setConservation(c); - av.setGlobalColourScheme(cs); - } - else - { - cs.setConservation(c); - av.setGlobalColourScheme(cs); - } - - } - - if (cs instanceof ClustalxColourScheme) - { - ( (ClustalxColourScheme) cs).resetClustalX(av.alignment.getSequences(), - av.alignment.getWidth()); - av.setGlobalColourScheme(cs); - } - } + av.firePropertyChange("alignment", null,av.getAlignment().getSequences()); } ////////////////////////////////////////// @@ -567,6 +507,7 @@ public class SeqPanel int res = findRes(evt); int seq = findSeq(evt); oldSeq = seq; + startWrapBlock=wrappedBlock; SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(seq); @@ -705,6 +646,9 @@ public class SeqPanel int res = findRes(evt); int y = findSeq(evt); + if(wrappedBlock!=startWrapBlock) + return; + if(y>=av.alignment.getHeight()) y = av.alignment.getHeight()-1; @@ -713,7 +657,7 @@ public class SeqPanel return; } - if (res > av.alignment.getWidth() && !av.getWrapAlignment()) + if (res > av.alignment.getWidth()) { res = av.alignment.getWidth() - 1; }