X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqPanel.java;h=162f978ab4adec11a87e246a6f35f6a8a2df3687;hb=e542a2b9968ee6a7def19e79e84c27684ee686e3;hp=986f9966016d6c6b111a92a3c651da9b0fe3969f;hpb=b7d08a8fc06966d98af98e4eaacb03db813005f5;p=jalview.git diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 986f996..162f978 100755 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -6,8 +6,6 @@ import jalview.datamodel.*; import javax.swing.*; import java.util.*; import jalview.schemes.*; -import jalview.analysis.*; - public class SeqPanel extends JPanel { @@ -27,6 +25,10 @@ public class SeqPanel extends JPanel // if character is inserted or deleted, we will need to recalculate the conservation int seqEditOccurred = -1; + ScrollThread scrollThread = null; + boolean mouseDragging = false; + + public SeqPanel(AlignViewport avp, AlignmentPanel p) { this.av = avp; @@ -75,6 +77,21 @@ public class SeqPanel extends JPanel else doMousePressedDefineMode(evt); } + public void mouseExited(MouseEvent evt) + { + if (av.getWrapAlignment() || evt.isShiftDown() || evt.isAltDown() || + evt.isControlDown()) + return; + doMouseExitedDefineMode(evt); + + } + public void mouseEntered(MouseEvent evt) + { + if (av.getWrapAlignment() || evt.isShiftDown() || evt.isAltDown() || + evt.isControlDown()) + return; + doMouseEnteredDefineMode(evt); + } }); repaint(); @@ -96,8 +113,7 @@ public class SeqPanel extends JPanel seqEditOccurred = -1; - ap.RefreshPanels(); - repaint(); + ap.repaint(); } @@ -156,8 +172,6 @@ public class SeqPanel extends JPanel y %= chunkHeight; seq = y / av.getCharHeight() + av.getStartSeq(); - // chunkHeight = (da.getHeight() + 2)*charHeight; - // startx += chunkWidth; } else { @@ -170,6 +184,9 @@ public class SeqPanel extends JPanel return; SequenceI sequence = av.getAlignment().getSequenceAt(seq); + if(res>sequence.getLength()) + return; + Object obj = ResidueProperties.aa2Triplet.get( sequence.getCharAt(res)+"" ) ; String aa = ""; if(obj!=null) @@ -181,7 +198,8 @@ public class SeqPanel extends JPanel ap.alignFrame.statusBar.setText(text.toString()); - if(av.showSequenceFeatures) + // use aa to see if the mouse pointer is on a + if( av.showSequenceFeatures) { Vector features = sequence.getSequenceFeatures(); Enumeration e = features.elements(); @@ -197,7 +215,8 @@ public class SeqPanel extends JPanel if(sbuffer.length()>0) sbuffer.append("; "); sbuffer.append(sf.getType() + " " + sf.getDescription()); - + if(sf.getStatus().length()>0) + sbuffer.append(" ("+sf.getStatus()+")"); } } @@ -212,6 +231,9 @@ public class SeqPanel extends JPanel public void doMouseDragged(MouseEvent evt) { // If we're dragging we're editing + if(lastres==-1) + return; + int x = evt.getX(); int res = x/av.getCharWidth() + av.getStartRes(); @@ -223,7 +245,9 @@ public class SeqPanel extends JPanel // Group editing if (evt.isAltDown() || evt.isControlDown()) { - SequenceGroup sg = av.getAlignment().findGroup(startseq); + SequenceGroup sg = av.getSelectionGroup(); + if(sg==null) + av.getAlignment().findGroup(startseq); if (sg != null) { boolean deleteAllowed = false; @@ -323,31 +347,29 @@ public class SeqPanel extends JPanel { if ( jalview.util.Comparison.isGap( av.alignment.getSequenceAt(seq).getSequence().charAt(j))) - av.alignment.getSequenceAt(seq).deleteCharAt(j); + av.alignment.getSequenceAt(seq).deleteCharAt(j); av.alignment.getWidth(); repaint(); seqEditOccurred=seq; + } void updateConservation(int i) { - /* Alignment al = (Alignment) av.getAlignment(); - SequenceGroup sg = av.alignment.findGroup( al.getSequenceAt(i)); - if(sg==null || !(sg.cs instanceof ConservationColourScheme)) - return; + av.updateConservation(); + av.updateConsensus(); + + ColourSchemeI cs = av.getGlobalColourScheme(); + if(cs instanceof ConservationColourScheme) + cs = ( (ConservationColourScheme) cs).cs; + + if(cs instanceof ClustalxColourScheme) + cs = new ClustalxColourScheme(av.alignment.getSequences(), av.alignment.getWidth()); - Conservation c = sg.getConservation(); + ap.alignFrame.changeColour(cs); - c = new Conservation("All", al.cons, - ResidueProperties.propHash, 3, sg.sequences, 0, - al.getWidth()); - c.calculate(); - c.verdict(false, 100); - sg.setConservation(c); - ConservationColourScheme ccs = (ConservationColourScheme)sg.cs; - ccs.conserve = c;*/ } ////////////////////////////////////////// @@ -360,24 +382,29 @@ public class SeqPanel extends JPanel int seq = evt.getY()/av.getCharHeight() + av.getStartSeq(); oldSeq = seq; - stretchGroup = av.getRubberbandGroup(); + SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(seq); + + if(sequence==null || res>sequence.getLength()) + return; + + stretchGroup = av.getSelectionGroup(); if(stretchGroup == null) { - stretchGroup = av.alignment.findGroup( (Sequence) av.getAlignment(). - getSequenceAt(seq)); - av.setRubberbandGroup( stretchGroup ); + stretchGroup = av.alignment.findGroup( sequence ); + if(stretchGroup!=null && res>stretchGroup.getStartRes() && resres || stretchGroup.getEndRes()= res) { stretchGroup = allGroups[i]; - av.setRubberbandGroup(stretchGroup); + av.setSelectionGroup(stretchGroup); break; } } @@ -396,19 +423,14 @@ public class SeqPanel extends JPanel SequenceGroup sg = new SequenceGroup(); sg.setStartRes(res); sg.setEndRes(res); - sg.addSequence( (Sequence)av.getAlignment().getSequenceAt(seq) ); - av.setRubberbandGroup( sg ); + sg.addSequence( sequence ); + av.setSelectionGroup( sg ); stretchGroup = sg; if(av.getConservationSelected()) - Desktop.setConservationSliderSource(ap, av.getGlobalColourScheme(), "Background"); - else if(av.getGlobalColourScheme()!=null && av.getGlobalColourScheme().canThreshold()) - { - ResidueColourScheme rcs = (ResidueColourScheme) av.getGlobalColourScheme(); - int threshold = rcs.getThreshold(); - if (threshold > 0) - Desktop.setPIDSliderSource(ap, av.getGlobalColourScheme(), "Background"); - } + SliderPanel.setConservationSlider(ap, av.getGlobalColourScheme(), "Background"); + if(av.getAbovePIDThreshold()) + SliderPanel.setPIDSliderSource(ap, av.getGlobalColourScheme(), "Background"); } else if( javax.swing.SwingUtilities.isRightMouseButton(evt)) @@ -428,7 +450,6 @@ public class SeqPanel extends JPanel changeStartRes = true; - seqCanvas.paintFlag = true; repaint(); } @@ -441,32 +462,23 @@ public class SeqPanel extends JPanel public void doMouseReleasedDefineMode(MouseEvent evt) { + mouseDragging = false; + + if(stretchGroup==null) + return; if(stretchGroup.cs instanceof ClustalxColourScheme) { stretchGroup.cs = new ClustalxColourScheme(stretchGroup.sequences, av.alignment.getWidth()); - seqCanvas.paintFlag = true; repaint(); } else if(stretchGroup.cs instanceof ConservationColourScheme) { - ConservationColourScheme ccs = (ConservationColourScheme)stretchGroup.cs; - - Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, stretchGroup.sequences, 0, - av.alignment.getWidth() ); - - c.calculate(); - c.verdict(false, 100); - ccs = new ConservationColourScheme(c, ccs.cs); - + ConservationColourScheme ccs = (ConservationColourScheme)stretchGroup.cs; stretchGroup.cs = ccs; + SliderPanel.setConservationSlider(ap, stretchGroup.cs, stretchGroup.getName()) ; - - Desktop.setConservationSliderSource(ap, stretchGroup.cs, stretchGroup.getName()) ; - - seqCanvas.paintFlag = true; repaint(); } else @@ -474,9 +486,7 @@ public class SeqPanel extends JPanel if(stretchGroup.cs !=null && stretchGroup.cs.canThreshold()) { ResidueColourScheme rcs = (ResidueColourScheme) stretchGroup.cs; - int threshold = rcs.getThreshold(); - if(threshold>0) - Desktop.setPIDSliderSource(ap, stretchGroup.cs, stretchGroup.getName()); + SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, stretchGroup.getName()); } } @@ -485,6 +495,7 @@ public class SeqPanel extends JPanel changeEndRes = false; changeStartRes = false; stretchGroup = null; + ap.idPanel.repaint(); } @@ -494,6 +505,12 @@ public class SeqPanel extends JPanel int res = evt.getX()/av.getCharWidth() + av.getStartRes(); int y = evt.getY()/av.getCharHeight() + av.getStartSeq(); + if(stretchGroup==null) + return; + + if(res>av.alignment.getWidth()) + res = av.alignment.getWidth()-1; + if(stretchGroup.getEndRes()==res) // Edit end res position of selected group @@ -520,14 +537,13 @@ public class SeqPanel extends JPanel stretchGroup.setStartRes( res ); } - int dragDirection = 0; if (y > oldSeq) dragDirection = 1; else if (y < oldSeq) dragDirection = -1; - while (y != oldSeq) + while (y != oldSeq && oldSeq>0 && y 0) + running = ap.scrollUp(true); + + if (mouseDragging && evt.getY() >= getHeight() && + av.alignment.getHeight() > av.getEndSeq()) + running = ap.scrollUp(false); + + if (mouseDragging && evt.getX() < 0) + running = ap.scrollRight(true); + + else if (mouseDragging && evt.getX() >= getWidth()) + running = ap.scrollRight(false); + } + + try + { + Thread.sleep(75); + } + catch (Exception ex) + {} + } + } +} + + }