Merge branch 'JAL-3878_web_services_overhaul' into try-to-update-slivka-jar
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index 4aec9d2..066be9b 100644 (file)
@@ -23,7 +23,6 @@ package jalview.viewmodel;
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.analysis.Conservation;
 import jalview.analysis.TreeModel;
-import jalview.api.AlignCalcManagerI;
 import jalview.api.AlignCalcManagerI2;
 import jalview.api.AlignCalcWorkerI;
 import jalview.api.AlignExportSettingsI;
@@ -58,12 +57,12 @@ import jalview.util.MapList;
 import jalview.util.MappingUtils;
 import jalview.util.MessageManager;
 import jalview.viewmodel.styles.ViewStyle;
-import jalview.workers.AlignCalcManager;
 import jalview.workers.AlignCalcManager2;
 import jalview.workers.ComplementConsensusThread;
 import jalview.workers.ConsensusThread;
 import jalview.workers.InformationThread;
 import jalview.workers.StrucConsensusThread;
+import jalview.ws2.PollingTaskExecutor;
 
 import java.awt.Color;
 import java.beans.PropertyChangeSupport;
@@ -89,7 +88,6 @@ public abstract class AlignmentViewport
 {
   public static final String PROPERTY_ALIGNMENT = "alignment";
   public static final String PROPERTY_SEQUENCE = "sequence";
-
   protected ViewportRanges ranges;
 
   protected ViewStyleI viewStyle = new ViewStyle();
@@ -618,6 +616,7 @@ public abstract class AlignmentViewport
    * alignment
    */
   protected boolean isDataset = false;
+
   
   public void setDataset(boolean b)
   {
@@ -656,11 +655,10 @@ public abstract class AlignmentViewport
   {
     autoCalculateStrucConsensus = b;
   }
-
-
   protected boolean ignoreGapsInConsensusCalculation = false;
 
   protected ResidueShaderI residueShading = new ResidueShader();
+
   
   @Override
   public void setGlobalColourScheme(ColourSchemeI cs)
@@ -735,6 +733,7 @@ public abstract class AlignmentViewport
   {
     return residueShading;
   }
+
   
   protected AlignmentAnnotation consensus;
 
@@ -769,6 +768,7 @@ public abstract class AlignmentViewport
   protected Hashtable<String, Object>[] hStrucConsensus = null;
 
   protected Conservation hconservation = null;
+
   
   @Override
   public void setConservation(Conservation cons)
@@ -954,7 +954,6 @@ public abstract class AlignmentViewport
       calculator.registerWorker(new InformationThread(this, ap));
     }
   }
-
   // --------START Structure Conservation
   public void updateStrucConsensus(final AlignmentViewPanel ap)
   {
@@ -997,6 +996,13 @@ public abstract class AlignmentViewport
     return false;
   }
 
+  private PollingTaskExecutor wsExecutor = new PollingTaskExecutor();
+
+  public PollingTaskExecutor getWSExecutor()
+  {
+    return wsExecutor;
+  }
+
   public void setAlignment(AlignmentI align)
   {
     this.alignment = align;
@@ -1026,11 +1032,14 @@ public abstract class AlignmentViewport
     gapcounts = null;
     calculator.shutdown();
     calculator = null;
+    wsExecutor.shutdown();
+    wsExecutor = null;
     residueShading = null; // may hold a reference to Consensus
     changeSupport = null;
     ranges = null;
     currentTree = null;
     selectionGroup = null;
+    colSel = null;
     setAlignment(null);
   }
 
@@ -1141,7 +1150,6 @@ public abstract class AlignmentViewport
     }
     this.hmmShowSequenceLogo = showHMMSequenceLogo;
   }
-
   /**
    * @param showConsensusHistogram
    *          the showConsensusHistogram to set
@@ -1449,7 +1457,6 @@ public abstract class AlignmentViewport
   {
     return infoLetterHeight;
   }
-
   // property change stuff
   // JBPNote Prolly only need this in the applet version.
   private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
@@ -1501,6 +1508,7 @@ public abstract class AlignmentViewport
     }
   }
 
+
   // common hide/show column stuff
 
   public void hideSelectedColumns()
@@ -1572,7 +1580,6 @@ public abstract class AlignmentViewport
     }
   }
 
-
   public void showSequence(int index)
   {
     int startSeq = ranges.getStartSeq();
@@ -1595,6 +1602,7 @@ public abstract class AlignmentViewport
       }
 
       ranges.setStartEndSeq(startSeq, endSeq + tmp.size());
+
       notifyAlignment();
       sendSelection();
     }
@@ -2080,7 +2088,6 @@ public abstract class AlignmentViewport
               MessageManager.getString("label.consensus_descr"),
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       initConsensus(consensus);
-
       initGapCounts();
 
       initComplementConsensus();
@@ -3126,7 +3133,6 @@ public abstract class AlignmentViewport
     }
     return false;
   }
-
   @Override
   public void setCurrentTree(TreeModel tree)
   {
@@ -3253,6 +3259,24 @@ public abstract class AlignmentViewport
       codingComplement.setUpdateStructures(needToUpdateStructureViews);
     }
   }
+
+  @Override
+  public Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly)
+  {
+    int start = 0;
+    int end = 0;
+    if (selectedRegionOnly && selectionGroup != null)
+    {
+      start = selectionGroup.getStartRes();
+      end = selectionGroup.getEndRes() + 1;
+    }
+    else
+    {
+      end = alignment.getWidth();
+    }
+    return (alignment.getHiddenColumns().getVisContigsIterator(start, end,
+            false));
+  }
   /**
    * Filters out sequences with an eValue higher than the specified value. The
    * filtered sequences are hidden or deleted. Sequences with no eValues are also