From 7fef0501bb64f11080bdb93ee0824416d84784cc Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Sat, 5 Sep 2015 10:24:36 +0100 Subject: [PATCH 1/1] JAL-1233 tidy up and use same RNA helix colours in colour by annotation and RNA helix colouring --- src/jalview/schemes/RNAHelicesColour.java | 35 ++++++++--------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/src/jalview/schemes/RNAHelicesColour.java b/src/jalview/schemes/RNAHelicesColour.java index 5518f8f..74cc803 100644 --- a/src/jalview/schemes/RNAHelicesColour.java +++ b/src/jalview/schemes/RNAHelicesColour.java @@ -40,16 +40,12 @@ import java.util.Map; public class RNAHelicesColour extends ResidueColourScheme { - /** - * Stores random colors generated for the number of helices - */ - public Hashtable helixcolorhash = new Hashtable(); /** * Maps sequence positions to the RNA helix they belong to. Key: position, - * Value: helix + * Value: helix TODO: Revise or drop in favour of annotation position numbers */ - public Hashtable positionsToHelix = new Hashtable(); + public Hashtable positionsToHelix = new Hashtable(); /** * Number of helices in the RNA secondary structure @@ -82,7 +78,6 @@ public class RNAHelicesColour extends ResidueColourScheme public RNAHelicesColour(RNAHelicesColour rnaHelicesColour) { super(ResidueProperties.nucleotideIndex); - helixcolorhash = rnaHelicesColour.helixcolorhash; annotation = rnaHelicesColour.annotation; refresh(); } @@ -123,7 +118,7 @@ public class RNAHelicesColour extends ResidueColourScheme annotation.getRNAStruc(); lastrefresh = annotation._rnasecstr.hashCode(); numHelix = 0; - positionsToHelix = new Hashtable(); + positionsToHelix = new Hashtable(); // Figure out number of helices // Length of rnasecstr is the number of pairs of positions that base pair @@ -150,16 +145,7 @@ public class RNAHelicesColour extends ResidueColourScheme } } - - // Generate random colors and store - for (int j = 0; j <= numHelix; j++) - { - if (!helixcolorhash.containsKey(Integer.toString(j))) - { - helixcolorhash.put(Integer.toString(j), - jalview.util.ColorUtils.generateRandomColor(Color.white)); - } - } + ColourSchemeProperty.initRnaHelicesShading(numHelix); } } @@ -186,7 +172,7 @@ public class RNAHelicesColour extends ResidueColourScheme * @param c * Character in sequence * @param j - * Threshold + * position in sequence - used to locate helix * * @return Color in RGB */ @@ -196,15 +182,12 @@ public class RNAHelicesColour extends ResidueColourScheme refresh(); Color currentColour = Color.white; String currentHelix = null; - currentHelix = (String) positionsToHelix.get(j); - + currentHelix = positionsToHelix.get(j); if (currentHelix != null) { - currentColour = (Color) helixcolorhash.get(currentHelix); + currentColour = ColourSchemeProperty.rnaHelices[Integer + .parseInt(currentHelix)]; } - - // System.out.println(c + " " + j + " helix " + currentHelix + " " + - // currentColour); return currentColour; } @@ -214,4 +197,4 @@ public class RNAHelicesColour extends ResidueColourScheme { return new RNAHelicesColour(this); } -} +} \ No newline at end of file -- 1.7.10.2