formatting
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index ae1a4fd..fc96f62 100644 (file)
@@ -41,9 +41,11 @@ import java.util.Hashtable;
 import java.util.Vector;
 
 /**
- * base class holding visualization and analysis attributes and common logic for an active alignment view displayed in the GUI
+ * base class holding visualization and analysis attributes and common logic for
+ * an active alignment view displayed in the GUI
+ * 
  * @author jimp
- *
+ * 
  */
 public abstract class AlignmentViewport implements AlignViewportI
 {
@@ -55,7 +57,8 @@ public abstract class AlignmentViewport implements AlignViewportI
   protected String sequenceSetID;
 
   /**
-   * probably unused indicator that view is of a dataset rather than an alignment
+   * probably unused indicator that view is of a dataset rather than an
+   * alignment
    */
   protected boolean isDataset = false;
 
@@ -63,13 +66,11 @@ public abstract class AlignmentViewport implements AlignViewportI
 
   protected ColumnSelection colSel = new ColumnSelection();
 
-
   public boolean autoCalculateConsensus = true;
 
   protected boolean autoCalculateStrucConsensus = true;
 
   protected boolean ignoreGapsInConsensusCalculation = false;
-  
 
   protected ColourSchemeI globalColourScheme = null;
 
@@ -84,7 +85,6 @@ public abstract class AlignmentViewport implements AlignViewportI
     return globalColourScheme;
   }
 
-
   protected AlignmentAnnotation consensus;
 
   protected AlignmentAnnotation strucConsensus;
@@ -97,22 +97,23 @@ public abstract class AlignmentViewport implements AlignViewportI
 
   protected AlignmentAnnotation[] groupConservation;
 
-  /** 
-   * results of alignment consensus analysis for visible portion of view 
+  /**
+   * results of alignment consensus analysis for visible portion of view
    */
-  protected Hashtable[] hconsensus=null;
+  protected Hashtable[] hconsensus = null;
 
   /**
-   * results of secondary structure base pair consensus for visible portion of view
+   * results of secondary structure base pair consensus for visible portion of
+   * view
    */
-  protected Hashtable[] hStrucConsensus=null;
+  protected Hashtable[] hStrucConsensus = null;
 
   /**
-   * percentage gaps allowed in a column before all amino acid properties should be considered unconserved
+   * percentage gaps allowed in a column before all amino acid properties should
+   * be considered unconserved
    */
   int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
 
-
   public int getConsPercGaps()
   {
     return ConsPercGaps;
@@ -120,8 +121,8 @@ public abstract class AlignmentViewport implements AlignViewportI
   @Override
   public void setSequenceConsensusHash(Hashtable[] hconsensus)
   {
-    this.hconsensus=hconsensus;
-    
+    this.hconsensus = hconsensus;
+
   }
 
   @Override
@@ -135,12 +136,14 @@ public abstract class AlignmentViewport implements AlignViewportI
   {
     return hStrucConsensus;
   }
+
   @Override
   public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
   {
-    this.hStrucConsensus=hStrucConsensus;
-    
+    this.hStrucConsensus = hStrucConsensus;
+
   }
+
   @Override
   public AlignmentAnnotation getAlignmentQualityAnnot()
   {
@@ -152,18 +155,20 @@ public abstract class AlignmentViewport implements AlignViewportI
   {
     return conservation;
   }
+
   @Override
   public AlignmentAnnotation getAlignmentConsensusAnnotation()
   {
     return consensus;
   }
+
   @Override
   public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
   {
     return strucConsensus;
   }
-  
-  protected AlignCalcManagerI calculator=new AlignCalcManager();
+
+  protected AlignCalcManagerI calculator = new AlignCalcManager();
 
   /**
    * trigger update of conservation annotation
@@ -176,9 +181,11 @@ public abstract class AlignmentViewport implements AlignViewportI
     {
       return;
     }
-    if (!calculator.startRegisteredWorkersOfClass(jalview.workers.ConservationThread.class))
+    if (!calculator
+            .startRegisteredWorkersOfClass(jalview.workers.ConservationThread.class))
     {
-      calculator.registerWorker(new jalview.workers.ConservationThread(this, ap));
+      calculator.registerWorker(new jalview.workers.ConservationThread(
+              this, ap));
     }
   }
 
@@ -201,9 +208,10 @@ public abstract class AlignmentViewport implements AlignViewportI
   // --------START Structure Conservation
   public void updateStrucConsensus(final AlignmentViewPanel ap)
   {
-    if (autoCalculateStrucConsensus && strucConsensus==null && alignment.isNucleotide() && alignment.hasRNAStructure())
+    if (autoCalculateStrucConsensus && strucConsensus == null
+            && alignment.isNucleotide() && alignment.hasRNAStructure())
     {
-      
+
     }
 
     // see note in mantis : issue number 8585
@@ -211,9 +219,10 @@ public abstract class AlignmentViewport implements AlignViewportI
     {
       return;
     }
-    if (!calculator.startRegisteredWorkersOfClass(StrucConsensusThread.class))
+    if (!calculator
+            .startRegisteredWorkersOfClass(StrucConsensusThread.class))
     {
-      calculator.registerWorker(new StrucConsensusThread(this,ap));
+      calculator.registerWorker(new StrucConsensusThread(this, ap));
     }
   }
 
@@ -229,16 +238,18 @@ public abstract class AlignmentViewport implements AlignViewportI
       return false;
     if (calculator.workingInvolvedWith(alignmentAnnotation))
     {
-//      System.err.println("grey out ("+alignmentAnnotation.label+")");
+      // System.err.println("grey out ("+alignmentAnnotation.label+")");
       return true;
     }
     return false;
   }
+
   @Override
   public boolean isClosed()
   {
-    // TODO: check that this isClosed is only true after panel is closed, not before it is fully constructed.
-    return alignment==null;
+    // TODO: check that this isClosed is only true after panel is closed, not
+    // before it is fully constructed.
+    return alignment == null;
   }
 
   @Override
@@ -418,9 +429,10 @@ public abstract class AlignmentViewport implements AlignViewportI
   {
     return colSel;
   }
+
   public void setColumnSelection(ColumnSelection colSel)
   {
-    this.colSel=colSel;
+    this.colSel = colSel;
   }
   public Hashtable getHiddenRepSequences()
   {
@@ -434,12 +446,13 @@ public abstract class AlignmentViewport implements AlignViewportI
 
   public void updateHiddenColumns()
   {
-    hasHiddenColumns = colSel.getHiddenColumns() != null;  
+    hasHiddenColumns = colSel.getHiddenColumns() != null;
   }
-  
+
   protected boolean hasHiddenRows = false;
-  
-  public boolean hasHiddenRows() {
+
+  public boolean hasHiddenRows()
+  {
     return hasHiddenRows;
   }
 
@@ -447,12 +460,14 @@ public abstract class AlignmentViewport implements AlignViewportI
 
   public void setSequenceSetId(String newid)
   {
-    if (sequenceSetID!=null)
+    if (sequenceSetID != null)
     {
-      System.err.println("Warning - overwriting a sequenceSetId for a viewport!");
+      System.err
+              .println("Warning - overwriting a sequenceSetId for a viewport!");
     }
-    sequenceSetID=new String(newid);
+    sequenceSetID = new String(newid);
   }
+
   public String getSequenceSetId()
   {
     if (sequenceSetID == null)
@@ -462,6 +477,7 @@ public abstract class AlignmentViewport implements AlignViewportI
 
     return sequenceSetID;
   }
+
   /**
    * unique viewId for synchronizing state (e.g. with stored Jalview Project)
    * 
@@ -476,17 +492,22 @@ public abstract class AlignmentViewport implements AlignViewportI
     }
     return viewId;
   }
+
   public void setIgnoreGapsConsensus(boolean b, AlignmentViewPanel ap)
   {
     ignoreGapsInConsensusCalculation = b;
-    if (ap!=null) {updateConsensus(ap);
-    if (globalColourScheme != null)
+    if (ap != null)
     {
-      globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
-              ignoreGapsInConsensusCalculation);
-    }}
-    
+      updateConsensus(ap);
+      if (globalColourScheme != null)
+      {
+        globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
+                ignoreGapsInConsensusCalculation);
+      }
+    }
+
   }
+
   private long sgrouphash = -1, colselhash = -1;
 
   /**
@@ -541,7 +562,7 @@ public abstract class AlignmentViewport implements AlignViewportI
     return ignoreGapsInConsensusCalculation;
   }
 
-  /// property change stuff
+  // / property change stuff
 
   // JBPNote Prolly only need this in the applet version.
   private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
@@ -661,7 +682,8 @@ public abstract class AlignmentViewport implements AlignViewportI
       hiddenRepSequences = null;
 
       firePropertyChange("alignment", null, alignment.getSequences());
-      // used to set hasHiddenRows/hiddenRepSequences here, after the property changed event
+      // used to set hasHiddenRows/hiddenRepSequences here, after the property
+      // changed event
       sendSelection();
     }
   }
@@ -682,7 +704,8 @@ public abstract class AlignmentViewport implements AlignViewportI
       {
         selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
       }
-      // JBPNote: refactor: only update flag if we modified visiblity (used to do this regardless) 
+      // JBPNote: refactor: only update flag if we modified visiblity (used to
+      // do this regardless)
       if (alignment.getHiddenSequences().getSize() < 1)
       {
         hasHiddenRows = false;
@@ -752,7 +775,7 @@ public abstract class AlignmentViewport implements AlignViewportI
         seqs[index++] = sg.getSequenceAt(i);
       }
     }
-    sg.setSeqrep(repSequence); // note: not done in 2.7applet 
+    sg.setSeqrep(repSequence); // note: not done in 2.7applet
     sg.setHidereps(true); // note: not done in 2.7applet
     hideSequence(seqs);
 
@@ -761,11 +784,13 @@ public abstract class AlignmentViewport implements AlignViewportI
   public boolean isHiddenRepSequence(SequenceI seq)
   {
     return hiddenRepSequences != null
-          && hiddenRepSequences.containsKey(seq);
+            && hiddenRepSequences.containsKey(seq);
   }
+
   public SequenceGroup getRepresentedSequences(SequenceI seq)
   {
-    return (SequenceGroup) (hiddenRepSequences == null ? null : hiddenRepSequences.get(seq));
+    return (SequenceGroup) (hiddenRepSequences == null ? null
+            : hiddenRepSequences.get(seq));
   }
 
   public int adjustForHiddenSeqs(int alignmentIndex)
@@ -786,7 +811,6 @@ public abstract class AlignmentViewport implements AlignViewportI
     colSel.invertColumnSelection(0, alignment.getWidth());
   }
 
-
   /**
    * This method returns an array of new SequenceI objects derived from the
    * whole alignment or just the current selection with start and end points
@@ -799,8 +823,11 @@ public abstract class AlignmentViewport implements AlignViewportI
   public SequenceI[] getSelectionAsNewSequence()
   {
     SequenceI[] sequences;
-    // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom - this was the only caller in the applet for this method
-    // JBPNote: in applet, this method returned references to the alignment sequences, and it did not honour the presence/absence of annotation attached to the alignment (probably!)
+    // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom -
+    // this was the only caller in the applet for this method
+    // JBPNote: in applet, this method returned references to the alignment
+    // sequences, and it did not honour the presence/absence of annotation
+    // attached to the alignment (probably!)
     if (selectionGroup == null)
     {
       sequences = alignment.getSequencesArray();
@@ -821,7 +848,6 @@ public abstract class AlignmentViewport implements AlignViewportI
     return sequences;
   }
 
-
   /**
    * get the currently selected sequence objects or all the sequences in the
    * alignment.
@@ -937,11 +963,13 @@ public abstract class AlignmentViewport implements AlignViewportI
     return selection;
   }
 
-
   /**
    * return visible region boundaries within given column range
-   * @param min first column (inclusive, from 0)
-   * @param max last column (exclusive)
+   * 
+   * @param min
+   *          first column (inclusive, from 0)
+   * @param max
+   *          last column (exclusive)
    * @return int[][] range of {start,end} visible positions
    */
   public int[][] getVisibleRegionBoundaries(int min, int max)
@@ -994,15 +1022,20 @@ public abstract class AlignmentViewport implements AlignViewportI
   {
     return padGaps;
   }
+
   /**
-   * @param padGaps the padGaps to set
+   * @param padGaps
+   *          the padGaps to set
    */
   public void setPadGaps(boolean padGaps)
   {
     this.padGaps = padGaps;
   }
+
   /**
-   * apply any post-edit constraints and trigger any calculations needed after an edit has been performed on the alignment 
+   * apply any post-edit constraints and trigger any calculations needed after
+   * an edit has been performed on the alignment
+   * 
    * @param ap
    */
   public void alignmentChanged(AlignmentViewPanel ap)
@@ -1100,48 +1133,53 @@ public abstract class AlignmentViewport implements AlignViewportI
       {
         if (showConservation)
         {
-          if (conservation==null)
-        {
-        conservation = new AlignmentAnnotation("Conservation",
-                "Conservation of total alignment less than " + getConsPercGaps()
-                        + "% gaps", new Annotation[1], 0f, 11f,
-                AlignmentAnnotation.BAR_GRAPH);
-        conservation.hasText = true;
-        conservation.autoCalculated = true;
-          alignment.addAnnotation(conservation);
-        }
+          if (conservation == null)
+          {
+            conservation = new AlignmentAnnotation("Conservation",
+                    "Conservation of total alignment less than "
+                            + getConsPercGaps() + "% gaps",
+                    new Annotation[1], 0f, 11f,
+                    AlignmentAnnotation.BAR_GRAPH);
+            conservation.hasText = true;
+            conservation.autoCalculated = true;
+            alignment.addAnnotation(conservation);
+          }
         }
         if (showQuality)
         {
-          if (quality==null)
+          if (quality == null)
           {
-          quality = new AlignmentAnnotation("Quality",
-                  "Alignment Quality based on Blosum62 scores",
-                  new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
-          quality.hasText = true;
-          quality.autoCalculated = true;
-          alignment.addAnnotation(quality);
+            quality = new AlignmentAnnotation("Quality",
+                    "Alignment Quality based on Blosum62 scores",
+                    new Annotation[1], 0f, 11f,
+                    AlignmentAnnotation.BAR_GRAPH);
+            quality.hasText = true;
+            quality.autoCalculated = true;
+            alignment.addAnnotation(quality);
+          }
         }
-        }
-      } else {
+      }
+      else
+      {
         if (alignment.hasRNAStructure())
         {
           strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
-                  new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
+                  new Annotation[1], 0f, 100f,
+                  AlignmentAnnotation.BAR_GRAPH);
           strucConsensus.hasText = true;
           strucConsensus.autoCalculated = true;
         }
       }
-        
+
       consensus = new AlignmentAnnotation("Consensus", "PID",
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       consensus.hasText = true;
       consensus.autoCalculated = true;
-  
+
       if (showConsensus)
       {
         alignment.addAnnotation(consensus);
-        if (strucConsensus!=null)
+        if (strucConsensus != null)
         {
           alignment.addAnnotation(strucConsensus);
         }