From 879293251d1072b24403df2f4bf3ac6a69d4a012 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 24 Nov 2014 16:07:45 +0000 Subject: [PATCH] JAL-1593 refactor rna helix colours to static singleton for consistent shading --- src/jalview/schemes/AnnotationColourGradient.java | 33 ++------------------- src/jalview/schemes/ColourSchemeProperty.java | 29 ++++++++++++++++++ 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index ef77e4d..3cada8b 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -53,33 +53,6 @@ public class AnnotationColourGradient extends FollowerColourScheme private boolean predefinedColours = false; private boolean seqAssociated = false; - Color rnaHelices[] = null; - private void initRnaHelicesShading(int n) - { - int j = 0; - if (rnaHelices==null) - { - rnaHelices = new Color[n + 1]; - } - else - if (rnaHelices != null && rnaHelices.length <= n) - { - Color[] t = new Color[n + 1]; - System.arraycopy(rnaHelices, 0, t, 0, rnaHelices.length); - j = rnaHelices.length; - rnaHelices = t; - } - else - { - return; - } - // Generate random colors and store - for (; j <= n; j++) - { - rnaHelices[j] = jalview.util.ColorUtils - .generateRandomColor(Color.white); - } - } /** * false if the scheme was constructed without a minColour and maxColour used * to decide if existing colours should be taken from annotation elements when @@ -171,7 +144,7 @@ public class AnnotationColourGradient extends FollowerColourScheme aamin = annotation.graphMin; if (annotation.isRNA()) { - initRnaHelicesShading(1 + (int) aamax); + ColourSchemeProperty.initRnaHelicesShading(1 + (int) aamax); } } @@ -220,7 +193,7 @@ public class AnnotationColourGradient extends FollowerColourScheme } if (rna) { - initRnaHelicesShading(1 + (int) aamax); + ColourSchemeProperty.initRnaHelicesShading(1 + (int) aamax); } } } @@ -331,7 +304,7 @@ public class AnnotationColourGradient extends FollowerColourScheme { if (annotation.isRNA()) { - currentColour = rnaHelices[(int) aj.value]; + currentColour = ColourSchemeProperty.rnaHelices[(int) aj.value]; } else { diff --git a/src/jalview/schemes/ColourSchemeProperty.java b/src/jalview/schemes/ColourSchemeProperty.java index cc303d6..57a2dd9 100755 --- a/src/jalview/schemes/ColourSchemeProperty.java +++ b/src/jalview/schemes/ColourSchemeProperty.java @@ -597,4 +597,33 @@ public class ColourSchemeProperty return col; } + + public static Color rnaHelices[] = null; + + public static void initRnaHelicesShading(int n) + { + int j = 0; + if (rnaHelices == null) + { + rnaHelices = new Color[n + 1]; + } + else if (rnaHelices != null && rnaHelices.length <= n) + { + Color[] t = new Color[n + 1]; + System.arraycopy(rnaHelices, 0, t, 0, rnaHelices.length); + j = rnaHelices.length; + rnaHelices = t; + } + else + { + return; + } + // Generate random colors and store + for (; j <= n; j++) + { + rnaHelices[j] = jalview.util.ColorUtils + .generateRandomColor(Color.white); + } + } + } -- 1.7.10.2