X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FColourSchemes.java;h=e11540cea8ed7858e2c10344d341e4669cc7dca5;hb=4ba1c57b4ce0b3708b245633a109442dc88f586c;hp=c3d0ea0ba4aa2a8b827271210122eab4193f3a96;hpb=1d0f5219658cdf6ad5e1a1cbe6e1bb8cd12e6d85;p=jalview.git diff --git a/src/jalview/schemes/ColourSchemes.java b/src/jalview/schemes/ColourSchemes.java index c3d0ea0..e11540c 100644 --- a/src/jalview/schemes/ColourSchemes.java +++ b/src/jalview/schemes/ColourSchemes.java @@ -21,24 +21,19 @@ package jalview.schemes; import jalview.api.AlignViewportI; +import jalview.bin.ApplicationSingletonProvider; +import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; +import jalview.util.ColorUtils; +import java.awt.Color; import java.util.LinkedHashMap; import java.util.Map; -public class ColourSchemes +public class ColourSchemes implements ApplicationSingletonI { - /* - * singleton instance of this class - */ - private static ColourSchemes instance = new ColourSchemes(); - - /* - * a map from scheme name (lower-cased) to an instance of it - */ - private Map schemes; /** * Returns the singleton instance of this class @@ -47,7 +42,8 @@ public class ColourSchemes */ public static ColourSchemes getInstance() { - return instance; + return (ColourSchemes) ApplicationSingletonProvider + .getInstance(ColourSchemes.class); } private ColourSchemes() @@ -56,6 +52,51 @@ public class ColourSchemes } /** + * ColourSchemeProperty "static" + */ + public Color[] rnaHelices = null; + + /** + * delete the existing cached RNA helices colours + */ + public static void resetRnaHelicesShading() + { + getInstance().rnaHelices = null; + } + + public static void initRnaHelicesShading(int n) + { + int i = 0; + ColourSchemes j = getInstance(); + + if (j.rnaHelices == null) + { + j.rnaHelices = new Color[n + 1]; + } + else if (j.rnaHelices != null && j.rnaHelices.length <= n) + { + Color[] t = new Color[n + 1]; + System.arraycopy(j.rnaHelices, 0, t, 0, j.rnaHelices.length); + i = j.rnaHelices.length; + j.rnaHelices = t; + } + else + { + return; + } + // Generate random colors and store + for (; i <= n; i++) + { + j.rnaHelices[i] = ColorUtils.generateRandomColor(Color.white); + } + } + + /** + * a map from scheme name (lower-cased) to an instance of it + */ + private Map schemes; + + /** * Loads an instance of each standard or user-defined colour scheme * * @return @@ -146,7 +187,7 @@ public class ColourSchemes } ColourSchemeI cs = schemes.get(name.toLowerCase()); return cs == null ? null - : cs.getInstance(viewport, forData, hiddenRepSequences); + : cs.getInstance(viewport, forData); } /**