X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FAlignmentViewport.java;h=0e3bb9e923077371053715aa0e677adfa0914453;hb=bea1d9b563d2fea018de3dbde9112dd59149126e;hp=77210eeada5b675a4568d4b8736b13dc276dc626;hpb=6a6fb5010c2cd06b14a1e055eabaeb4848e65d2d;p=jalview.git diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 77210ee..0e3bb9e 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -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,7 +57,6 @@ 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; @@ -76,6 +74,9 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; /** * base class holding visualization and analysis attributes and common logic for @@ -87,6 +88,8 @@ import java.util.Map; public abstract class AlignmentViewport implements AlignViewportI, CommandListener, VamsasSource { + public static final String PROPERTY_ALIGNMENT = "alignment"; + public static final String PROPERTY_SEQUENCE = "sequence"; protected ViewportRanges ranges; protected ViewStyleI viewStyle = new ViewStyle(); @@ -615,6 +618,7 @@ public abstract class AlignmentViewport * alignment */ protected boolean isDataset = false; + public void setDataset(boolean b) { @@ -630,13 +634,33 @@ public abstract class AlignmentViewport protected ColumnSelection colSel = new ColumnSelection(); - public boolean autoCalculateConsensus = true; + protected boolean autoCalculateConsensusAndConservation = true; + + public boolean getAutoCalculateConsensusAndConservation() + { // BH 2019.07.24 + return autoCalculateConsensusAndConservation; + } + + public void setAutoCalculateConsensusAndConservation(boolean b) + { + autoCalculateConsensusAndConservation = b; + } protected boolean autoCalculateStrucConsensus = true; + public boolean getAutoCalculateStrucConsensus() + { // BH 2019.07.24 + return autoCalculateStrucConsensus; + } + + public void setAutoCalculateStrucConsensus(boolean b) + { + autoCalculateStrucConsensus = b; + } protected boolean ignoreGapsInConsensusCalculation = false; protected ResidueShaderI residueShading = new ResidueShader(); + @Override public void setGlobalColourScheme(ColourSchemeI cs) @@ -711,6 +735,7 @@ public abstract class AlignmentViewport { return residueShading; } + protected AlignmentAnnotation consensus; @@ -745,6 +770,7 @@ public abstract class AlignmentViewport protected Hashtable[] hStrucConsensus = null; protected Conservation hconservation = null; + @Override public void setConservation(Conservation cons) @@ -861,7 +887,7 @@ public abstract class AlignmentViewport // see note in mantis : issue number 8585 if (alignment.isNucleotide() || (conservation == null && quality == null) - || !autoCalculateConsensus) + || !autoCalculateConsensusAndConservation) { return; } @@ -879,7 +905,7 @@ public abstract class AlignmentViewport public void updateConsensus(final AlignmentViewPanel ap) { // see note in mantis : issue number 8585 - if (consensus == null || !autoCalculateConsensus) + if (consensus == null || !autoCalculateConsensusAndConservation) { return; } @@ -930,7 +956,6 @@ public abstract class AlignmentViewport calculator.registerWorker(new InformationThread(this, ap)); } } - // --------START Structure Conservation public void updateStrucConsensus(final AlignmentViewPanel ap) { @@ -973,6 +998,20 @@ public abstract class AlignmentViewport return false; } + private ScheduledExecutorService serviceExecutor = Executors.newSingleThreadScheduledExecutor(); + + /** + * Get a default scheduled executor service which can be used by + * services and calculators to run parallel jobs associated with this + * viewport. + * + * @return default service executor of that viewport + */ + public ScheduledExecutorService getServiceExecutor() + { + return serviceExecutor; + } + public void setAlignment(AlignmentI align) { this.alignment = align; @@ -1000,12 +1039,16 @@ public abstract class AlignmentViewport hconservation = null; hcomplementConsensus = null; gapcounts = null; + calculator.shutdown(); calculator = null; + serviceExecutor.shutdown(); + serviceExecutor = null; residueShading = null; // may hold a reference to Consensus changeSupport = null; ranges = null; currentTree = null; selectionGroup = null; + colSel = null; setAlignment(null); } @@ -1116,7 +1159,6 @@ public abstract class AlignmentViewport } this.hmmShowSequenceLogo = showHMMSequenceLogo; } - /** * @param showConsensusHistogram * the showConsensusHistogram to set @@ -1388,21 +1430,22 @@ public abstract class AlignmentViewport * checks current colsel against record of last hash value, and optionally * updates record. * - * @param b + * @param updateHash * update the record of last hash value * @return true if colsel changed since last call (when b is true) */ - public boolean isColSelChanged(boolean b) + public boolean isColSelChanged(boolean updateHash) { int hc = (colSel == null || colSel.isEmpty()) ? -1 : colSel.hashCode(); if (hc != -1 && hc != colselhash) { - if (b) + if (updateHash) { colselhash = hc; } return true; } + notifySequence(); return false; } @@ -1423,7 +1466,6 @@ public abstract class AlignmentViewport { return infoLetterHeight; } - // property change stuff // JBPNote Prolly only need this in the applet version. private PropertyChangeSupport changeSupport = new PropertyChangeSupport( @@ -1475,21 +1517,6 @@ public abstract class AlignmentViewport } } - /** - * Property change listener for changes in alignment - * - * @param prop - * DOCUMENT ME! - * @param oldvalue - * DOCUMENT ME! - * @param newvalue - * DOCUMENT ME! - */ - public void firePropertyChange(String prop, Object oldvalue, - Object newvalue) - { - changeSupport.firePropertyChange(prop, oldvalue, newvalue); - } // common hide/show column stuff @@ -1555,9 +1582,9 @@ public abstract class AlignmentViewport ranges.setStartEndSeq(startSeq, endSeq + tmp.size()); - firePropertyChange("alignment", null, alignment.getSequences()); // used to set hasHiddenRows/hiddenRepSequences here, after the property // changed event + notifySequence(); sendSelection(); } } @@ -1585,7 +1612,7 @@ public abstract class AlignmentViewport ranges.setStartEndSeq(startSeq, endSeq + tmp.size()); - firePropertyChange("alignment", null, alignment.getSequences()); + notifyAlignment(); sendSelection(); } } @@ -1619,7 +1646,7 @@ public abstract class AlignmentViewport setSequenceAnnotationsVisible(seq[i], false); } ranges.setStartSeq(startSeq); - firePropertyChange("alignment", null, alignment.getSequences()); + notifyAlignment(); } } @@ -1984,11 +2011,11 @@ public abstract class AlignmentViewport { alignment.padGaps(); } - if (autoCalculateConsensus) + if (autoCalculateConsensusAndConservation) { updateConsensus(ap); } - if (hconsensus != null && autoCalculateConsensus) + if (hconsensus != null && autoCalculateConsensusAndConservation) { updateConservation(ap); } @@ -2070,7 +2097,6 @@ public abstract class AlignmentViewport MessageManager.getString("label.consensus_descr"), new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); initConsensus(consensus); - initGapCounts(); initComplementConsensus(); @@ -3116,7 +3142,6 @@ public abstract class AlignmentViewport } return false; } - @Override public void setCurrentTree(TreeModel tree) { @@ -3244,6 +3269,23 @@ public abstract class AlignmentViewport } } + @Override + public Iterator 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 @@ -3284,5 +3326,21 @@ public abstract class AlignmentViewport hideSequence(new SequenceI[] { seq }); } } + } + + /** + * Notify TreePanel and AlignmentPanel of some sort of alignment change. + */ + public void notifyAlignment() + { + changeSupport.firePropertyChange(PROPERTY_ALIGNMENT, null, alignment.getSequences()); + } + + /** + * Notify AlignmentPanel of a sequence column selection or visibility changes. + */ + public void notifySequence() + { + changeSupport.firePropertyChange(PROPERTY_SEQUENCE, null, null); } }