X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FUserColourScheme.java;h=d77f2f53d4d663e1e0ead2b883960d688f4dea72;hb=b160d9b1aecc3fc3d6583189a045a986ecf8f18a;hp=218c285c90686c6deaf227da0a45dc4a9694b29b;hpb=8e2d11189e14700f721dc0cf17c462352883ef97;p=jalview.git diff --git a/src/jalview/schemes/UserColourScheme.java b/src/jalview/schemes/UserColourScheme.java index 218c285..d77f2f5 100755 --- a/src/jalview/schemes/UserColourScheme.java +++ b/src/jalview/schemes/UserColourScheme.java @@ -20,9 +20,8 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; -import jalview.datamodel.SequenceCollectionI; -import jalview.datamodel.SequenceI; import jalview.util.ColorUtils; import jalview.util.StringUtils; @@ -56,18 +55,27 @@ public class UserColourScheme extends ResidueColourScheme } @Override - public ColourSchemeI applyTo(AnnotatedCollectionI sg, - Map hiddenRepSequences) + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI sg) { - UserColourScheme usc = new UserColourScheme(colors); - if (lowerCaseColours != null) + return new UserColourScheme(this); + } + + /** + * Copy constructor + * + * @return + */ + protected UserColourScheme(UserColourScheme from) + { + this(from.colors); + schemeName = from.schemeName; + if (from.lowerCaseColours != null) { - usc.schemeName = schemeName; - usc.lowerCaseColours = new Color[lowerCaseColours.length]; - System.arraycopy(lowerCaseColours, 0, usc.lowerCaseColours, 0, - lowerCaseColours.length); + lowerCaseColours = new Color[from.lowerCaseColours.length]; + System.arraycopy(from.lowerCaseColours, 0, lowerCaseColours, 0, + from.lowerCaseColours.length); } - return usc; } /** @@ -213,7 +221,8 @@ public class UserColourScheme extends ResidueColourScheme { lowerCaseColours = new Color[colors.length]; } - lowerCaseColours[colIndex] = ColorUtils.parseColourString(colour); + lowerCaseColours[colIndex] = ColorUtils + .parseColourString(colour); } else { @@ -223,40 +232,10 @@ public class UserColourScheme extends ResidueColourScheme } } catch (Exception ex) { - System.out.println("Error parsing userDefinedColours:\n" + token - + "\n" + ex); - } - - } - - @Override - public Color findColour(char c, int j, SequenceI seq) - { - Color currentColour; - int index = ResidueProperties.aaIndex[c]; - - if ((threshold == 0) || aboveThreshold(c, j)) - { - if (lowerCaseColours != null && 'a' <= c && c <= 'z') - { - currentColour = lowerCaseColours[index]; - } - else - { - currentColour = colors[index]; - } - } - else - { - currentColour = Color.white; + System.out.println( + "Error parsing userDefinedColours:\n" + token + "\n" + ex); } - if (conservationColouring) - { - currentColour = applyConservation(currentColour, j); - } - - return currentColour; } public void setLowerCaseColours(Color[] lcolours) @@ -284,8 +263,8 @@ public class UserColourScheme extends ResidueColourScheme } /** - * Answers the customised name of the colour scheme, if it has one, else - * "User Defined" + * Answers the customised name of the colour scheme, if it has one, else "User + * Defined" */ @Override public String getSchemeName() @@ -294,7 +273,7 @@ public class UserColourScheme extends ResidueColourScheme { return schemeName; } - return JalviewColourScheme.UserDefined.toString(); + return ResidueColourScheme.USER_DEFINED; } /** @@ -307,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++) { @@ -340,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; @@ -370,4 +349,10 @@ public class UserColourScheme extends ResidueColourScheme Collections.sort(residueColours); return StringUtils.listToDelimitedString(residueColours, ";"); } + + @Override + public boolean hasGapColour() + { + return (findColour(' ') != null); + } }