X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fschemes%2FResidueColourScheme.java;h=f6b7c5e16e31cd3da8f34f14597aa751cb071c90;hb=6a39c322e12aa5b9a14e240e19df8d6be814e594;hp=56c573c8f792ba1ff397d32b8718a87ae7777fd0;hpb=179dd7c29198cb2f0e9eee5802e6ab27bb6de4f4;p=jalview.git diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index 56c573c..f6b7c5e 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -21,10 +21,12 @@ package jalview.schemes; import jalview.analysis.Conservation; -import jalview.analysis.Profile; import jalview.datamodel.AnnotatedCollectionI; +import jalview.datamodel.ProfileI; +import jalview.datamodel.ProfilesI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; +import jalview.util.ColorUtils; import jalview.util.Comparison; import jalview.util.MessageManager; @@ -53,7 +55,7 @@ public class ResidueColourScheme implements ColourSchemeI /* * Consensus data indexed by column */ - Profile[] consensus; + ProfilesI consensus; /* * Conservation string as a char array @@ -181,19 +183,20 @@ public class ResidueColourScheme implements ColourSchemeI residue -= ('a' - 'A'); } - if (consensus == null || consensus.length < column - || consensus[column] == null) + if (consensus == null) { return false; } + ProfileI profile = consensus.get(column); + /* * test whether this is the consensus (or joint consensus) residue */ - if (consensus[column].getModalResidue().contains( - String.valueOf(residue))) + if (profile != null + && profile.getModalResidue().contains(String.valueOf(residue))) { - if (consensus[column].getPercentageIdentity(ignoreGaps) >= threshold) + if (profile.getPercentageIdentity(ignoreGaps) >= threshold) { return true; } @@ -233,7 +236,7 @@ public class ResidueColourScheme implements ColourSchemeI * DOCUMENT ME! */ @Override - public void setConsensus(Profile[] consensus) + public void setConsensus(ProfilesI consensus) { if (consensus == null) { @@ -311,33 +314,13 @@ public class ResidueColourScheme implements ColourSchemeI float bleachFactor = (11 - (conservationScore - '0')) / 10f; /* - * scale this by the percentage slider / 20 - */ - bleachFactor *= (inc / 20f); - - int red = currentColour.getRed(); - int green = currentColour.getGreen(); - int blue = currentColour.getBlue(); - - /* - * bleach colours towards white (255, 255, 255), - * depending on the consensus score and the conservation slider value - * scores of: 0 1 2 3 4 5 6 7 8 9 + * scale this up by 0-5 (percentage slider / 20) + * as a result, scores of: 0 1 2 3 4 5 6 7 8 9 * fade to white at slider value: 18 20 22 25 29 33 40 50 67 100% */ - red += (255 - red) * bleachFactor; - green += (255 - green) * bleachFactor; - blue += (255 - blue) * bleachFactor; + bleachFactor *= (inc / 20f); - if (red > 255 || green > 255 || blue > 255) - { - currentColour = Color.white; - } - else - { - currentColour = new Color(red, green, blue); - } - return currentColour; + return ColorUtils.bleachColour(currentColour, bleachFactor); } @Override