X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FAlignmentViewport.java;h=8d2580b93833f17e643daf2b296da8fa3e0e817b;hb=00b6a6802349029e2c6fb3263201287ba921dd63;hp=47f7d9dbd62fd232cf72de86a2fa2a5b9f4fabc8;hpb=7f4da0a2b0c10f158a03dbfce8878e67e90c4a68;p=jalview.git diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 47f7d9d..8d2580b 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -20,6 +20,17 @@ */ package jalview.viewmodel; +import java.awt.Color; +import java.beans.PropertyChangeSupport; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.BitSet; +import java.util.Deque; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.analysis.Conservation; import jalview.api.AlignCalcManagerI; @@ -57,17 +68,6 @@ import jalview.workers.ComplementConsensusThread; import jalview.workers.ConsensusThread; import jalview.workers.StrucConsensusThread; -import java.awt.Color; -import java.beans.PropertyChangeSupport; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.BitSet; -import java.util.Deque; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; - /** * base class holding visualization and analysis attributes and common logic for * an active alignment view displayed in the GUI @@ -78,7 +78,7 @@ import java.util.Map; public abstract class AlignmentViewport implements AlignViewportI, CommandListener, VamsasSource { - protected ViewportPositionProps posProps; + protected ViewportRanges ranges; protected ViewStyleI viewStyle = new ViewStyle(); @@ -674,6 +674,8 @@ public abstract class AlignmentViewport implements AlignViewportI, protected AlignmentAnnotation complementConsensus; + protected AlignmentAnnotation gapcounts; + protected AlignmentAnnotation strucConsensus; protected AlignmentAnnotation conservation; @@ -776,6 +778,12 @@ public abstract class AlignmentViewport implements AlignViewportI, } @Override + public AlignmentAnnotation getAlignmentGapAnnotation() + { + return gapcounts; + } + + @Override public AlignmentAnnotation getComplementConsensusAnnotation() { return complementConsensus; @@ -815,7 +823,7 @@ public abstract class AlignmentViewport implements AlignViewportI, public void updateConsensus(final AlignmentViewPanel ap) { // see note in mantis : issue number 8585 - if (consensus == null || !autoCalculateConsensus) + if ((consensus == null || gapcounts == null) || !autoCalculateConsensus) { return; } @@ -1287,14 +1295,6 @@ public abstract class AlignmentViewport implements AlignViewportI, */ private boolean followHighlight = true; - /*private int startRes; - - private int endRes; - - private int startSeq; - - private int endSeq;*/ - /** * Property change listener for changes in alignment * @@ -1893,16 +1893,21 @@ public abstract class AlignmentViewport implements AlignViewportI, consensus = new AlignmentAnnotation("Consensus", "PID", new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); initConsensus(consensus); + gapcounts = new AlignmentAnnotation("Occupancy", + "Number of aligned positions", + new Annotation[1], 0f, alignment.getHeight(), + AlignmentAnnotation.BAR_GRAPH); + initGapCounts(gapcounts); initComplementConsensus(); } } /** - * If this is a protein alignment and there are mappings to cDNA, add the cDNA - * consensus annotation. + * If this is a protein alignment and there are mappings to cDNA, adds the + * cDNA consensus annotation and returns true, else returns false. */ - public void initComplementConsensus() + public boolean initComplementConsensus() { if (!alignment.isNucleotide()) { @@ -1929,9 +1934,11 @@ public abstract class AlignmentViewport implements AlignViewportI, "PID for cDNA", new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); initConsensus(complementConsensus); + return true; } } } + return false; } private void initConsensus(AlignmentAnnotation aa) @@ -1945,6 +1952,21 @@ public abstract class AlignmentViewport implements AlignViewportI, } } + // these should be extracted from the view model - style and settings for + // derived annotation + private void initGapCounts(AlignmentAnnotation counts) + { + counts.hasText = true; + counts.autoCalculated = true; + counts.scaleColLabel = true; + counts.graph = AlignmentAnnotation.BAR_GRAPH; + + if (showConsensus) + { + alignment.addAnnotation(counts); + } + } + private void initConservation() { if (showConservation) @@ -2647,54 +2669,9 @@ public abstract class AlignmentViewport implements AlignViewportI, } @Override - public ViewportPositionProps getPosProps() - { - return posProps; - } - - @Override - public int getStartRes() - { - return posProps.getStartRes(); - } - - @Override - public int getEndRes() - { - return posProps.getEndRes(); - } - - @Override - public int getStartSeq() + public ViewportRanges getRanges() { - return posProps.getStartSeq(); - } - - public void setStartRes(int res) - { - posProps.setStartRes(res); - // this.startRes = res; - } - - public void setStartSeq(int seq) - { - posProps.setStartSeq(seq); - } - - public void setEndRes(int res) - { - posProps.setEndRes(res); - } - - public void setEndSeq(int seq) - { - posProps.setEndSeq(seq); - } - - @Override - public int getEndSeq() - { - return posProps.getEndSeq(); + return ranges; } /** @@ -2734,7 +2711,8 @@ public abstract class AlignmentViewport implements AlignViewportI, * locate 'middle' column (true middle if an odd number visible, left of * middle if an even number visible) */ - int middleColumn = getStartRes() + (getEndRes() - getStartRes()) / 2; + int middleColumn = ranges.getStartRes() + + (ranges.getEndRes() - ranges.getStartRes()) / 2; final HiddenSequences hiddenSequences = getAlignment() .getHiddenSequences(); @@ -2744,7 +2722,7 @@ public abstract class AlignmentViewport implements AlignViewportI, */ int lastSeq = alignment.getHeight() - 1; List seqMappings = null; - for (int seqNo = getStartSeq(); seqNo < lastSeq; seqNo++, seqOffset++) + for (int seqNo = ranges.getStartSeq(); seqNo < lastSeq; seqNo++, seqOffset++) { sequence = getAlignment().getSequenceAt(seqNo); if (hiddenSequences != null && hiddenSequences.isHidden(sequence)) @@ -2812,7 +2790,6 @@ public abstract class AlignmentViewport implements AlignViewportI, */ private boolean selectionIsDefinedGroup = false; - @Override public boolean isSelectionDefinedGroup() {