JAL-1421 typed map / lists, explicit imports, method refactoring
[jalview.git] / src / jalview / gui / SeqPanel.java
index d379764..1f1dd2f 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.gui;
 
 import jalview.api.AlignViewportI;
+import jalview.bin.Cache;
 import jalview.commands.EditCommand;
 import jalview.commands.EditCommand.Action;
 import jalview.commands.EditCommand.Edit;
@@ -54,11 +55,12 @@ import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
 import java.awt.event.MouseWheelEvent;
 import java.awt.event.MouseWheelListener;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Vector;
 
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
 import javax.swing.ToolTipManager;
 
 /**
@@ -509,6 +511,7 @@ public class SeqPanel extends JPanel implements MouseListener,
 
   void insertNucAtCursor(boolean group, String nuc)
   {
+    // TODO not called - delete?
     groupEditing = group;
     startseq = seqCanvas.cursorY;
     lastres = seqCanvas.cursorX;
@@ -599,7 +602,7 @@ public class SeqPanel extends JPanel implements MouseListener,
   {
     lastMousePress = evt.getPoint();
 
-    if (javax.swing.SwingUtilities.isMiddleMouseButton(evt))
+    if (SwingUtilities.isMiddleMouseButton(evt))
     {
       mouseWheelPressed = true;
       return;
@@ -680,7 +683,7 @@ public class SeqPanel extends JPanel implements MouseListener,
        * 
        * @see AlignmentPanel#adjustmentValueChanged
        */
-      ap.setFollowingComplementScroll(true);
+      ap.setDontScrollComplement(true);
       if (ap.scrollToPosition(results, false))
       {
         seqCanvas.revalidate();
@@ -801,6 +804,7 @@ public class SeqPanel extends JPanel implements MouseListener,
    * 
    * @see javax.swing.JComponent#getToolTipLocation(java.awt.event.MouseEvent)
    */
+  @Override
   public Point getToolTipLocation(MouseEvent event)
   {
     int x = event.getX(), w = getWidth();
@@ -904,7 +908,7 @@ public class SeqPanel extends JPanel implements MouseListener,
          * Convert position in sequence (base 1) to sequence character array
          * index (base 0)
          */
-        int start = m.getStart() - 1;
+        int start = m.getStart() - m.getSequence().getStart();
         setStatusMessage(seq, start, sequenceIndex);
         return;
       }
@@ -1170,8 +1174,7 @@ public class SeqPanel extends JPanel implements MouseListener,
           {
             for (int j = 0; j < startres - lastres; j++)
             {
-              if (!jalview.util.Comparison.isGap(groupSeqs[g]
-                      .getCharAt(fixedRight - j)))
+              if (!Comparison.isGap(groupSeqs[g].getCharAt(fixedRight - j)))
               {
                 blank = false;
                 break;
@@ -1233,7 +1236,7 @@ public class SeqPanel extends JPanel implements MouseListener,
               continue;
             }
 
-            if (!jalview.util.Comparison.isGap(groupSeqs[g].getCharAt(j)))
+            if (!Comparison.isGap(groupSeqs[g].getCharAt(j)))
             {
               // Not a gap, block edit not valid
               endEditing();
@@ -1365,7 +1368,7 @@ public class SeqPanel extends JPanel implements MouseListener,
 
       for (blankColumn = fixedColumn; blankColumn > j; blankColumn--)
       {
-        if (jalview.util.Comparison.isGap(seq[s].getCharAt(blankColumn)))
+        if (Comparison.isGap(seq[s].getCharAt(blankColumn)))
         {
           // Theres a space, so break and insert the gap
           break;
@@ -1596,24 +1599,24 @@ public class SeqPanel extends JPanel implements MouseListener,
 
     }
 
-    if (javax.swing.SwingUtilities.isRightMouseButton(evt))
+    if (SwingUtilities.isRightMouseButton(evt))
     {
       List<SequenceFeature> allFeatures = ap.getFeatureRenderer()
               .findFeaturesAtRes(sequence.getDatasetSequence(),
                       sequence.findPosition(res));
-      Vector links = new Vector();
+      List<String> links = new ArrayList<String>();
       for (SequenceFeature sf : allFeatures)
       {
         if (sf.links != null)
         {
-          for (int j = 0; j < sf.links.size(); j++)
+          for (String link : sf.links)
           {
-            links.addElement(sf.links.elementAt(j));
+            links.add(link);
           }
         }
       }
 
-      jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(ap, null, links);
+      PopupMenu pop = new PopupMenu(ap, null, links);
       pop.show(this, evt.getX(), evt.getY());
       return;
     }
@@ -1954,7 +1957,7 @@ public class SeqPanel extends JPanel implements MouseListener,
     {
       if (av.getAlignment() == null)
       {
-        jalview.bin.Cache.log.warn("alignviewport av SeqSetId="
+        Cache.log.warn("alignviewport av SeqSetId="
                 + av.getSequenceSetId() + " ViewId=" + av.getViewId()
                 + " 's alignment is NULL! returning immediately.");
         return;
@@ -1962,7 +1965,7 @@ public class SeqPanel extends JPanel implements MouseListener,
       sgroup = seqsel.intersect(av.getAlignment(),
               (av.hasHiddenRows()) ? av.getHiddenRepSequences() : null);
       if ((sgroup == null || sgroup.getSize() == 0)
-              || (colsel == null || colsel.size() == 0))
+              || (colsel == null || colsel.isEmpty()))
       {
         // don't copy columns if the region didn't intersect.
         copycolsel = false;
@@ -1983,7 +1986,7 @@ public class SeqPanel extends JPanel implements MouseListener,
     {
       // the current selection is unset or from a previous message
       // so import the new colsel.
-      if (colsel == null || colsel.size() == 0)
+      if (colsel == null || colsel.isEmpty())
       {
         if (av.getColumnSelection() != null)
         {