From cafaf4610c39cac8347bde424e6d9984c3959a51 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Sun, 23 Jun 2013 19:02:20 +0100 Subject: [PATCH] JAL-1230 simplify initialisation of consensus, conservation and structure consensus rows --- src/jalview/viewmodel/AlignmentViewport.java | 111 +++++++++++++++----------- 1 file changed, 65 insertions(+), 46 deletions(-) diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 029280b..d65486d 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -402,7 +402,8 @@ public abstract class AlignmentViewport implements AlignViewportI if (autoCalculateStrucConsensus && strucConsensus == null && alignment.isNucleotide() && alignment.hasRNAStructure()) { - + // secondary structure has been added - so init the consensus line + initRNAStructure(); } // see note in mantis : issue number 8585 @@ -1318,62 +1319,80 @@ public abstract class AlignmentViewport implements AlignViewportI { if (!alignment.isNucleotide()) { - 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 (showQuality) - { - 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); - } - } + initConservation(); + initQuality(); } else { - if (alignment.hasRNAStructure()) - { - strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID", - new Annotation[1], 0f, 100f, - AlignmentAnnotation.BAR_GRAPH); - strucConsensus.hasText = true; - strucConsensus.autoCalculated = true; - } + initRNAStructure(); } + initConsensus(); + } + } - consensus = new AlignmentAnnotation("Consensus", "PID", - new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); - consensus.hasText = true; - consensus.autoCalculated = true; + private void initConsensus() + { - if (showConsensus) + consensus = new AlignmentAnnotation("Consensus", "PID", + new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); + consensus.hasText = true; + consensus.autoCalculated = true; + + if (showConsensus) + { + alignment.addAnnotation(consensus); + } + } + + private void initConservation() + { + if (showConservation) + { + if (conservation == null) { - alignment.addAnnotation(consensus); - if (strucConsensus != null) - { - alignment.addAnnotation(strucConsensus); - } + 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); + } + } + } + private void initQuality() + { + if (showQuality) + { + 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); } } } + private void initRNAStructure() + { + if (alignment.hasRNAStructure() && strucConsensus==null) + { + strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID", + new Annotation[1], 0f, 100f, + AlignmentAnnotation.BAR_GRAPH); + strucConsensus.hasText = true; + strucConsensus.autoCalculated = true; + if (showConsensus) + { + alignment.addAnnotation(strucConsensus); + } + } + } /* * (non-Javadoc) * -- 1.7.10.2