Merge branch 'develop' into developtomchmmer
[jalview.git] / src / jalview / datamodel / SequenceGroup.java
index cffe0d9..56681cf 100755 (executable)
@@ -81,7 +81,7 @@ public class SequenceGroup implements AnnotatedCollectionI
   /*
    * sequences in the group
    */
-  private List<SequenceI> sequences = new ArrayList<>();
+  private List<SequenceI> sequences;
 
   /*
    * representative sequence for this group (if any)
@@ -95,11 +95,15 @@ public class SequenceGroup implements AnnotatedCollectionI
    */
   public ResidueShaderI cs;
 
-  // start column (base 0)
-  private int startRes;
+  /**
+   * start column (base 0)
+   */
+  private int startRes = 0;
 
-  // end column (base 0)
-  private int endRes;
+  /**
+   *  end column (base 0)
+   */
+  private int endRes = 0;
 
   public Color outlineColour = Color.black;
 
@@ -159,6 +163,7 @@ public class SequenceGroup implements AnnotatedCollectionI
   {
     groupName = "JGroup:" + this.hashCode();
     cs = new ResidueShader();
+    sequences = new ArrayList<>();
   }
 
   /**
@@ -226,6 +231,7 @@ public class SequenceGroup implements AnnotatedCollectionI
       displayBoxes = seqsel.displayBoxes;
       displayText = seqsel.displayText;
       colourText = seqsel.colourText;
+      
       startRes = seqsel.startRes;
       endRes = seqsel.endRes;
       cs = new ResidueShader((ResidueShader) seqsel.cs);
@@ -275,6 +281,17 @@ public class SequenceGroup implements AnnotatedCollectionI
     changeSupport.removePropertyChangeListener(listener);
   }
 
+  /**
+   * Constructor that copies the given list of sequences
+   * 
+   * @param seqs
+   */
+  public SequenceGroup(List<SequenceI> seqs)
+  {
+    this();
+    this.sequences.addAll(seqs);
+  }
+
   public boolean isShowSequenceLogo()
   {
     return showSequenceLogo;
@@ -821,13 +838,16 @@ public class SequenceGroup implements AnnotatedCollectionI
   /**
    * Set the first column selected by this group. Runs from 0<=i<N_cols
    * 
-   * @param i
+   * @param newStart
    */
-  public void setStartRes(int i)
+  public void setStartRes(int newStart)
   {
     int before = startRes;
-    startRes = i;
-    changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
+   startRes= Math.max(0,newStart); // sanity check for negative start column positions
+   changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
+    
+
+
   }
 
   /**