formatting
[jalview.git] / src / jalview / appletgui / SeqPanel.java
index 744a941..a5dfb83 100644 (file)
@@ -154,7 +154,8 @@ public class SeqPanel extends Panel implements MouseMotionListener,
   {
     seqCanvas.cursorX += dx;
     seqCanvas.cursorY += dy;
-    if (av.hasHiddenColumns() && !av.getColumnSelection().isVisible(seqCanvas.cursorX))
+    if (av.hasHiddenColumns()
+            && !av.getColumnSelection().isVisible(seqCanvas.cursorX))
     {
       int original = seqCanvas.cursorX - dx;
       int maxWidth = av.getAlignment().getWidth();
@@ -458,7 +459,8 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     SequenceI sequence = av.getAlignment().getSequenceAt(findSeq(evt));
     if (evt.getClickCount() > 1)
     {
-      if (av.getSelectionGroup()!=null && av.getSelectionGroup().getSize() == 1
+      if (av.getSelectionGroup() != null
+              && av.getSelectionGroup().getSize() == 1
               && av.getSelectionGroup().getEndRes()
                       - av.getSelectionGroup().getStartRes() < 2)
       {
@@ -581,8 +583,8 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
       y -= hgap;
 
-      seq = Math.min((y % cHeight) / av.getCharHeight(),
-              av.getAlignment().getHeight() - 1);
+      seq = Math.min((y % cHeight) / av.getCharHeight(), av.getAlignment()
+              .getHeight() - 1);
       if (seq < 0)
       {
         seq = -1;
@@ -590,8 +592,8 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     }
     else
     {
-      seq = Math.min((y / av.getCharHeight()) + av.getStartSeq(),
-              av.getAlignment().getHeight() - 1);
+      seq = Math.min((y / av.getCharHeight()) + av.getStartSeq(), av
+              .getAlignment().getHeight() - 1);
       if (seq < 0)
       {
         seq = -1;
@@ -1036,7 +1038,8 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
     if (groupEditing)
     {
-      SequenceI[] groupSeqs = sg.getSequences(av.getHiddenRepSequences()).toArray(new SequenceI[0]);
+      SequenceI[] groupSeqs = sg.getSequences(av.getHiddenRepSequences())
+              .toArray(new SequenceI[0]);
 
       // drag to right
       if (insertGap)
@@ -1058,12 +1061,12 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         {
           blank = true;
 
-          for (SequenceI gs:groupSeqs)
+          for (SequenceI gs : groupSeqs)
           {
             for (int j = 0; j < startres - lastres; j++)
             {
-              if (!jalview.util.Comparison.isGap(gs
-                      .getCharAt(fixedRight - j)))
+              if (!jalview.util.Comparison.isGap(gs.getCharAt(fixedRight
+                      - j)))
               {
                 blank = false;
                 break;
@@ -1080,8 +1083,8 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         {
           if (sg.getSize() == av.getAlignment().getHeight())
           {
-            if ((av.hasHiddenColumns() && startres < av.getColumnSelection()
-                    .getHiddenBoundaryRight(startres)))
+            if ((av.hasHiddenColumns() && startres < av
+                    .getColumnSelection().getHiddenBoundaryRight(startres)))
             {
               endEditing();
               return;
@@ -1090,7 +1093,8 @@ public class SeqPanel extends Panel implements MouseMotionListener,
             int alWidth = av.getAlignment().getWidth();
             if (av.hasHiddenRows())
             {
-              int hwidth = av.getAlignment().getHiddenSequences().getWidth();
+              int hwidth = av.getAlignment().getHiddenSequences()
+                      .getWidth();
               if (hwidth > alWidth)
               {
                 alWidth = hwidth;
@@ -1115,7 +1119,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         // / Are we able to delete?
         // ie are all columns blank?
 
-        for (SequenceI gs:groupSeqs)
+        for (SequenceI gs : groupSeqs)
         {
           for (int j = startres; j < lastres; j++)
           {
@@ -1258,16 +1262,16 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     editCommand.appendEdit(EditCommand.DELETE_GAP, seq, blankColumn, 1,
             av.getAlignment(), true);
 
-    editCommand.appendEdit(EditCommand.INSERT_GAP, seq, j, 1, av.getAlignment(),
-            true);
+    editCommand.appendEdit(EditCommand.INSERT_GAP, seq, j, 1,
+            av.getAlignment(), true);
 
   }
 
   void deleteChar(int j, SequenceI[] seq, int fixedColumn)
   {
 
-    editCommand.appendEdit(EditCommand.DELETE_GAP, seq, j, 1, av.getAlignment(),
-            true);
+    editCommand.appendEdit(EditCommand.DELETE_GAP, seq, j, 1,
+            av.getAlignment(), true);
 
     editCommand.appendEdit(EditCommand.INSERT_GAP, seq, fixedColumn, 1,
             av.getAlignment(), true);
@@ -1411,27 +1415,17 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       return;
     }
 
+    stretchGroup.recalcConservation(); // always do this - annotation has own
+                                       // state
     if (stretchGroup.cs != null)
     {
-      if (stretchGroup.cs instanceof ClustalxColourScheme)
-      {
-        ((ClustalxColourScheme) stretchGroup.cs).alignmentChanged(
-stretchGroup,av.getHiddenRepSequences());
-      }
-
-      if (stretchGroup.cs instanceof Blosum62ColourScheme
-              || stretchGroup.cs instanceof PIDColourScheme
-              || stretchGroup.cs.conservationApplied()
-              || stretchGroup.cs.getThreshold() > 0)
-      {
-        stretchGroup.recalcConservation();
-      }
+      stretchGroup.cs.alignmentChanged(stretchGroup,
+              av.getHiddenRepSequences());
 
       if (stretchGroup.cs.conservationApplied())
       {
         SliderPanel.setConservationSlider(ap, stretchGroup.cs,
                 stretchGroup.getName());
-        stretchGroup.recalcConservation();
       }
       else
       {
@@ -1516,7 +1510,8 @@ stretchGroup,av.getHiddenRepSequences());
       dragDirection = -1;
     }
 
-    while ((y != oldSeq) && (oldSeq > -1) && (y < av.getAlignment().getHeight()))
+    while ((y != oldSeq) && (oldSeq > -1)
+            && (y < av.getAlignment().getHeight()))
     {
       // This routine ensures we don't skip any sequences, as the
       // selection is quite slow.
@@ -1703,7 +1698,7 @@ stretchGroup,av.getHiddenRepSequences());
     if (av.getSelectionGroup() == null || !av.isSelectionGroupChanged(true))
     {
       SequenceGroup sgroup = null;
-      if (seqsel != null && seqsel.getSize()>0)
+      if (seqsel != null && seqsel.getSize() > 0)
       {
         if (av.getAlignment() == null)
         {
@@ -1733,7 +1728,9 @@ stretchGroup,av.getHiddenRepSequences());
       }
       repaint = av.isSelectionGroupChanged(true);
     }
-    if (copycolsel && (av.getColumnSelection() == null || !av.isColSelChanged(true)))
+    if (copycolsel
+            && (av.getColumnSelection() == null || !av
+                    .isColSelChanged(true)))
     {
       // the current selection is unset or from a previous message
       // so import the new colsel.
@@ -1758,8 +1755,10 @@ stretchGroup,av.getHiddenRepSequences());
       }
       repaint |= av.isColSelChanged(true);
     }
-    if (copycolsel && av.hasHiddenColumns()
-            && (av.getColumnSelection() == null || av.getColumnSelection().getHiddenColumns() == null))
+    if (copycolsel
+            && av.hasHiddenColumns()
+            && (av.getColumnSelection() == null || av.getColumnSelection()
+                    .getHiddenColumns() == null))
     {
       System.err.println("Bad things");
     }
@@ -1772,35 +1771,40 @@ stretchGroup,av.getHiddenRepSequences());
 
   /**
    * scroll to the given row/column - or nearest visible location
+   * 
    * @param row
    * @param column
    */
   public void scrollTo(int row, int column)
   {
-    
-    row = row<0 ? ap.av.startSeq : row;
-    column = column<0 ? ap.av.startRes : column;
+
+    row = row < 0 ? ap.av.startSeq : row;
+    column = column < 0 ? ap.av.startRes : column;
     ap.scrollTo(column, column, row, true, true);
   }
+
   /**
    * scroll to the given row - or nearest visible location
+   * 
    * @param row
    */
   public void scrollToRow(int row)
   {
-    
-    row = row<0 ? ap.av.startSeq : row;
+
+    row = row < 0 ? ap.av.startSeq : row;
     ap.scrollTo(ap.av.startRes, ap.av.startRes, row, true, true);
   }
+
   /**
    * scroll to the given column - or nearest visible location
+   * 
    * @param column
    */
   public void scrollToColumn(int column)
   {
-    
-    column = column<0 ? ap.av.startRes : column;
-    ap.scrollTo( column, column, ap.av.startSeq, true, true);
+
+    column = column < 0 ? ap.av.startRes : column;
+    ap.scrollTo(column, column, ap.av.startSeq, true, true);
   }
 
 }