From 577f505f54fe343e89f581461e780ea8308c20ec Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 15 Mar 2005 16:06:54 +0000 Subject: [PATCH] selection removed, now SelectionGroup does same job as id select and residue select --- src/jalview/gui/AlignFrame.java | 43 ++++--- src/jalview/gui/AlignViewport.java | 16 ++- src/jalview/gui/AlignmentPanel.java | 100 ++++++++++++---- src/jalview/gui/Desktop.java | 3 +- src/jalview/gui/Finder.java | 8 +- src/jalview/gui/GroupEditor.java | 10 +- src/jalview/gui/IdCanvas.java | 28 +++-- src/jalview/gui/IdPanel.java | 197 +++++++++++++++++++++---------- src/jalview/gui/PCAPanel.java | 6 +- src/jalview/gui/PairwiseAlignPanel.java | 5 +- src/jalview/gui/PopupMenu.java | 12 +- src/jalview/gui/RedundancyPanel.java | 13 +- src/jalview/gui/RotatableCanvas.java | 29 +++-- src/jalview/gui/ScalePanel.java | 6 +- src/jalview/gui/Selection.java | 73 ------------ src/jalview/gui/SeqCanvas.java | 2 +- src/jalview/gui/SeqPanel.java | 105 +++++++++++++++- src/jalview/gui/SequenceRenderer.java | 5 +- src/jalview/gui/SplashScreen.java | 2 +- src/jalview/gui/TreeCanvas.java | 47 ++++---- src/jalview/gui/UserDefinedColours.java | 2 + 21 files changed, 429 insertions(+), 283 deletions(-) delete mode 100755 src/jalview/gui/Selection.java diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 4209455..c679559 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -64,6 +64,7 @@ public class AlignFrame extends GAlignFrame protected void saveAs_actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY")); + chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Save Alignment to file - "+e.getActionCommand() +" format."); chooser.setToolTipText("Save"); int value = chooser.showSaveDialog(this); @@ -222,7 +223,7 @@ public class AlignFrame extends GAlignFrame public void moveSelectedSequences(boolean up) { - SequenceGroup sg = viewport.getRubberbandGroup(); + SequenceGroup sg = viewport.getSelectionGroup(); if (sg == null) return; @@ -266,10 +267,10 @@ public class AlignFrame extends GAlignFrame protected void copy_actionPerformed(ActionEvent e) { - if(viewport.getRubberbandGroup()==null) + if(viewport.getSelectionGroup()==null) return; - SequenceGroup sg = viewport.getRubberbandGroup(); + SequenceGroup sg = viewport.getSelectionGroup(); Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); StringBuffer buffer= new StringBuffer(); @@ -352,10 +353,10 @@ public class AlignFrame extends GAlignFrame protected void delete_actionPerformed(ActionEvent e) { addHistoryItem("Delete"); - if (viewport.getRubberbandGroup() == null) + if (viewport.getSelectionGroup() == null) return; - SequenceGroup sg = viewport.getRubberbandGroup(); + SequenceGroup sg = viewport.getSelectionGroup(); for (int i=0;i < sg.sequences.size(); i++) { SequenceI seq = sg.getSequenceAt(i); @@ -368,7 +369,7 @@ public class AlignFrame extends GAlignFrame viewport.getAlignment().getSequences().setElementAt(seq, index); } - viewport.setRubberbandGroup(null); + viewport.setSelectionGroup(null); viewport.alignment.deleteGroup(sg); viewport.resetSeqLimits( alignPanel.seqPanel.seqCanvas.getHeight()); if(viewport.getAlignment().getHeight()<1) @@ -404,7 +405,7 @@ public class AlignFrame extends GAlignFrame protected void deleteGroups_actionPerformed(ActionEvent e) { viewport.alignment.deleteAllGroups(); - viewport.getSelection().clear(); + viewport.setSelectionGroup(null); alignPanel.RefreshPanels(); } @@ -413,29 +414,26 @@ public class AlignFrame extends GAlignFrame public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e) { - Selection sel = viewport.getSelection(); + SequenceGroup sg = new SequenceGroup(); for (int i=0; i0) + + if( (viewport.getSelectionGroup()!=null && viewport.getSelectionGroup().getSize()<4 && viewport.getSelectionGroup().getSize()>0) || viewport.getAlignment().getHeight()<4) { JOptionPane.showInternalMessageDialog(this, "Principal component analysis must take\n" @@ -938,9 +937,9 @@ if ( viewport.getConservationSelected() ) } TreePanel tp=null; - if (viewport.getSelection() != null && viewport.getSelection().size() > 3) + if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize() > 3) { - tp = new TreePanel(viewport, viewport.getSelection().asVector(),type, pwType, + tp = new TreePanel(viewport, viewport.getSelectionGroup().sequences,type, pwType, 0, viewport.alignment.getWidth()); } else diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 7719f02..2f40de4 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -28,7 +28,7 @@ public class AlignViewport boolean conservationColourSelected = false; boolean abovePIDThreshold = false; - SequenceGroup rubberbandGroup = null; + SequenceGroup selectionGroup = new SequenceGroup(); RendererI renderer = new SequenceRenderer(this); @@ -40,7 +40,6 @@ public class AlignViewport Font font = new Font("SansSerif",Font.PLAIN,10); AlignmentI alignment; - Selection sel = new Selection(this); ColumnSelection colSel = new ColumnSelection(); String visibleConsensus; @@ -116,16 +115,17 @@ public class AlignViewport return consensus; } - public SequenceGroup getRubberbandGroup() + public SequenceGroup getSelectionGroup() { - return rubberbandGroup; + return selectionGroup; } - public void setRubberbandGroup(SequenceGroup sg) + public void setSelectionGroup(SequenceGroup sg) { - rubberbandGroup = sg; + selectionGroup = sg; } + public boolean getConservationSelected() { return conservationColourSelected; @@ -325,9 +325,7 @@ public class AlignViewport } return -1; } - public Selection getSelection() { - return sel; - } + public ColumnSelection getColumnSelection() { return colSel; } diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index fafcdcd..15f1a1f 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -55,8 +55,8 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene }); - hscroll.setFocusable(false); - vscroll.setFocusable(false); + // hscroll.setFocusable(false); + // vscroll.setFocusable(false); setFocusable(true); addKeyListener(new KeyAdapter() @@ -66,8 +66,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene switch(evt.getKeyCode()) { case 27: // escape key - av.setRubberbandGroup(null); - av.getSelection().clear(); + av.setSelectionGroup(null); RefreshPanels(); break; case KeyEvent.VK_X: @@ -180,33 +179,83 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene public void RefreshPanels() { - requestFocus(); - invalidate(); - idPanelHolder.setPreferredSize( idPanel.idCanvas.getPreferredSize() ); - idSpaceFillerPanel1.setPreferredSize(new Dimension(500, av.charHeight/2 +12)); - scalePanelHolder.setPreferredSize(new Dimension(500, av.charHeight/2 +12)); - if(av.getWrapAlignment()) - { - int max = av.alignment.getWidth()/ (seqPanel.seqCanvas.getWidth()/av.charWidth)+1; + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + + requestFocus(); + invalidate(); + idPanelHolder.setPreferredSize(idPanel.idCanvas.getPreferredSize()); + hscrollFillerPanel.setPreferredSize(new Dimension(idPanel.idCanvas. + getPreferredSize().width, 12)); + idSpaceFillerPanel1.setPreferredSize(new Dimension(500, + av.charHeight / 2 + 12)); + scalePanelHolder.setPreferredSize(new Dimension(500, + av.charHeight / 2 + 12)); + if (av.getWrapAlignment()) + { + int max = av.alignment.getWidth() / + (seqPanel.seqCanvas.getWidth() / av.charWidth) + 1; + + int h = (av.alignment.getHeight() + 2) * av.charHeight; + vextent = seqPanel.seqCanvas.getHeight() / h; + vscroll.setValues(0, vextent, 0, max); + } + else + + setScrollValues(av.getStartRes(), av.getStartSeq()); + av.getConsensus(true); + if (overviewPanel != null) + overviewPanel.updateOverviewImage(); + + } + }); + + validate(); + repaint(); + } + int hextent = 0; + int vextent = 0; + - int h = (av.alignment.getHeight() + 2)*av.charHeight; - vextent = seqPanel.seqCanvas.getHeight()/h; - vscroll.setValues(0,vextent,0,max); + // return value is true if the scroll is valid + public boolean scrollUp(boolean up) + { + if(up) + { + if(vscroll.getValue()<1) + return false; + vscroll.setValue(vscroll.getValue() - 1); } else + { + if(vextent+vscroll.getValue() >= av.getAlignment().getHeight()) + return false; + vscroll.setValue(vscroll.getValue() + 1); + } - setScrollValues(av.getStartRes(), av.getStartSeq()); - av.getConsensus(true); - if(overviewPanel!=null) - overviewPanel.updateOverviewImage(); + return true; + } - validate(); - repaint(); + public boolean scrollRight(boolean right) + { + if(right) + { + if(hscroll.getValue()<1) + return false; + hscroll.setValue(hscroll.getValue() - 1); + } + else + { + if(hextent+hscroll.getValue() >= av.getAlignment().getWidth()) + return false; + hscroll.setValue(hscroll.getValue() + 1); + } - } + return true; + } - int hextent = 0; - int vextent = 0; public void setScrollValues(int x, int y) { @@ -324,7 +373,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene Color currentTextColor=null; for(int i=startSeq; i0) - seq = (Sequence)(av.getSelection().sequenceAt(0)); + if(av.getSelectionGroup().getSize()>0) + seq = (Sequence)(av.getSelectionGroup().getSequenceAt(0)); else seq = (Sequence)av.getAlignment().getSequenceAt(0); @@ -122,7 +122,7 @@ public class Finder extends GFinder int end = av.alignment.getHeight(); - SequenceGroup rubberband = av.getRubberbandGroup(); + SequenceGroup rubberband = av.getSelectionGroup(); if(rubberband!=null) end = rubberband.getEndRes(); @@ -132,7 +132,7 @@ public class Finder extends GFinder { seq = (Sequence)av.getAlignment().getSequenceAt(seqIndex); - if( av.getSelection().size()>0 && !av.getSelection().contains(seq) + if( av.getSelectionGroup().getSize()>0 && !av.getSelectionGroup().sequences.contains(seq) || (rubberband!=null && !rubberband.sequences.contains(seq)) ) { // if a selection has been made, only search within that selection diff --git a/src/jalview/gui/GroupEditor.java b/src/jalview/gui/GroupEditor.java index 3ee186b..e3c49d6 100755 --- a/src/jalview/gui/GroupEditor.java +++ b/src/jalview/gui/GroupEditor.java @@ -198,10 +198,10 @@ public class GroupEditor extends GGroupEditor return; SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex); - Selection sel = av.getSelection(); - for(int i=0; i lastid) selectSeqs(lastid + 1, seq); lastid = seq; - - return; + alignPanel.repaint(); } public void mouseClicked(MouseEvent e) @@ -106,8 +72,28 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene } } - public void mouseEntered(MouseEvent e) { } - public void mouseExited (MouseEvent e) { } + public void mouseEntered(MouseEvent e) + { + if(scrollThread!=null) + scrollThread.running = false; + } + + public void mouseExited (MouseEvent e) + { + if(av.getWrapAlignment()) + return; + + if(mouseDragging && e.getY()<0 && av.getStartSeq()>0) + { + scrollThread = new ScrollThread(true); + } + + if(mouseDragging && e.getY()>=getHeight() && av.alignment.getHeight()>av.getEndSeq()) + { + scrollThread = new ScrollThread(false); + } + } + public void mousePressed(MouseEvent e) { if (e.getClickCount() == 2) @@ -118,6 +104,8 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene y-=2*av.charHeight; int seq = av.getIndex(y); + if (seq == -1) + return; if (javax.swing.SwingUtilities.isRightMouseButton(e)) { @@ -127,34 +115,117 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene return; } + if(!e.isControlDown() && !e.isShiftDown() && av.alignment.findGroup( av.alignment.getSequenceAt(seq))!=null) + { + SequenceGroup selection = new SequenceGroup(); + SequenceGroup sg = av.alignment.findGroup(av.alignment.getSequenceAt(seq)); + selection.setStartRes(0); + selection.setEndRes(av.alignment.getWidth()); + for (int i =0; i< sg.getSize(); i++) + selection.addSequence(sg.getSequenceAt(i)); - if(av.getRubberbandGroup()!=null && (av.getRubberbandGroup().getSize() == av.getSelection().size())) - selectedSequenceGroup = av.getRubberbandGroup(); - - if (selectedSequenceGroup == null) - { - selectedSequenceGroup = new SequenceGroup(); - av.setRubberbandGroup(selectedSequenceGroup); - av.getSelection().clear(); + av.setSelectionGroup(selection); + return; } - selectedSequenceGroup.setStartRes(0); - selectedSequenceGroup.setEndRes(av.getAlignment().getWidth() - 1); + if(av.getSelectionGroup()==null || ( !e.isControlDown() && av.getSelectionGroup()!=null)) + av.setSelectionGroup(new SequenceGroup()); - if (seq != -1) - selectSeqs(seq, seq); + av.getSelectionGroup().setStartRes(0); + av.getSelectionGroup().setEndRes(av.alignment.getWidth()); - lastid = seq; + if(e.isShiftDown() && lastid!=-1) + selectSeqs(lastid, seq); + else + selectSeq(seq); + alignPanel.seqPanel.seqCanvas.paintFlag=true; + alignPanel.repaint(); + repaint(); + } - return; + void selectSeq(int seq) + { + lastid = seq; + SequenceI pickedSeq = av.getAlignment().getSequenceAt(seq); + av.getSelectionGroup().addOrRemove(pickedSeq); } + void selectSeqs(int start, int end) { + + lastid = start; + if (end < start) + { + int tmp = start; + start = end; + end = tmp; + lastid = end; + } + + for (int i = start; i <= end; i++) + av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i)); + + } + + public void mouseReleased(MouseEvent e) { - lastid = -1; + if(scrollThread!=null) + scrollThread.running = false; + + mouseDragging = false; PaintRefresher.Refresh(this); - selectedSequenceGroup = null; } + + // this class allows scrolling off the bottom of the visible alignment + class ScrollThread + extends Thread + { + boolean running = false; + boolean up = true; + public ScrollThread(boolean up) + { + this.up = up; + start(); + } + + public void stopScrolling() + { + running = false; + } + + public void run() + { + running = true; + while (running) + { + if(alignPanel.scrollUp(up)) + { + // scroll was ok, so add new sequence to selection + int seq = av.getStartSeq(); + if(!up) + seq = av.getEndSeq(); + + if (seq < lastid) + selectSeqs(lastid - 1, seq); + else if (seq > lastid) + selectSeqs(lastid + 1, seq); + + lastid = seq; + } + else + running = false; + + alignPanel.repaint(); + try + { + Thread.sleep(100); + } + catch (Exception ex) + {} + } + } +} + } diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index 7fe3835..8e0bc37 100755 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -23,11 +23,11 @@ public class PCAPanel extends GPCAPanel implements Runnable public PCAPanel(AlignViewport av, SequenceI[] s) { this.av = av; - if(av.getSelection().size()>3) + if(av.getSelectionGroup().getSize()>3) { - s = new Sequence[av.getSelection().size()]; + s = new Sequence[av.getSelectionGroup().getSize()]; for(int i=0; i 1) + SequenceGroup sg = ap.av.getSelectionGroup(); + if (sg != null && sg.getSize() > 1) { - del = ap.av.alignment.removeRedundancy(threshold, ap.av.sel.asVector()); + del = ap.av.alignment.removeRedundancy(threshold, sg.sequences); for (int i = 0; i < del.size(); i++) - if (ap.av.sel.contains( (SequenceI) del.elementAt(i))) - ap.av.sel.removeElement( (SequenceI) del.elementAt(i)); + if (sg.sequences.contains( (SequenceI) del.elementAt(i))) + sg.deleteSequence( (SequenceI) del.elementAt(i)); } else @@ -69,8 +70,8 @@ public class RedundancyPanel extends GSliderPanel del = ap.av.alignment.removeRedundancy(threshold,s); for (int j=0; j < del.size(); j++) { - if (ap.av.sel.contains((SequenceI)del.elementAt(j))) - ap.av.sel.removeElement((SequenceI)del.elementAt(j)); + if (sg.sequences.contains((SequenceI)del.elementAt(j))) + sg.deleteSequence((SequenceI)del.elementAt(j)); } } diff --git a/src/jalview/gui/RotatableCanvas.java b/src/jalview/gui/RotatableCanvas.java index bd03629..b4af354 100755 --- a/src/jalview/gui/RotatableCanvas.java +++ b/src/jalview/gui/RotatableCanvas.java @@ -294,9 +294,9 @@ public class RotatableCanvas extends JPanel implements MouseListener, g.setColor(sp.sequence.getColor()); - if (av != null) + if (av.getSelectionGroup() != null) { - if (av.getSelection().contains(((SequencePoint)points.elementAt(i)).sequence)) + if (av.getSelectionGroup().sequences.contains(((SequencePoint)points.elementAt(i)).sequence)) g.setColor(Color.gray); } if (z < 0) @@ -380,16 +380,20 @@ public class RotatableCanvas extends JPanel implements MouseListener, SequenceI found = findPoint(x,y); - if (found != null) { - if (av != null) { - - if (av.getSelection().contains(found)) { - av.getSelection().removeElement(found); - } else { - av.getSelection().addElement(found); - } + if (found != null) + { + if (av.getSelectionGroup() != null) + { + av.getSelectionGroup().addOrRemove(found); PaintRefresher.Refresh(this); } + else + { + av.setSelectionGroup(new SequenceGroup()); + av.getSelectionGroup().addOrRemove(found); + av.getSelectionGroup().setEndRes(av.alignment.getWidth()); + + } } repaint(); } @@ -455,9 +459,10 @@ public class RotatableCanvas extends JPanel implements MouseListener, if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) { if (av != null) { - if (!av.getSelection().contains(sp.sequence)) { + if (!av.getSelectionGroup().sequences.contains(sp.sequence)) + { changedSel = true; - av.getSelection().addElement(sp.sequence); + av.getSelectionGroup().addSequence(sp.sequence); } } } diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 8d6e331..dc80d1b 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -62,7 +62,7 @@ public class ScalePanel extends JPanel sg.setStartRes(res); sg.setEndRes(res); } - av.setRubberbandGroup(sg); + av.setSelectionGroup(sg); ap.RefreshPanels(); } @@ -77,7 +77,7 @@ public class ScalePanel extends JPanel if (! av.getColumnSelection().contains(res)) av.getColumnSelection().addElement(res); - SequenceGroup sg = av.getRubberbandGroup(); + SequenceGroup sg = av.getSelectionGroup(); if(res>sg.getStartRes()) sg.setEndRes(res); @@ -93,7 +93,7 @@ public class ScalePanel extends JPanel int x = evt.getX(); int res = x/av.getCharWidth() + av.getStartRes(); - SequenceGroup sg = av.getRubberbandGroup(); + SequenceGroup sg = av.getSelectionGroup(); if(sg!=null) { stretchingGroup = true; diff --git a/src/jalview/gui/Selection.java b/src/jalview/gui/Selection.java deleted file mode 100755 index 0ac9389..0000000 --- a/src/jalview/gui/Selection.java +++ /dev/null @@ -1,73 +0,0 @@ -package jalview.gui; - -import jalview.datamodel.*; - -import java.util.*; - -public class Selection -{ - - Vector selected = new Vector(); - AlignViewport av; - - public Selection(AlignViewport av) - { - this.av = av; - } - - public void addElement(SequenceI seq) { - selected.addElement(seq); - SequenceGroup sg = av.getRubberbandGroup(); - if(sg==null) - { - sg = new SequenceGroup(); - sg.setEndRes(av.alignment.getWidth()-1); - av.setRubberbandGroup(sg); - } - - sg.addSequence(seq); - - } - - public void clear() { - selected.removeAllElements(); - } - - public void removeElement(SequenceI seq) { - if (selected.contains(seq)) - selected.removeElement(seq); - else - System.err.println("WARNING: Tried to remove SequenceI NOT in Selection"); - - SequenceGroup sg = av.getRubberbandGroup(); - if (sg != null) - sg.deleteSequence(seq); - - - } - - public boolean contains(SequenceI seq) { - return selected.contains(seq); - } - - public SequenceI sequenceAt(int i) { - return (SequenceI)selected.elementAt(i); - } - - public int size() { - return selected.size(); - } - - public Vector asVector() { - return selected; - } - - public void selectAll(AlignmentI align) { - for (int i=0;isequence.getLength()) return; - stretchGroup = av.getRubberbandGroup(); + stretchGroup = av.getSelectionGroup(); if(stretchGroup == null) { stretchGroup = av.alignment.findGroup( sequence ); - av.setRubberbandGroup( stretchGroup ); + av.setSelectionGroup( stretchGroup ); } else if(!stretchGroup.sequences.contains(sequence) @@ -394,7 +413,7 @@ public class SeqPanel extends JPanel allGroups[i].getEndRes() >= res) { stretchGroup = allGroups[i]; - av.setRubberbandGroup(stretchGroup); + av.setSelectionGroup(stretchGroup); break; } } @@ -406,7 +425,7 @@ public class SeqPanel extends JPanel sg.setStartRes(res); sg.setEndRes(res); sg.addSequence( sequence ); - av.setRubberbandGroup( sg ); + av.setSelectionGroup( sg ); stretchGroup = sg; if(av.getConservationSelected()) @@ -450,6 +469,8 @@ public class SeqPanel extends JPanel public void doMouseReleasedDefineMode(MouseEvent evt) { + mouseDragging = false; + if(stretchGroup==null) return; @@ -496,6 +517,7 @@ public class SeqPanel extends JPanel changeEndRes = false; changeStartRes = false; stretchGroup = null; + ap.idPanel.repaint(); } @@ -533,14 +555,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) { // This routine ensures we don't skip any sequences, as the // selection is quite slow. @@ -561,11 +582,83 @@ public class SeqPanel extends JPanel } } oldSeq = y; + mouseDragging = true; + if(scrollThread!=null) + scrollThread.setEvent(evt); seqCanvas.paintFlag = true; repaint(); } + public void doMouseEnteredDefineMode(MouseEvent e) + { + if (scrollThread != null) + scrollThread.running = false; + } + + 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 + class ScrollThread extends Thread + { + MouseEvent evt; + boolean running = false; + public ScrollThread() + { + start(); + } + + public void setEvent(MouseEvent e) + { + evt = e; + } + + public void stopScrolling() + { + running = false; + } + + public void run() + { + running = true; + while (running) + { + if(evt!=null) + { + + if (mouseDragging && evt.getY() < 0 && av.getStartSeq() > 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); + } + + ap.repaint(); + try + { + Thread.sleep(75); + } + catch (Exception ex) + {} + } + } +} + + } diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index 5b5a392..442239d 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -131,7 +131,10 @@ public class SequenceRenderer implements RendererI if(av.getColourText()) { getBoxColour(av.getGlobalColourScheme(), seq, i); - graphics.setColor(resBoxColour.darker()); + if(av.getShowBoxes()) + graphics.setColor(resBoxColour.darker()); + else + graphics.setColor(resBoxColour); } } diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java index a5199ab..f013dc4 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -34,7 +34,7 @@ public class SplashScreen extends JPanel implements Runnable while( visible ) { - if( System.currentTimeMillis()/1000 - startTime > 8) + if( System.currentTimeMillis()/1000 - startTime > 5) visible = false; try{ diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index de84902..ed9677a 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -34,7 +34,6 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print //RubberbandRectangle rubberband; - Selection selected; Vector listeners; Hashtable nameHash = new Hashtable(); @@ -44,7 +43,6 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print { this.av = av; this.tree = tree; - selected = av.getSelection(); scrollPane = scroller; addMouseListener(this); tree.findHeight(tree.getTopNode()); @@ -54,23 +52,22 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print } public void TreeSelectionChanged(Sequence sequence) { - selected = av.getSelection(); + SequenceGroup selected = av.getSelectionGroup(); + if(selected == null) + { + selected = new SequenceGroup(); + av.setSelectionGroup(selected); + } + + selected.setEndRes(av.alignment.getWidth()); + selected.addOrRemove(sequence); - if (selected.contains(sequence)) - selected.removeElement(sequence); - else - selected.addElement(sequence); - setSelected(selected); PaintRefresher.Refresh(this); repaint(); } - public void setSelected(Selection selected) - { - this.selected = selected; - } public void setTree(NJTree tree) { this.tree = tree; @@ -136,7 +133,8 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print nameHash.put((SequenceI)node.element(),rect); - if (selected.contains((SequenceI)node.element())) { + SequenceGroup selected = av.getSelectionGroup(); + if (selected!=null && selected.sequences.contains((SequenceI)node.element())) { g.setColor(Color.gray); g.fillRect(xend + 10, ypos - charHeight + 3,charWidth,charHeight); @@ -203,7 +201,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print } - public void pickNodes(Rectangle pickBox, Selection sel) { + public void pickNodes(Rectangle pickBox) { int width = getWidth(); int height = getHeight(); @@ -216,10 +214,10 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print } float chunk = (float)(height-offy*2)/top.count; - pickNode(pickBox,sel,top,chunk,wscale,width,offx,offy); + pickNode(pickBox,top,chunk,wscale,width,offx,offy); } - public void pickNode(Rectangle pickBox, Selection sel, SequenceNode node, float chunk, float scale, int width,int offx, int offy) { + public void pickNode(Rectangle pickBox, SequenceNode node, float chunk, float scale, int width,int offx, int offy) { if (node == null) { return; } @@ -236,16 +234,14 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print if (pickBox.contains(new Point(xend,ypos))) { if (node.element() instanceof SequenceI) { SequenceI seq = (SequenceI)node.element(); - if (sel.contains(seq)) { - sel.removeElement(seq); - } else { - sel.addElement(seq); - } + SequenceGroup sg = av.getSelectionGroup(); + if(sg!=null) + sg.addOrRemove(seq); } } } else { - pickNode(pickBox,sel,(SequenceNode)node.left(), chunk,scale,width,offx,offy); - pickNode(pickBox,sel,(SequenceNode)node.right(),chunk,scale,width,offx,offy); + pickNode(pickBox,(SequenceNode)node.left(), chunk,scale,width,offx,offy); + pickNode(pickBox,(SequenceNode)node.right(),chunk,scale,width,offx,offy); } } @@ -323,6 +319,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print public void paintComponent(Graphics g) { + font = new Font("Verdana",Font.PLAIN,fontSize); g.setFont(font); @@ -411,7 +408,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print tree.groupNodes(tree.getTopNode(),fthreshold); setColor(tree.getTopNode(),Color.black); - av.sel.clear(); + av.setSelectionGroup(null); av.alignment.deleteAllGroups(); for (int i=0; i < tree.getGroups().size(); i++) @@ -428,7 +425,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print { SequenceNode sn = (SequenceNode) l.elementAt(j); if(sg==null) - sg = new SequenceGroup("TreeGroup", av.getGlobalColourScheme(), true, true,false,0,av.alignment.getWidth()); + sg = new SequenceGroup("TreeGroup", av.getGlobalColourScheme(), true, true,false,0,av.alignment.getWidth()); sg.addSequence( (Sequence) sn.element()); } diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index a409549..a96cf52 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -124,6 +124,7 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis protected void loadbutton_actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY")); + chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle("Load colour scheme"); chooser.setToolTipText("Load"); int value = chooser.showOpenDialog(this); @@ -156,6 +157,7 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis protected void savebutton_actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY")); + chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle("Save colour scheme"); chooser.setToolTipText("Save"); int value = chooser.showSaveDialog(this); -- 1.7.10.2