From 93661ff97ede19d69fde4e2d15f12a7e8963f084 Mon Sep 17 00:00:00 2001 From: kiramt Date: Wed, 28 Jun 2017 10:55:50 +0100 Subject: [PATCH] JAL-2588 Gap colour scheme now shown in overview --- src/jalview/gui/SequenceRenderer.java | 3 ++- src/jalview/schemes/ColourSchemeI.java | 7 +++++++ src/jalview/schemes/ResidueColourScheme.java | 10 ++++++++++ src/jalview/schemes/UserColourScheme.java | 10 ++++++++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index 51b1a3a..7a1e263 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -140,7 +140,8 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer { if (shader.getColourScheme() != null) { - if (forOverview && Comparison.isGap(seq.getCharAt(i))) + if (forOverview && Comparison.isGap(seq.getCharAt(i)) + && !shader.getColourScheme().hasGapColour()) { resBoxColour = Color.lightGray; } diff --git a/src/jalview/schemes/ColourSchemeI.java b/src/jalview/schemes/ColourSchemeI.java index f16ca21..d70b4e2 100755 --- a/src/jalview/schemes/ColourSchemeI.java +++ b/src/jalview/schemes/ColourSchemeI.java @@ -98,4 +98,11 @@ public interface ColourSchemeI * @return */ boolean isSimple(); + + /** + * Answers true if the colour scheme has a colour specified for gaps. + * + * @return + */ + boolean hasGapColour(); } diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index b47b82e..3e8daf9 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -200,4 +200,14 @@ public abstract class ResidueColourScheme implements ColourSchemeI { return true; } + + /** + * Default method returns false. Override this to return true in colour + * schemes that have a colour associated with gap residues. + */ + @Override + public boolean hasGapColour() + { + return false; + } } diff --git a/src/jalview/schemes/UserColourScheme.java b/src/jalview/schemes/UserColourScheme.java index 8e58c20..d83e9c2 100755 --- a/src/jalview/schemes/UserColourScheme.java +++ b/src/jalview/schemes/UserColourScheme.java @@ -286,7 +286,7 @@ public class UserColourScheme extends ResidueColourScheme /* * step 1: build a map from colours to the symbol(s) that have the colour */ - Map> colours = new HashMap>(); + Map> colours = new HashMap<>(); for (char symbol = 'A'; symbol <= 'Z'; symbol++) { @@ -319,7 +319,7 @@ public class UserColourScheme extends ResidueColourScheme /* * step 2: make a list of { A,G,R=12f9d6 } residues/colour specs */ - List residueColours = new ArrayList(); + List residueColours = new ArrayList<>(); for (Entry> cols : colours.entrySet()) { boolean first = true; @@ -349,4 +349,10 @@ public class UserColourScheme extends ResidueColourScheme Collections.sort(residueColours); return StringUtils.listToDelimitedString(residueColours, ";"); } + + @Override + public boolean hasGapColour() + { + return (findColour(' ') != null); + } } -- 1.7.10.2