selection removed, now SelectionGroup does same job as id select and residue select
authoramwaterhouse <Andrew Waterhouse>
Tue, 15 Mar 2005 16:06:54 +0000 (16:06 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 15 Mar 2005 16:06:54 +0000 (16:06 +0000)
21 files changed:
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/Desktop.java
src/jalview/gui/Finder.java
src/jalview/gui/GroupEditor.java
src/jalview/gui/IdCanvas.java
src/jalview/gui/IdPanel.java
src/jalview/gui/PCAPanel.java
src/jalview/gui/PairwiseAlignPanel.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/RedundancyPanel.java
src/jalview/gui/RotatableCanvas.java
src/jalview/gui/ScalePanel.java
src/jalview/gui/Selection.java [deleted file]
src/jalview/gui/SeqCanvas.java
src/jalview/gui/SeqPanel.java
src/jalview/gui/SequenceRenderer.java
src/jalview/gui/SplashScreen.java
src/jalview/gui/TreeCanvas.java
src/jalview/gui/UserDefinedColours.java

index 4209455..c679559 100755 (executable)
@@ -64,6 +64,7 @@ public class AlignFrame extends GAlignFrame
   protected void saveAs_actionPerformed(ActionEvent e)\r
   {\r
     JFileChooser chooser = new JFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"));\r
+    chooser.setFileView(new JalviewFileView());\r
     chooser.setDialogTitle("Save Alignment to file - "+e.getActionCommand() +" format.");\r
     chooser.setToolTipText("Save");\r
     int value = chooser.showSaveDialog(this);\r
@@ -222,7 +223,7 @@ public class AlignFrame extends GAlignFrame
 \r
   public void moveSelectedSequences(boolean up)\r
   {\r
-    SequenceGroup sg = viewport.getRubberbandGroup();\r
+    SequenceGroup sg = viewport.getSelectionGroup();\r
     if (sg == null)\r
       return;\r
 \r
@@ -266,10 +267,10 @@ public class AlignFrame extends GAlignFrame
 \r
   protected void copy_actionPerformed(ActionEvent e)\r
   {\r
-   if(viewport.getRubberbandGroup()==null)\r
+   if(viewport.getSelectionGroup()==null)\r
      return;\r
 \r
-   SequenceGroup sg = viewport.getRubberbandGroup();\r
+   SequenceGroup sg = viewport.getSelectionGroup();\r
 \r
      Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();\r
      StringBuffer buffer= new StringBuffer();\r
@@ -352,10 +353,10 @@ public class AlignFrame extends GAlignFrame
   protected void delete_actionPerformed(ActionEvent e)\r
   {\r
     addHistoryItem("Delete");\r
-    if (viewport.getRubberbandGroup() == null)\r
+    if (viewport.getSelectionGroup() == null)\r
       return;\r
 \r
-     SequenceGroup sg = viewport.getRubberbandGroup();\r
+     SequenceGroup sg = viewport.getSelectionGroup();\r
      for (int i=0;i < sg.sequences.size(); i++)\r
      {\r
        SequenceI seq = sg.getSequenceAt(i);\r
@@ -368,7 +369,7 @@ public class AlignFrame extends GAlignFrame
           viewport.getAlignment().getSequences().setElementAt(seq, index);\r
      }\r
 \r
-     viewport.setRubberbandGroup(null);\r
+     viewport.setSelectionGroup(null);\r
      viewport.alignment.deleteGroup(sg);\r
      viewport.resetSeqLimits( alignPanel.seqPanel.seqCanvas.getHeight());\r
      if(viewport.getAlignment().getHeight()<1)\r
@@ -404,7 +405,7 @@ public class AlignFrame extends GAlignFrame
   protected void deleteGroups_actionPerformed(ActionEvent e)\r
   {\r
     viewport.alignment.deleteAllGroups();\r
-    viewport.getSelection().clear();\r
+    viewport.setSelectionGroup(null);\r
 \r
     alignPanel.RefreshPanels();\r
   }\r
@@ -413,29 +414,26 @@ public class AlignFrame extends GAlignFrame
 \r
   public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)\r
   {\r
-    Selection sel = viewport.getSelection();\r
+    SequenceGroup sg = new SequenceGroup();\r
     for (int i=0; i<viewport.getAlignment().getSequences().size(); i++)\r
-      sel.addElement( viewport.getAlignment().getSequenceAt(i));\r
+      sg.addSequence( viewport.getAlignment().getSequenceAt(i));\r
+    sg.setEndRes(viewport.alignment.getWidth());\r
+    viewport.setSelectionGroup(sg);\r
     PaintRefresher.Refresh(null);\r
   }\r
 \r
   public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setRubberbandGroup(null);\r
-    viewport.getSelection().clear();\r
+    viewport.setSelectionGroup(null);\r
     PaintRefresher.Refresh(null);\r
   }\r
 \r
   public void invertSequenceMenuItem_actionPerformed(ActionEvent e)\r
   {\r
-    Selection sel = viewport.getSelection();\r
+    SequenceGroup sg = viewport.getSelectionGroup();\r
     for (int i=0; i<viewport.getAlignment().getSequences().size(); i++)\r
-    {\r
-      if (sel.contains(viewport.getAlignment().getSequenceAt(i)))\r
-        sel.removeElement(viewport.getAlignment().getSequenceAt(i));\r
-      else\r
-        sel.addElement(viewport.getAlignment().getSequenceAt(i));\r
-    }\r
+      sg.addOrRemove (viewport.getAlignment().getSequenceAt(i));\r
+\r
     PaintRefresher.Refresh(null);\r
   }\r
 \r
@@ -870,7 +868,7 @@ if ( viewport.getConservationSelected() )
 \r
   public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)\r
   {\r
-    if(viewport.getSelection().size()<2)\r
+    if(viewport.getSelectionGroup().getSize()<2)\r
       JOptionPane.showInternalMessageDialog(this, "You must select at least 2 sequences.", "Invalid Selection", JOptionPane.WARNING_MESSAGE);\r
     else\r
     {\r
@@ -882,7 +880,8 @@ if ( viewport.getConservationSelected() )
 \r
   public void PCAMenuItem_actionPerformed(ActionEvent e)\r
   {\r
-    if( (viewport.getSelection().size()<4 && viewport.getSelection().size()>0)\r
+\r
+    if( (viewport.getSelectionGroup()!=null && viewport.getSelectionGroup().getSize()<4 && viewport.getSelectionGroup().getSize()>0)\r
        || viewport.getAlignment().getHeight()<4)\r
     {\r
       JOptionPane.showInternalMessageDialog(this, "Principal component analysis must take\n"\r
@@ -938,9 +937,9 @@ if ( viewport.getConservationSelected() )
     }\r
 \r
     TreePanel tp=null;\r
-   if (viewport.getSelection() != null && viewport.getSelection().size() > 3)\r
+   if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize() > 3)\r
    {\r
-     tp = new TreePanel(viewport, viewport.getSelection().asVector(),type, pwType,\r
+     tp = new TreePanel(viewport, viewport.getSelectionGroup().sequences,type, pwType,\r
                          0, viewport.alignment.getWidth());\r
    }\r
    else\r
index 7719f02..2f40de4 100755 (executable)
@@ -28,7 +28,7 @@ public class AlignViewport
   boolean conservationColourSelected = false;\r
   boolean abovePIDThreshold = false;\r
 \r
-  SequenceGroup rubberbandGroup = null;\r
+  SequenceGroup selectionGroup = new SequenceGroup();\r
 \r
   RendererI renderer = new SequenceRenderer(this);\r
 \r
@@ -40,7 +40,6 @@ public class AlignViewport
   Font            font = new Font("SansSerif",Font.PLAIN,10);\r
   AlignmentI      alignment;\r
 \r
-  Selection       sel    = new Selection(this);\r
   ColumnSelection colSel = new ColumnSelection();\r
 \r
   String visibleConsensus;\r
@@ -116,16 +115,17 @@ public class AlignViewport
     return consensus;\r
   }\r
 \r
-  public SequenceGroup getRubberbandGroup()\r
+  public SequenceGroup getSelectionGroup()\r
   {\r
-    return rubberbandGroup;\r
+    return selectionGroup;\r
   }\r
 \r
-  public void setRubberbandGroup(SequenceGroup sg)\r
+  public void setSelectionGroup(SequenceGroup sg)\r
   {\r
-    rubberbandGroup = sg;\r
+    selectionGroup = sg;\r
   }\r
 \r
+\r
  public boolean getConservationSelected()\r
  {\r
    return conservationColourSelected;\r
@@ -325,9 +325,7 @@ public class AlignViewport
     }\r
     return -1;\r
   }\r
-  public Selection getSelection() {\r
-    return sel;\r
-  }\r
+\r
   public ColumnSelection getColumnSelection() {\r
     return colSel;\r
   }\r
index fafcdcd..15f1a1f 100755 (executable)
@@ -55,8 +55,8 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
    });\r
 \r
 \r
-   hscroll.setFocusable(false);\r
-   vscroll.setFocusable(false);\r
+  // hscroll.setFocusable(false);\r
+  // vscroll.setFocusable(false);\r
    setFocusable(true);\r
 \r
    addKeyListener(new KeyAdapter()\r
@@ -66,8 +66,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
        switch(evt.getKeyCode())\r
        {\r
          case  27: // escape key\r
-           av.setRubberbandGroup(null);\r
-           av.getSelection().clear();\r
+           av.setSelectionGroup(null);\r
            RefreshPanels();\r
            break;\r
          case KeyEvent.VK_X:\r
@@ -180,33 +179,83 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
 \r
   public void RefreshPanels()\r
   {\r
-    requestFocus();\r
-    invalidate();\r
-    idPanelHolder.setPreferredSize( idPanel.idCanvas.getPreferredSize() );\r
-    idSpaceFillerPanel1.setPreferredSize(new Dimension(500, av.charHeight/2 +12));\r
-    scalePanelHolder.setPreferredSize(new Dimension(500, av.charHeight/2 +12));\r
-    if(av.getWrapAlignment())\r
-    {\r
-      int max = av.alignment.getWidth()/ (seqPanel.seqCanvas.getWidth()/av.charWidth)+1;\r
+    javax.swing.SwingUtilities.invokeLater(new Runnable()\r
+          {\r
+            public void run()\r
+            {\r
+\r
+              requestFocus();\r
+              invalidate();\r
+              idPanelHolder.setPreferredSize(idPanel.idCanvas.getPreferredSize());\r
+              hscrollFillerPanel.setPreferredSize(new Dimension(idPanel.idCanvas.\r
+                  getPreferredSize().width, 12));\r
+              idSpaceFillerPanel1.setPreferredSize(new Dimension(500,\r
+                  av.charHeight / 2 + 12));\r
+              scalePanelHolder.setPreferredSize(new Dimension(500,\r
+                  av.charHeight / 2 + 12));\r
+              if (av.getWrapAlignment())\r
+              {\r
+                int max = av.alignment.getWidth() /\r
+                    (seqPanel.seqCanvas.getWidth() / av.charWidth) + 1;\r
+\r
+                int h = (av.alignment.getHeight() + 2) * av.charHeight;\r
+                vextent = seqPanel.seqCanvas.getHeight() / h;\r
+                vscroll.setValues(0, vextent, 0, max);\r
+              }\r
+              else\r
+\r
+                setScrollValues(av.getStartRes(), av.getStartSeq());\r
+              av.getConsensus(true);\r
+              if (overviewPanel != null)\r
+                overviewPanel.updateOverviewImage();\r
+\r
+            }\r
+          });\r
+\r
+          validate();\r
+          repaint();\r
+  }\r
+  int hextent = 0;\r
+  int vextent = 0;\r
+\r
 \r
-      int h  = (av.alignment.getHeight() + 2)*av.charHeight;\r
-      vextent = seqPanel.seqCanvas.getHeight()/h;\r
-      vscroll.setValues(0,vextent,0,max);\r
+  // return value is true if the scroll is valid\r
+  public boolean scrollUp(boolean up)\r
+  {\r
+    if(up)\r
+    {\r
+      if(vscroll.getValue()<1)\r
+        return false;\r
+      vscroll.setValue(vscroll.getValue() - 1);\r
     }\r
     else\r
+    {\r
+     if(vextent+vscroll.getValue() >= av.getAlignment().getHeight())\r
+       return false;\r
+      vscroll.setValue(vscroll.getValue() + 1);\r
+    }\r
 \r
-    setScrollValues(av.getStartRes(), av.getStartSeq());\r
-    av.getConsensus(true);\r
-    if(overviewPanel!=null)\r
-      overviewPanel.updateOverviewImage();\r
+    return true;\r
+  }\r
 \r
-    validate();\r
-    repaint();\r
+  public boolean scrollRight(boolean right)\r
+  {\r
+    if(right)\r
+   {\r
+     if(hscroll.getValue()<1)\r
+       return false;\r
+     hscroll.setValue(hscroll.getValue() - 1);\r
+   }\r
+   else\r
+   {\r
+    if(hextent+hscroll.getValue() >= av.getAlignment().getWidth())\r
+      return false;\r
+     hscroll.setValue(hscroll.getValue() + 1);\r
+   }\r
 \r
-  }\r
+   return true;\r
+ }\r
 \r
-  int hextent = 0;\r
-  int vextent = 0;\r
 \r
   public void setScrollValues(int x, int y)\r
   {\r
@@ -324,7 +373,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
     Color currentTextColor=null;\r
     for(int i=startSeq; i<endSeq; i++)\r
     {\r
-      if (av.getSelection().contains(av.getAlignment().getSequenceAt(i)))\r
+      if (av.alignment.findGroup(av.getAlignment().getSequenceAt(i))==null)\r
       {\r
         currentColor = Color.gray;\r
         currentTextColor = Color.black;\r
@@ -431,6 +480,7 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene
 \r
       javax.swing.JFileChooser chooser = new javax.swing.JFileChooser(jalview.bin.Cache.getProperty(\r
           "LAST_DIRECTORY"));\r
+      chooser.setFileView(new jalview.io.JalviewFileView());\r
       chooser.setDialogTitle("Create JPG image from alignment");\r
       chooser.setToolTipText("Save");\r
 \r
index 25bfa52..efa283c 100755 (executable)
@@ -48,7 +48,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);\r
 \r
     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();\r
-    int width = 1200, height = 800;\r
+    int width = 900, height = 650;\r
     if(screenSize.getWidth()<width)\r
       width = screenSize.width;\r
     if(screenSize.getHeight()<height)\r
@@ -126,6 +126,7 @@ public class Desktop extends jalview.jbgui.GDesktop
  public void inputLocalFileMenuItem_actionPerformed(ActionEvent e)\r
  {\r
    JFileChooser chooser = new JFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"));\r
+   chooser.setFileView(new JalviewFileView());\r
    chooser.setDialogTitle("Open local file");\r
    chooser.setToolTipText("Open");\r
    int value = chooser.showOpenDialog(this);\r
index 2311a9f..8567451 100755 (executable)
@@ -99,8 +99,8 @@ public class Finder extends GFinder
       int res = Integer.parseInt(searchString);\r
       found = true;\r
 \r
-      if(av.getSelection().size()>0)\r
-        seq = (Sequence)(av.getSelection().sequenceAt(0));\r
+      if(av.getSelectionGroup().getSize()>0)\r
+        seq = (Sequence)(av.getSelectionGroup().getSequenceAt(0));\r
       else\r
         seq = (Sequence)av.getAlignment().getSequenceAt(0);\r
 \r
@@ -122,7 +122,7 @@ public class Finder extends GFinder
     int end = av.alignment.getHeight();\r
 \r
 \r
-    SequenceGroup rubberband = av.getRubberbandGroup();\r
+    SequenceGroup rubberband = av.getSelectionGroup();\r
     if(rubberband!=null)\r
       end = rubberband.getEndRes();\r
 \r
@@ -132,7 +132,7 @@ public class Finder extends GFinder
     {\r
       seq = (Sequence)av.getAlignment().getSequenceAt(seqIndex);\r
 \r
-      if(   av.getSelection().size()>0 && !av.getSelection().contains(seq)\r
+      if(   av.getSelectionGroup().getSize()>0 && !av.getSelectionGroup().sequences.contains(seq)\r
             || (rubberband!=null && !rubberband.sequences.contains(seq))  )\r
       {\r
         // if a selection has been made, only search within that selection\r
index 3ee186b..e3c49d6 100755 (executable)
@@ -198,10 +198,10 @@ public class GroupEditor extends GGroupEditor
       return;\r
 \r
     SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex);\r
-    Selection sel = av.getSelection();\r
-    for(int i=0; i<sel.size(); i++)\r
+\r
+    for(int i=0; i<av.getSelectionGroup().getSize(); i++)\r
     {\r
-      int index = unassignedVector.indexOf( sel.sequenceAt(i).getDisplayId() );\r
+      int index = unassignedVector.indexOf( av.getSelectionGroup().getSequenceAt(i).getDisplayId() );\r
       if(index!=-1)\r
       {\r
         sg.addSequence( (SequenceI) sequenceHash.get( unassignedVector.elementAt(index) ));\r
@@ -267,7 +267,7 @@ public class GroupEditor extends GGroupEditor
 \r
       unassignedVector.addElement(assignedVector.elementAt(indices[i]-i));\r
       SequenceI removeSequence = (SequenceI)sequenceHash.get( assignedVector.elementAt(indices[i]-i) );\r
-      av.getSelection().removeElement( removeSequence );\r
+      av.getSelectionGroup().deleteSequence( removeSequence );\r
       sg.deleteSequence( removeSequence );\r
       assignedVector.removeElementAt(indices[i]-i);\r
 \r
@@ -288,7 +288,7 @@ public class GroupEditor extends GGroupEditor
       String id = (String)enum.nextElement();\r
       unassignedVector.addElement( id );\r
       SequenceI removeSequence = (SequenceI)sequenceHash.get( id );\r
-      av.getSelection().removeElement( removeSequence );\r
+      av.getSelectionGroup().deleteSequence( removeSequence );\r
       sg.deleteSequence( removeSequence );\r
     }\r
 \r
index f68d967..9e64b1e 100755 (executable)
@@ -10,7 +10,6 @@ public class IdCanvas extends JPanel
 {\r
   protected AlignViewport av;\r
 \r
-  public boolean paintFlag   = false;\r
   protected boolean showScores  = true;\r
 \r
   protected int     maxIdLength = -1;\r
@@ -23,28 +22,29 @@ public class IdCanvas extends JPanel
     PaintRefresher.Register(this);\r
   }\r
 \r
-  public void drawIdString(Graphics gg,SequenceI ds,int i, int starty, int ypos) {\r
+  public void drawIdString(Graphics gg,SequenceI s,int i, int starty, int ypos) {\r
       int charHeight = av.getCharHeight();\r
 \r
-      if (av.getSelection().contains(ds)) {\r
+\r
+      if (av.getSelectionGroup()!=null && av.getSelectionGroup().sequences.contains(s)) {\r
          gg.setColor(Color.lightGray);\r
          gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight);\r
          gg.setColor(Color.white);\r
       } else {\r
-         gg.setColor(ds.getColor());\r
+         gg.setColor(s.getColor());\r
          gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight);\r
          gg.setColor(Color.black);\r
       }\r
 \r
-      String string = ds.getName() + "/" + ds.getStart() + "-" + ds.getEnd();\r
+      String string = s.getName() + "/" + s.getStart() + "-" + s.getEnd();\r
 \r
       gg.drawString(string,0,AlignmentUtil.getPixelHeight(starty,i,charHeight) + ypos + charHeight-   (charHeight/5));\r
 \r
   }\r
 \r
   public void paintComponent(Graphics gg) {\r
-    AlignmentI da         = av.getAlignment();\r
-    int        charHeight = av.getCharHeight();\r
+    AlignmentI al         = av.alignment;\r
+    int        charHeight = av.charHeight;\r
     gg.setFont(av.getFont());\r
 \r
     //Fill in the background\r
@@ -61,15 +61,15 @@ public class IdCanvas extends JPanel
     if (av.getWrapAlignment())\r
     {\r
           // Draw the rest of the panels\r
-          int chunkHeight =  (da.getHeight() + 2)*av.charHeight;\r
+          int chunkHeight =  (al.getHeight() + 2)*av.charHeight;\r
           int row = av.getStartRes() / av.chunkWidth ;\r
           for(int ypos=2*av.charHeight;\r
-              ypos <= getHeight() && row*av.chunkWidth<da.getWidth();\r
+              ypos <= getHeight() && row*av.chunkWidth<al.getWidth();\r
               ypos += chunkHeight, row++ )\r
           {\r
             for (int i = starty; i < av.alignment.getHeight(); i++)\r
             {\r
-              SequenceI s = da.getSequenceAt(i);\r
+              SequenceI s = al.getSequenceAt(i);\r
               drawIdString(gg, s, i, 0, ypos);\r
             }\r
           }\r
@@ -82,14 +82,16 @@ public class IdCanvas extends JPanel
       for (int i = starty; i < endy; i++)\r
       {\r
         // Selected sequence colours\r
-        if (av.getSelection().contains(da.getSequenceAt(i)))\r
+\r
+        if (av.getSelectionGroup()!= null && av.getSelectionGroup().sequences.contains(al.getSequenceAt(i)))\r
         {\r
+       //   if(av.alignment.findGroup(al.getSequenceAt(i)).getEndRes()==\r
           currentColor = Color.lightGray;\r
           currentTextColor = Color.black;\r
         }\r
         else\r
         {\r
-          currentColor = da.getSequenceAt(i).getColor();\r
+          currentColor = al.getSequenceAt(i).getColor();\r
           currentTextColor = Color.black;\r
         }\r
 \r
@@ -101,7 +103,7 @@ public class IdCanvas extends JPanel
                     charHeight);\r
 \r
         gg.setColor(currentTextColor);\r
-        String string = da.getSequenceAt(i).getDisplayId();\r
+        String string = al.getSequenceAt(i).getDisplayId();\r
         gg.drawString(string, 0,\r
                       AlignmentUtil.getPixelHeight(starty, i, charHeight) +\r
                       charHeight - (charHeight / 5));\r
index 32f3425..1889eb6 100755 (executable)
@@ -12,12 +12,12 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene
   protected IdCanvas       idCanvas;\r
   protected AlignViewport  av;\r
   protected AlignmentPanel alignPanel;\r
+  ScrollThread scrollThread = null;\r
 \r
-  protected int            offy;\r
-  public    int            width;\r
-  public    int            lastid;\r
-\r
-  SequenceGroup selectedSequenceGroup;\r
+  int            offy;\r
+  int            width;\r
+  int lastid = -1;\r
+  boolean mouseDragging = false;\r
 \r
   public IdPanel(AlignViewport av, AlignmentPanel parent)\r
   {\r
@@ -32,59 +32,25 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene
 \r
   public void mouseMoved(MouseEvent e) {}\r
 \r
-  public void selectSeqs(int start, int end) {\r
-     if (end < start)\r
-     {\r
-       int tmp = start;\r
-       start = end;\r
-       end   = tmp;\r
-     }\r
-\r
-     for (int i = start; i <= end; i++)\r
-     {\r
-       SequenceI pickedSeq = av.getAlignment().getSequenceAt(i);\r
-       if (av.getSelection().contains(pickedSeq))\r
-       {\r
-         av.getSelection().removeElement(pickedSeq);\r
-         selectedSequenceGroup.deleteSequence(pickedSeq);\r
-       }\r
-       else\r
-       {\r
-         av.getSelection().addElement(pickedSeq);\r
-         if(selectedSequenceGroup==null)\r
-         {\r
-           selectedSequenceGroup = new SequenceGroup();\r
-           av.setRubberbandGroup( selectedSequenceGroup );\r
-          // av.alignment.addGroup( selectedSequenceGroup );\r
-           selectedSequenceGroup.setStartRes(0);\r
-           selectedSequenceGroup.setEndRes( pickedSeq.getSequence().length());\r
-         }\r
-\r
-         selectedSequenceGroup.addSequence( pickedSeq );\r
-       }\r
-\r
-     }\r
-\r
-     alignPanel.seqPanel.seqCanvas.paintFlag=true;\r
-     alignPanel.repaint();\r
-     repaint();\r
-\r
-   }\r
 \r
   public void mouseDragged(MouseEvent e) {\r
+    mouseDragging = true;\r
+\r
     int y = e.getY();\r
     if(av.getWrapAlignment())\r
       y-=2*av.charHeight;\r
     int seq = av.getIndex(y);\r
 \r
+    if(seq<0)\r
+      return;\r
+\r
     if (seq < lastid)\r
       selectSeqs(lastid - 1, seq);\r
     else if (seq > lastid)\r
       selectSeqs(lastid + 1, seq);\r
 \r
     lastid = seq;\r
-\r
-    return;\r
+    alignPanel.repaint();\r
   }\r
 \r
   public void mouseClicked(MouseEvent e)\r
@@ -106,8 +72,28 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene
     }\r
 \r
   }\r
-  public void mouseEntered(MouseEvent e) { }\r
-  public void mouseExited (MouseEvent e) { }\r
+  public void mouseEntered(MouseEvent e)\r
+  {\r
+    if(scrollThread!=null)\r
+      scrollThread.running = false;\r
+  }\r
+\r
+  public void mouseExited (MouseEvent e)\r
+  {\r
+    if(av.getWrapAlignment())\r
+      return;\r
+\r
+    if(mouseDragging && e.getY()<0 && av.getStartSeq()>0)\r
+    {\r
+      scrollThread = new ScrollThread(true);\r
+    }\r
+\r
+    if(mouseDragging && e.getY()>=getHeight() && av.alignment.getHeight()>av.getEndSeq())\r
+    {\r
+      scrollThread = new ScrollThread(false);\r
+    }\r
+  }\r
+\r
 \r
   public void mousePressed(MouseEvent e) {\r
     if (e.getClickCount() == 2)\r
@@ -118,6 +104,8 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene
       y-=2*av.charHeight;\r
 \r
     int seq = av.getIndex(y);\r
+    if (seq == -1)\r
+      return;\r
 \r
     if (javax.swing.SwingUtilities.isRightMouseButton(e))\r
     {\r
@@ -127,34 +115,117 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene
       return;\r
     }\r
 \r
+    if(!e.isControlDown() && !e.isShiftDown() && av.alignment.findGroup( av.alignment.getSequenceAt(seq))!=null)\r
+    {\r
 \r
+      SequenceGroup selection = new SequenceGroup();\r
+      SequenceGroup sg = av.alignment.findGroup(av.alignment.getSequenceAt(seq));\r
+      selection.setStartRes(0);\r
+      selection.setEndRes(av.alignment.getWidth());\r
+      for (int i =0; i< sg.getSize(); i++)\r
+        selection.addSequence(sg.getSequenceAt(i));\r
 \r
-    if(av.getRubberbandGroup()!=null && (av.getRubberbandGroup().getSize() == av.getSelection().size()))\r
-          selectedSequenceGroup = av.getRubberbandGroup();\r
-\r
-    if (selectedSequenceGroup == null)\r
-    {\r
-      selectedSequenceGroup = new SequenceGroup();\r
-      av.setRubberbandGroup(selectedSequenceGroup);\r
-      av.getSelection().clear();\r
+      av.setSelectionGroup(selection);\r
+      return;\r
     }\r
 \r
-    selectedSequenceGroup.setStartRes(0);\r
-    selectedSequenceGroup.setEndRes(av.getAlignment().getWidth() - 1);\r
+    if(av.getSelectionGroup()==null || ( !e.isControlDown() && av.getSelectionGroup()!=null))\r
+      av.setSelectionGroup(new SequenceGroup());\r
 \r
-    if (seq != -1)\r
-      selectSeqs(seq, seq);\r
+    av.getSelectionGroup().setStartRes(0);\r
+    av.getSelectionGroup().setEndRes(av.alignment.getWidth());\r
 \r
-    lastid = seq;\r
+    if(e.isShiftDown() && lastid!=-1)\r
+      selectSeqs(lastid, seq);\r
+    else\r
+      selectSeq(seq);\r
 \r
+    alignPanel.seqPanel.seqCanvas.paintFlag=true;\r
+    alignPanel.repaint();\r
+    repaint();\r
+  }\r
 \r
-    return;\r
+  void selectSeq(int seq)\r
+  {\r
+    lastid = seq;\r
+    SequenceI pickedSeq = av.getAlignment().getSequenceAt(seq);\r
+    av.getSelectionGroup().addOrRemove(pickedSeq);\r
   }\r
 \r
+  void selectSeqs(int start, int end) {\r
+\r
+    lastid = start;\r
+    if (end < start)\r
+     {\r
+       int tmp = start;\r
+       start = end;\r
+       end   = tmp;\r
+       lastid = end;\r
+     }\r
+\r
+     for (int i = start; i <= end; i++)\r
+        av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i));\r
+\r
+   }\r
+\r
+\r
   public void mouseReleased(MouseEvent e)\r
   {\r
-    lastid = -1;\r
+    if(scrollThread!=null)\r
+      scrollThread.running = false;\r
+\r
+    mouseDragging = false;\r
     PaintRefresher.Refresh(this);\r
-    selectedSequenceGroup = null;\r
   }\r
+\r
+  // this class allows scrolling off the bottom of the visible alignment\r
+  class ScrollThread\r
+      extends Thread\r
+  {\r
+    boolean running = false;\r
+    boolean up = true;\r
+    public ScrollThread(boolean up)\r
+    {\r
+      this.up = up;\r
+      start();\r
+    }\r
+\r
+    public void stopScrolling()\r
+    {\r
+      running = false;\r
+    }\r
+\r
+    public void run()\r
+    {\r
+      running = true;\r
+      while (running)\r
+      {\r
+        if(alignPanel.scrollUp(up))\r
+        {\r
+          // scroll was ok, so add new sequence to selection\r
+          int seq = av.getStartSeq();\r
+          if(!up)\r
+            seq = av.getEndSeq();\r
+\r
+          if (seq < lastid)\r
+            selectSeqs(lastid - 1, seq);\r
+          else if (seq > lastid)\r
+            selectSeqs(lastid + 1, seq);\r
+\r
+          lastid = seq;\r
+        }\r
+        else\r
+          running = false;\r
+\r
+        alignPanel.repaint();\r
+        try\r
+        {\r
+          Thread.sleep(100);\r
+        }\r
+        catch (Exception ex)\r
+        {}\r
+      }\r
+    }\r
+}\r
+\r
 }\r
index 7fe3835..8e0bc37 100755 (executable)
@@ -23,11 +23,11 @@ public class PCAPanel extends GPCAPanel implements Runnable
   public PCAPanel(AlignViewport av, SequenceI[] s) {\r
 \r
     this.av = av;\r
-    if(av.getSelection().size()>3)\r
+    if(av.getSelectionGroup().getSize()>3)\r
     {\r
-      s = new Sequence[av.getSelection().size()];\r
+      s = new Sequence[av.getSelectionGroup().getSize()];\r
       for(int i=0; i<s.length; i++)\r
-        s[i] = av.getSelection().sequenceAt(i);\r
+        s[i] = av.getSelectionGroup().getSequenceAt(i);\r
     }\r
 \r
 \r
index b85cb94..0d3b0f3 100755 (executable)
@@ -19,7 +19,7 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel
       this.av = av;\r
       float scores[][] = new float[av.getAlignment().getHeight()][av.getAlignment().getHeight()];\r
       double totscore = 0;\r
-      int count = av.getSelection().size();\r
+      int count = av.getSelectionGroup().getSize();\r
 \r
       int acount = 0;\r
         for (int i = 1; i < count; i++)\r
@@ -27,7 +27,8 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel
           for (int j = 0; j < i; j++)\r
           {\r
             acount++;\r
-            AlignSeq as = new AlignSeq(av.getSelection().sequenceAt(i),av.getSelection().sequenceAt(j),"pep");\r
+            AlignSeq as = new AlignSeq(av.getSelectionGroup().getSequenceAt(i),\r
+                                       av.getSelectionGroup().getSequenceAt(j),"pep");\r
 \r
             as.calcScoreMatrix();\r
             as.traceAlignment();\r
index c09093b..abd5093 100755 (executable)
@@ -73,7 +73,7 @@ public class PopupMenu extends JPopupMenu
     catch(Exception e)\r
     {    e.printStackTrace();    }\r
 \r
-    SequenceGroup sg = ap.av.getRubberbandGroup();\r
+    SequenceGroup sg = ap.av.getSelectionGroup();\r
     if(sg!=null)\r
     {\r
       groupName.setText(sg.getName());\r
@@ -324,10 +324,6 @@ public class PopupMenu extends JPopupMenu
     if( superG !=null)\r
       superG.setSuperGroupProperties( sg );\r
 \r
-\r
-    //once group is defined, remove selection rubberband\r
-    ap.av.setRubberbandGroup(null);\r
-\r
     ap.seqPanel.seqCanvas.paintFlag=true;\r
     ap.seqPanel.repaint();\r
   }\r
@@ -490,7 +486,7 @@ public class PopupMenu extends JPopupMenu
 \r
   SequenceGroup getGroup()\r
   {\r
-    SequenceGroup sg = ap.av.getRubberbandGroup();\r
+    SequenceGroup sg = ap.av.getSelectionGroup();\r
 \r
     // this method won't add a new group if it already exists\r
     ap.av.alignment.addGroup(sg);\r
@@ -520,9 +516,9 @@ public class PopupMenu extends JPopupMenu
 \r
   void unGroupMenuItem_actionPerformed(ActionEvent e)\r
   {\r
-     SequenceGroup sg = ap.av.getRubberbandGroup();\r
+     SequenceGroup sg = ap.av.getSelectionGroup();\r
      ap.av.alignment.deleteGroup(sg);\r
-     ap.av.setRubberbandGroup(null);\r
+     ap.av.setSelectionGroup(null);\r
      ap.RefreshPanels();\r
   }\r
 \r
index 6cb2c22..3eec476 100755 (executable)
@@ -48,13 +48,14 @@ public class RedundancyPanel extends GSliderPanel
 \r
         undoButton.setEnabled(true);\r
 \r
-       if (ap.av.sel != null && ap.av.sel.size() > 1)\r
+        SequenceGroup sg = ap.av.getSelectionGroup();\r
+       if (sg != null && sg.getSize() > 1)\r
        {\r
 \r
-         del = ap.av.alignment.removeRedundancy(threshold, ap.av.sel.asVector());\r
+         del = ap.av.alignment.removeRedundancy(threshold, sg.sequences);\r
          for (int i = 0; i < del.size(); i++)\r
-           if (ap.av.sel.contains( (SequenceI) del.elementAt(i)))\r
-             ap.av.sel.removeElement( (SequenceI) del.elementAt(i));\r
+           if (sg.sequences.contains( (SequenceI) del.elementAt(i)))\r
+             sg.deleteSequence( (SequenceI) del.elementAt(i));\r
 \r
          }\r
          else\r
@@ -69,8 +70,8 @@ public class RedundancyPanel extends GSliderPanel
             del = ap.av.alignment.removeRedundancy(threshold,s);\r
            for (int j=0; j < del.size(); j++)\r
            {\r
-               if (ap.av.sel.contains((SequenceI)del.elementAt(j)))\r
-               ap.av.sel.removeElement((SequenceI)del.elementAt(j));\r
+               if (sg.sequences.contains((SequenceI)del.elementAt(j)))\r
+               sg.deleteSequence((SequenceI)del.elementAt(j));\r
 \r
            }\r
          }\r
index bd03629..b4af354 100755 (executable)
@@ -294,9 +294,9 @@ public class RotatableCanvas extends JPanel implements MouseListener,
           g.setColor(sp.sequence.getColor());\r
 \r
 \r
-      if (av != null)\r
+      if (av.getSelectionGroup() != null)\r
       {\r
-        if (av.getSelection().contains(((SequencePoint)points.elementAt(i)).sequence))\r
+        if (av.getSelectionGroup().sequences.contains(((SequencePoint)points.elementAt(i)).sequence))\r
           g.setColor(Color.gray);\r
       }\r
       if (z < 0)\r
@@ -380,16 +380,20 @@ public class RotatableCanvas extends JPanel implements MouseListener,
 \r
     SequenceI found = findPoint(x,y);\r
 \r
-    if (found != null) {\r
-      if (av != null) {\r
-\r
-        if (av.getSelection().contains(found)) {\r
-          av.getSelection().removeElement(found);\r
-        } else {\r
-          av.getSelection().addElement(found);\r
-        }\r
+    if (found != null)\r
+    {\r
+      if (av.getSelectionGroup() != null)\r
+      {\r
+        av.getSelectionGroup().addOrRemove(found);\r
         PaintRefresher.Refresh(this);\r
       }\r
+      else\r
+      {\r
+          av.setSelectionGroup(new SequenceGroup());\r
+          av.getSelectionGroup().addOrRemove(found);\r
+          av.getSelectionGroup().setEndRes(av.alignment.getWidth());\r
+\r
+      }\r
     }\r
     repaint();\r
   }\r
@@ -455,9 +459,10 @@ public class RotatableCanvas extends JPanel implements MouseListener,
 \r
       if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) {\r
         if (av != null) {\r
-          if (!av.getSelection().contains(sp.sequence)) {\r
+          if (!av.getSelectionGroup().sequences.contains(sp.sequence))\r
+          {\r
             changedSel = true;\r
-            av.getSelection().addElement(sp.sequence);\r
+            av.getSelectionGroup().addSequence(sp.sequence);\r
           }\r
         }\r
       }\r
index 8d6e331..dc80d1b 100755 (executable)
@@ -62,7 +62,7 @@ public class ScalePanel extends JPanel
       sg.setStartRes(res);\r
       sg.setEndRes(res);\r
     }\r
-    av.setRubberbandGroup(sg);\r
+    av.setSelectionGroup(sg);\r
     ap.RefreshPanels();\r
   }\r
 \r
@@ -77,7 +77,7 @@ public class ScalePanel extends JPanel
    if (! av.getColumnSelection().contains(res))\r
      av.getColumnSelection().addElement(res);\r
 \r
-   SequenceGroup sg = av.getRubberbandGroup();\r
+   SequenceGroup sg = av.getSelectionGroup();\r
 \r
    if(res>sg.getStartRes())\r
      sg.setEndRes(res);\r
@@ -93,7 +93,7 @@ public class ScalePanel extends JPanel
     int x = evt.getX();\r
     int res = x/av.getCharWidth() + av.getStartRes();\r
 \r
-    SequenceGroup sg = av.getRubberbandGroup();\r
+    SequenceGroup sg = av.getSelectionGroup();\r
     if(sg!=null)\r
     {\r
       stretchingGroup = true;\r
diff --git a/src/jalview/gui/Selection.java b/src/jalview/gui/Selection.java
deleted file mode 100755 (executable)
index 0ac9389..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-package jalview.gui;\r
-\r
-import jalview.datamodel.*;\r
-\r
-import java.util.*;\r
-\r
-public class Selection\r
-{\r
-\r
-  Vector selected = new Vector();\r
-  AlignViewport av;\r
-\r
-  public Selection(AlignViewport av)\r
-  {\r
-    this.av = av;\r
-  }\r
-\r
-  public void addElement(SequenceI seq) {\r
-    selected.addElement(seq);\r
-    SequenceGroup sg = av.getRubberbandGroup();\r
-    if(sg==null)\r
-    {\r
-      sg = new SequenceGroup();\r
-      sg.setEndRes(av.alignment.getWidth()-1);\r
-      av.setRubberbandGroup(sg);\r
-    }\r
-\r
-    sg.addSequence(seq);\r
-\r
-  }\r
-\r
-  public void clear() {\r
-    selected.removeAllElements();\r
-  }\r
-\r
-  public void removeElement(SequenceI seq) {\r
-    if (selected.contains(seq))\r
-      selected.removeElement(seq);\r
-    else\r
-      System.err.println("WARNING: Tried to remove SequenceI NOT in Selection");\r
-\r
-    SequenceGroup sg = av.getRubberbandGroup();\r
-    if (sg != null)\r
-      sg.deleteSequence(seq);\r
-\r
-\r
-  }\r
-\r
-  public boolean contains(SequenceI seq) {\r
-    return selected.contains(seq);\r
-  }\r
-\r
-  public SequenceI sequenceAt(int i) {\r
-    return (SequenceI)selected.elementAt(i);\r
-  }\r
-\r
-  public int size() {\r
-    return selected.size();\r
-  }\r
-\r
-  public Vector asVector() {\r
-    return selected;\r
-  }\r
-\r
-  public void selectAll(AlignmentI align) {\r
-    for (int i=0;i<align.getSequences().size();i++) {\r
-      SequenceI seq = align.getSequenceAt(i);\r
-      if (!contains(seq)) {\r
-        addElement(seq);\r
-      }\r
-    }\r
-  }\r
-}\r
index 507b7b0..96dea90 100755 (executable)
@@ -223,7 +223,7 @@ public class SeqCanvas extends JPanel
      else\r
        inGroup = false;\r
 \r
-     group = av.getRubberbandGroup();\r
+     group = av.getSelectionGroup();\r
      if( group != null && group.sequences.contains(nextSeq) )\r
      {\r
          g.setColor(Color.RED.brighter());\r
index 35c5aef..255be5d 100755 (executable)
@@ -27,6 +27,10 @@ public class SeqPanel extends JPanel
   // if character is inserted or deleted, we will need to recalculate the conservation\r
   int seqEditOccurred = -1;\r
 \r
+  ScrollThread scrollThread = null;\r
+  boolean mouseDragging = false;\r
+\r
+\r
   public SeqPanel(AlignViewport avp, AlignmentPanel p) {\r
     this.av         = avp;\r
 \r
@@ -75,6 +79,21 @@ public class SeqPanel extends JPanel
         else\r
           doMousePressedDefineMode(evt);\r
       }\r
+      public void mouseExited(MouseEvent evt)\r
+      {\r
+        if (av.getWrapAlignment() || evt.isShiftDown() || evt.isAltDown() ||\r
+                  evt.isControlDown())\r
+                return;\r
+              doMouseExitedDefineMode(evt);\r
+\r
+      }\r
+      public void mouseEntered(MouseEvent evt)\r
+      {\r
+        if (av.getWrapAlignment() || evt.isShiftDown() || evt.isAltDown() ||\r
+            evt.isControlDown())\r
+          return;\r
+        doMouseEnteredDefineMode(evt);\r
+      }\r
 \r
     });\r
     repaint();\r
@@ -372,12 +391,12 @@ public class SeqPanel extends JPanel
     if(res>sequence.getLength())\r
       return;\r
 \r
-    stretchGroup = av.getRubberbandGroup();\r
+    stretchGroup = av.getSelectionGroup();\r
 \r
     if(stretchGroup == null)\r
      {\r
        stretchGroup = av.alignment.findGroup( sequence );\r
-       av.setRubberbandGroup( stretchGroup );\r
+       av.setSelectionGroup( stretchGroup );\r
      }\r
 \r
     else if(!stretchGroup.sequences.contains(sequence)\r
@@ -394,7 +413,7 @@ public class SeqPanel extends JPanel
                allGroups[i].getEndRes() >= res)\r
            {\r
              stretchGroup = allGroups[i];\r
-             av.setRubberbandGroup(stretchGroup);\r
+             av.setSelectionGroup(stretchGroup);\r
              break;\r
            }\r
      }\r
@@ -406,7 +425,7 @@ public class SeqPanel extends JPanel
       sg.setStartRes(res);\r
       sg.setEndRes(res);\r
       sg.addSequence( sequence );\r
-      av.setRubberbandGroup( sg );\r
+      av.setSelectionGroup( sg );\r
       stretchGroup = sg;\r
 \r
       if(av.getConservationSelected())\r
@@ -450,6 +469,8 @@ public class SeqPanel extends JPanel
 \r
   public void doMouseReleasedDefineMode(MouseEvent evt)\r
   {\r
+    mouseDragging = false;\r
+\r
     if(stretchGroup==null)\r
       return;\r
 \r
@@ -496,6 +517,7 @@ public class SeqPanel extends JPanel
     changeEndRes = false;\r
     changeStartRes = false;\r
     stretchGroup = null;\r
+    ap.idPanel.repaint();\r
   }\r
 \r
 \r
@@ -533,14 +555,13 @@ public class SeqPanel extends JPanel
         stretchGroup.setStartRes( res );\r
     }\r
 \r
-\r
     int dragDirection = 0;\r
     if (y > oldSeq)\r
       dragDirection = 1;\r
     else if (y < oldSeq)\r
       dragDirection = -1;\r
 \r
-    while (y != oldSeq)\r
+    while (y != oldSeq && oldSeq>0)\r
     {\r
       // This routine ensures we don't skip any sequences, as the\r
       // selection is quite slow.\r
@@ -561,11 +582,83 @@ public class SeqPanel extends JPanel
       }\r
     }\r
     oldSeq = y;\r
+    mouseDragging = true;\r
+    if(scrollThread!=null)\r
+      scrollThread.setEvent(evt);\r
 \r
     seqCanvas.paintFlag = true;\r
     repaint();\r
   }\r
 \r
+  public void doMouseEnteredDefineMode(MouseEvent e)\r
+  {\r
+    if (scrollThread != null)\r
+      scrollThread.running = false;\r
+  }\r
+\r
+  public void doMouseExitedDefineMode(MouseEvent e)\r
+  {\r
+    if (av.getWrapAlignment())\r
+      return;\r
+\r
+    if(mouseDragging)\r
+      scrollThread = new ScrollThread();\r
+\r
+  }\r
+  // this class allows scrolling off the bottom of the visible alignment\r
+  class ScrollThread extends Thread\r
+  {\r
+    MouseEvent evt;\r
+    boolean running = false;\r
+    public ScrollThread()\r
+    {\r
+      start();\r
+    }\r
+\r
+    public void setEvent(MouseEvent e)\r
+    {\r
+      evt = e;\r
+    }\r
+\r
+    public void stopScrolling()\r
+    {\r
+      running = false;\r
+    }\r
+\r
+    public void run()\r
+    {\r
+      running = true;\r
+      while (running)\r
+      {\r
+        if(evt!=null)\r
+        {\r
+\r
+          if (mouseDragging && evt.getY() < 0 && av.getStartSeq() > 0)\r
+            running = ap.scrollUp(true);\r
+\r
+          if (mouseDragging && evt.getY() >= getHeight() &&\r
+              av.alignment.getHeight() > av.getEndSeq())\r
+            running = ap.scrollUp(false);\r
+\r
+          if (mouseDragging && evt.getX() < 0)\r
+            running = ap.scrollRight(true);\r
+\r
+          else if (mouseDragging && evt.getX() >= getWidth())\r
+            running = ap.scrollRight(false);\r
+        }\r
+\r
+        ap.repaint();\r
+        try\r
+        {\r
+          Thread.sleep(75);\r
+        }\r
+        catch (Exception ex)\r
+        {}\r
+      }\r
+    }\r
+}\r
+\r
+\r
 \r
 }\r
 \r
index 5b5a392..442239d 100755 (executable)
@@ -131,7 +131,10 @@ public class SequenceRenderer implements RendererI
           if(av.getColourText())\r
            {\r
              getBoxColour(av.getGlobalColourScheme(), seq, i);\r
-             graphics.setColor(resBoxColour.darker());\r
+             if(av.getShowBoxes())\r
+              graphics.setColor(resBoxColour.darker());\r
+            else\r
+              graphics.setColor(resBoxColour);\r
            }\r
         }\r
 \r
index a5199ab..f013dc4 100755 (executable)
@@ -34,7 +34,7 @@ public class SplashScreen extends JPanel implements Runnable
 \r
     while( visible )\r
     {\r
-      if( System.currentTimeMillis()/1000 - startTime > 8)\r
+      if( System.currentTimeMillis()/1000 - startTime > 5)\r
         visible = false;\r
 \r
       try{\r
index de84902..ed9677a 100755 (executable)
@@ -34,7 +34,6 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
 \r
   //RubberbandRectangle rubberband;\r
 \r
-  Selection selected;\r
   Vector    listeners;\r
 \r
   Hashtable nameHash = new Hashtable();\r
@@ -44,7 +43,6 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
   {\r
     this.av = av;\r
     this.tree     = tree;\r
-    selected = av.getSelection();\r
     scrollPane = scroller;\r
     addMouseListener(this);\r
     tree.findHeight(tree.getTopNode());\r
@@ -54,23 +52,22 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
   }\r
   public void TreeSelectionChanged(Sequence sequence)\r
  {\r
-    selected = av.getSelection();\r
+    SequenceGroup selected = av.getSelectionGroup();\r
+    if(selected == null)\r
+    {\r
+      selected = new SequenceGroup();\r
+      av.setSelectionGroup(selected);\r
+    }\r
+\r
+    selected.setEndRes(av.alignment.getWidth());\r
+    selected.addOrRemove(sequence);\r
 \r
-    if (selected.contains(sequence))\r
-        selected.removeElement(sequence);\r
-    else\r
-        selected.addElement(sequence);\r
 \r
-    setSelected(selected);\r
     PaintRefresher.Refresh(this);\r
     repaint();\r
  }\r
 \r
 \r
-  public void setSelected(Selection selected)\r
-  {\r
-        this.selected = selected;\r
-  }\r
 \r
   public void setTree(NJTree tree) {\r
     this.tree = tree;\r
@@ -136,7 +133,8 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
 \r
       nameHash.put((SequenceI)node.element(),rect);\r
 \r
-      if (selected.contains((SequenceI)node.element())) {\r
+      SequenceGroup selected = av.getSelectionGroup();\r
+      if (selected!=null && selected.sequences.contains((SequenceI)node.element())) {\r
         g.setColor(Color.gray);\r
 \r
         g.fillRect(xend + 10, ypos - charHeight + 3,charWidth,charHeight);\r
@@ -203,7 +201,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
 \r
   }\r
 \r
-  public void pickNodes(Rectangle pickBox, Selection sel) {\r
+  public void pickNodes(Rectangle pickBox) {\r
     int width  = getWidth();\r
     int height = getHeight();\r
 \r
@@ -216,10 +214,10 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
     }\r
     float chunk = (float)(height-offy*2)/top.count;\r
 \r
-    pickNode(pickBox,sel,top,chunk,wscale,width,offx,offy);\r
+    pickNode(pickBox,top,chunk,wscale,width,offx,offy);\r
   }\r
 \r
-  public void pickNode(Rectangle pickBox, Selection sel, SequenceNode node, float chunk, float scale, int width,int offx, int offy) {\r
+  public void pickNode(Rectangle pickBox, SequenceNode node, float chunk, float scale, int width,int offx, int offy) {\r
     if (node == null) {\r
       return;\r
     }\r
@@ -236,16 +234,14 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
       if (pickBox.contains(new Point(xend,ypos))) {\r
         if (node.element() instanceof SequenceI) {\r
           SequenceI seq = (SequenceI)node.element();\r
-          if (sel.contains(seq)) {\r
-            sel.removeElement(seq);\r
-          } else {\r
-            sel.addElement(seq);\r
-          }\r
+          SequenceGroup sg = av.getSelectionGroup();\r
+          if(sg!=null)\r
+            sg.addOrRemove(seq);\r
         }\r
       }\r
     } else {\r
-      pickNode(pickBox,sel,(SequenceNode)node.left(), chunk,scale,width,offx,offy);\r
-      pickNode(pickBox,sel,(SequenceNode)node.right(),chunk,scale,width,offx,offy);\r
+      pickNode(pickBox,(SequenceNode)node.left(), chunk,scale,width,offx,offy);\r
+      pickNode(pickBox,(SequenceNode)node.right(),chunk,scale,width,offx,offy);\r
     }\r
   }\r
 \r
@@ -323,6 +319,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
 \r
   public void paintComponent(Graphics g)\r
   {\r
+\r
     font = new Font("Verdana",Font.PLAIN,fontSize);\r
     g.setFont(font);\r
 \r
@@ -411,7 +408,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
               tree.groupNodes(tree.getTopNode(),fthreshold);\r
               setColor(tree.getTopNode(),Color.black);\r
 \r
-              av.sel.clear();\r
+              av.setSelectionGroup(null);\r
               av.alignment.deleteAllGroups();\r
 \r
               for (int i=0; i < tree.getGroups().size(); i++)\r
@@ -428,7 +425,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
                   {\r
                     SequenceNode sn = (SequenceNode) l.elementAt(j);\r
                     if(sg==null)\r
-                       sg  = new SequenceGroup("TreeGroup", av.getGlobalColourScheme(), true, true,false,0,av.alignment.getWidth());\r
+                       sg = new SequenceGroup("TreeGroup", av.getGlobalColourScheme(), true, true,false,0,av.alignment.getWidth());\r
 \r
                     sg.addSequence( (Sequence) sn.element());\r
                   }\r
index a409549..a96cf52 100755 (executable)
@@ -124,6 +124,7 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis
   protected void loadbutton_actionPerformed(ActionEvent e)\r
   {\r
     JFileChooser chooser = new JFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"));\r
+    chooser.setFileView(new jalview.io.JalviewFileView());\r
     chooser.setDialogTitle("Load colour scheme");\r
     chooser.setToolTipText("Load");\r
     int value = chooser.showOpenDialog(this);\r
@@ -156,6 +157,7 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis
   protected void savebutton_actionPerformed(ActionEvent e)\r
   {\r
     JFileChooser chooser = new JFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"));\r
+    chooser.setFileView(new jalview.io.JalviewFileView());\r
     chooser.setDialogTitle("Save colour scheme");\r
     chooser.setToolTipText("Save");\r
     int value = chooser.showSaveDialog(this);\r