X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSeqPanel.java;h=7c524ad3fcc6feaa8101f4ecfd9d5e9c35486859;hb=436a05e4d6015e30a04bb0234cebd07210137df8;hp=67b049a4f25f8f2773ea06e8f4c4e7d96325da63;hpb=ce66c3a512ba0d21dca3f389afc50b4a39ea5e1f;p=jalview.git diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 67b049a..7c524ad 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -64,19 +64,11 @@ public class SeqPanel { public void mouseMoved(MouseEvent evt) { - if (av.getWrapAlignment()) - { - return; - } doMouseMoved(evt); } public void mouseDragged(MouseEvent evt) { - if (av.getWrapAlignment()) - { - return; - } if (editingSeqs) { doMouseDragged(evt); @@ -92,10 +84,6 @@ public class SeqPanel { public void mouseReleased(MouseEvent evt) { - if (av.getWrapAlignment()) - { - return; - } if (editingSeqs) { doMouseReleased(evt); @@ -109,10 +97,6 @@ public class SeqPanel public void mousePressed(MouseEvent evt) { - if (av.getWrapAlignment()) - { - return; - } if (evt.isShiftDown() || evt.isAltDown() || evt.isControlDown()) { if (evt.isAltDown() || evt.isControlDown()) @@ -131,7 +115,7 @@ public class SeqPanel public void mouseExited(MouseEvent evt) { - if (av.getWrapAlignment() || editingSeqs) + if (editingSeqs) { return; } @@ -141,7 +125,7 @@ public class SeqPanel public void mouseEntered(MouseEvent evt) { - if (av.getWrapAlignment() || editingSeqs) + if (editingSeqs) { return; } @@ -168,18 +152,80 @@ public class SeqPanel ap.repaint(); } + int startWrapBlock=-1; + int wrappedBlock=-1; + int findRes(MouseEvent evt) + { + int res = 0; + int x = evt.getX(); + + 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 -= hgap; + x -= seqCanvas.LABEL_WEST; + + + int cwidth = seqCanvas.getWrappedCanvasWidth(getSize().width); + + wrappedBlock = y / cHeight; + wrappedBlock += av.getStartRes() / cwidth; + + res = wrappedBlock * cwidth + x / av.getCharWidth(); + + } + else + { + res = (x / av.getCharWidth()) + av.getStartRes(); + } + + return res; + + } + + int findSeq(MouseEvent evt) + { + + int seq = 0; + int y = evt.getY(); + + if (av.wrapAlignment) + { + 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 + { + seq = (y / av.getCharHeight()) + av.getStartSeq(); + } + + return seq; + } + + public void doMousePressed(MouseEvent evt) { ap.alignFrame.addHistoryItem(new HistoryItem( "Edit Sequence", av.alignment, HistoryItem.EDIT)); - int seq; - int res; - - int x = evt.getX(); - int y = evt.getY(); - res = x / av.getCharWidth() + av.getStartRes(); - seq = y / av.getCharHeight() + av.getStartSeq(); + int seq = findSeq(evt); + int res = findRes(evt); if (seq < av.getAlignment().getHeight() && res < av.getAlignment().getSequenceAt(seq).getLength()) @@ -202,28 +248,10 @@ public class SeqPanel public void doMouseMoved(MouseEvent evt) { - int res = 0, seq = 0; - int x = evt.getX(); - int y = evt.getY(); - if (av.wrapAlignment) - { - y -= 2 * av.charHeight; - int chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; - - res = (int) ( (y / chunkHeight) * (getSize().width / av.charWidth)) + - x / av.getCharWidth() + av.getStartRes(); - - y %= chunkHeight; - seq = y / av.getCharHeight() + av.getStartSeq(); + int res = findRes(evt); + int seq = findSeq(evt); - } - else - { - res = x / av.getCharWidth() + av.getStartRes(); - seq = y / av.getCharHeight() + av.getStartSeq(); - } - - if (seq >= av.getAlignment().getHeight()) + if (seq >= av.getAlignment().getHeight() || seq<0 || res<0) { return; } @@ -234,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()); @@ -261,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) @@ -284,7 +330,7 @@ public class SeqPanel { // If we're dragging we're editing - int res = evt.getX() / av.getCharWidth() + av.getStartRes(); + int res = findRes(evt); if (res < 0) { res = 0; @@ -445,42 +491,11 @@ public class SeqPanel { if (endEdit == startEdit) { - ap.alignFrame.historyList.pop(); - ap.alignFrame.updateEditMenuBar(); - } - - av.updateConservation(); - av.updateConsensus(); - - // Y O Y CLUSTALX - ColourSchemeI cs = av.getGlobalColourScheme(); - if (cs instanceof ConservationColourScheme) - { - ConservationColourScheme ccs = (ConservationColourScheme) cs; - if (ccs.cs instanceof ClustalxColourScheme) - { - 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); - - ClustalxColourScheme cxs = (ClustalxColourScheme) ccs.cs; - cxs.resetClustalX(av.alignment.getSequences(), av.alignment.getWidth()); - ccs = new ConservationColourScheme(c, cxs); - av.setGlobalColourScheme(ccs); - } - } - - if (cs instanceof ClustalxColourScheme) - { - ( (ClustalxColourScheme) cs).resetClustalX(av.alignment.getSequences(), - av.alignment.getWidth()); - av.setGlobalColourScheme(cs); + ap.alignFrame.historyList.pop(); + ap.alignFrame.updateEditMenuBar(); } + av.firePropertyChange("alignment", null,av.getAlignment().getSequences()); } ////////////////////////////////////////// @@ -489,9 +504,10 @@ public class SeqPanel int oldSeq = -1; public void doMousePressedDefineMode(MouseEvent evt) { - int res = evt.getX() / av.getCharWidth() + av.getStartRes(); - int seq = evt.getY() / av.getCharHeight() + av.getStartSeq(); + int res = findRes(evt); + int seq = findSeq(evt); oldSeq = seq; + startWrapBlock=wrappedBlock; SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(seq); @@ -566,7 +582,7 @@ public class SeqPanel else if ( (evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { - APopupMenu popup = new APopupMenu(ap, null); + APopupMenu popup = new APopupMenu(ap, null, null); this.add(popup); popup.show(this, evt.getX(), evt.getY()); } @@ -604,19 +620,19 @@ public class SeqPanel return; } - if (stretchGroup.cs instanceof ConservationColourScheme) - { - ConservationColourScheme ccs = (ConservationColourScheme) stretchGroup.cs; - stretchGroup.cs = ccs; - SliderPanel.setConservationSlider(ap, stretchGroup.cs, - stretchGroup.getName()); - } - else + if(stretchGroup.cs!=null) { + if (stretchGroup.cs.conservationApplied()) + { + SliderPanel.setConservationSlider(ap, stretchGroup.cs, + stretchGroup.getName()); + } + else + { SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, stretchGroup.getName()); + } } - changeEndRes = false; changeStartRes = false; stretchGroup = null; @@ -627,8 +643,14 @@ public class SeqPanel boolean remove = false; public void doMouseDraggedDefineMode(MouseEvent evt) { - int res = evt.getX() / av.getCharWidth() + av.getStartRes(); - int y = evt.getY() / av.getCharHeight() + av.getStartSeq(); + int res = findRes(evt); + int y = findSeq(evt); + + if(wrappedBlock!=startWrapBlock) + return; + + if(y>=av.alignment.getHeight()) + y = av.alignment.getHeight()-1; if (stretchGroup == null) { @@ -656,7 +678,7 @@ public class SeqPanel { res = av.getStartRes(); } - else if (res > av.getEndRes()) + else if (res > av.getEndRes() && !av.getWrapAlignment()) { res = av.getEndRes(); } @@ -698,7 +720,6 @@ public class SeqPanel if (stretchGroup.sequences.contains(nextSeq)) { stretchGroup.deleteSequence(seq, false); - stretchGroup.deleteSequence(nextSeq, false); } else { @@ -729,16 +750,10 @@ public class SeqPanel public void doMouseExitedDefineMode(MouseEvent e) { - if (av.getWrapAlignment()) - { - return; - } - if (mouseDragging) { scrollThread = new ScrollThread(); } - } // this class allows scrolling off the bottom of the visible alignment