AdjustAnnotations needs position, number and insert
authoramwaterhouse <Andrew Waterhouse>
Wed, 24 Jan 2007 17:30:12 +0000 (17:30 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 24 Jan 2007 17:30:12 +0000 (17:30 +0000)
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/AlignmentAnnotation.java
src/jalview/datamodel/AlignmentI.java

index 552a5f8..f255ab5 100755 (executable)
@@ -470,15 +470,53 @@ public class Alignment implements AlignmentI
     }
 
 
-    public void adjustSequenceAnnotations()
+    public void adjustSequenceAnnotations(int position,
+                                          int number,
+                                          boolean insert)
     {
       if(annotations!=null)
       {
+        int aSize, tSize;
+        Annotation [] temp;
         for (int a = 0; a < annotations.length; a++)
         {
-          if (annotations[a].sequenceRef != null)
+          if(annotations[a].autoCalculated)
           {
-            annotations[a].adjustForAlignment();
+            System.out.println("ignore "+annotations[a].label);
+            continue;
+          }
+          aSize = annotations[a].annotations.length;
+          if(insert)
+            tSize = aSize + number;
+          else
+            tSize = aSize - number;
+
+          temp = new Annotation[tSize];
+
+          if(insert)
+          {
+            System.arraycopy(annotations[a].annotations,
+                0, temp, 0, position);
+
+            System.arraycopy(annotations[a].annotations,
+                position, temp, position+number, aSize - position);
+          }
+          else
+          {
+              System.arraycopy(annotations[a].annotations,
+                               0, temp, 0, position);
+
+              System.arraycopy(annotations[a].annotations,
+                               position + number, temp, position,
+                               aSize - position - number);
+          }
+
+          annotations[a].annotations = temp;
+
+
+        //  if (annotations[a].sequenceRef != null)
+          {
+        //    annotations[a].adjustForAlignment();
           }
         }
       }
index a97ca7f..4a3cad6 100755 (executable)
@@ -27,6 +27,10 @@ package jalview.datamodel;
  */
 public class AlignmentAnnotation
 {
+  /** If true, this annotations is calculated every edit,
+   * eg consensus, quality or conservation graphs */
+  public boolean autoCalculated = false;
+
     public SequenceI sequenceRef;
 
     /** DOCUMENT ME!! */
index 12baabf..bf1614b 100755 (executable)
@@ -228,7 +228,10 @@ public interface AlignmentI
      */
     public boolean padGaps();
 
-    public void adjustSequenceAnnotations();
+    public void adjustSequenceAnnotations(int position,
+                                          int number,
+                                          boolean insert);
+
 
     public HiddenSequences getHiddenSequences();
     /**