if (colour != null)
{
- globalColourScheme = ColourSchemeProperty.getColour(alignment,
- colour);
+ globalColourScheme = ColourSchemeProperty.getColourScheme(
+ alignment, colour);
if (globalColourScheme != null)
{
globalColourScheme.setConsensus(hconsensus);
}
else
{
- cs = ColourSchemeProperty.getColour(sg,
+ cs = ColourSchemeProperty.getColourScheme(sg,
ColourSchemeProperty.getColourName(av
.getGlobalColourScheme()));
}
{
data.replaceAll("%20", " ");
- ColourSchemeI cs = ColourSchemeProperty.getColour(af
+ ColourSchemeI cs = ColourSchemeProperty.getColourScheme(af
.getViewport().getAlignment(), data);
if (cs == null)
}
if (propertyValue != null)
{
- globalColourScheme = ColourSchemeProperty.getColour(alignment,
+ globalColourScheme = ColourSchemeProperty.getColourScheme(alignment,
propertyValue);
if (globalColourScheme instanceof UserColourScheme)
}
else
{
- cs = ColourSchemeProperty.getColour(al, jGroup.getColour());
+ cs = ColourSchemeProperty.getColourScheme(al, jGroup.getColour());
}
if (cs != null)
}
else
{
- cs = ColourSchemeProperty.getColour(al, view.getBgColour());
+ cs = ColourSchemeProperty.getColourScheme(al, view.getBgColour());
}
if (cs != null)
{
cs = new AnnotationColourGradient(
annAlignment.getAlignmentAnnotation()[i],
- ColourSchemeProperty.getColour(al,
+ ColourSchemeProperty.getColourScheme(al,
viewAnnColour.getColourScheme()),
viewAnnColour.getAboveThreshold());
}
}
else
{
- cs = ColourSchemeProperty.getColour(al, groups[i].getColour());
+ cs = ColourSchemeProperty.getColourScheme(al, groups[i].getColour());
}
if (cs != null)
}
else
{
- cs = ColourSchemeProperty.getColour(al, view.getBgColour());
+ cs = ColourSchemeProperty.getColourScheme(al, view.getBgColour());
}
if (cs != null)
}
else
{
- cs = ColourSchemeProperty.getColour(sg,
+ cs = ColourSchemeProperty.getColourScheme(sg,
ColourSchemeProperty.getColourName(av
.getGlobalColourScheme()));
}
}
else if (key.equalsIgnoreCase("colour"))
{
- sg.cs = ColourSchemeProperty.getColour(al, value);
+ sg.cs = ColourSchemeProperty.getColourScheme(al, value);
}
else if (key.equalsIgnoreCase("pidThreshold"))
{
/**
* Returns a colour scheme for the given name, with which the given data may
- * be coloured. The name may be one of
+ * be coloured. The name is not case-sensitive, and may be one of
* <ul>
* <li>Clustal</li>
* <li>Blosum62</li>
* <li>T-Coffee Scores</li>
* <li>RNA Helices</li>
* <li>User Defined</li>
- * <li>None</li>
* <li>an AWT colour name e.g. red</li>
* <li>residue colours list e.g. D,E=red;K,R,H=0022FF;c=yellow</li>
* </ul>
* If none of these formats is matched, the string is converted to a colour
- * using a hashing algorithm.
+ * using a hashing algorithm. For name "None", returns null.
*
* @param forData
* @param name
* @return
*/
- public static ColourSchemeI getColour(AnnotatedCollectionI forData,
+ public static ColourSchemeI getColourScheme(AnnotatedCollectionI forData,
String name)
{
+ if (ResidueColourScheme.NONE.equalsIgnoreCase(name))
+ {
+ return null;
+
+ }
JalviewColourScheme scheme = JalviewColourScheme.forName(name);
if (scheme != null)
{
- // note JalviewColourScheme.None returns null here
return scheme.getColourScheme(forData);
}
assertSame("Didn't set T-coffee colourscheme", af.getViewport()
.getGlobalColourScheme().getClass(), TCoffeeColourScheme.class);
assertNotNull("Recognise T-Coffee score from string",
- ColourSchemeProperty.getColour(af.getViewport()
+ ColourSchemeProperty.getColourScheme(af.getViewport()
.getAlignment(), af.getViewport()
.getGlobalColourScheme().getSchemeName()));
package jalview.schemes;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
assertEquals(ColourSchemeProperty.getColourName(null), "None");
}
+
+ @Test
+ public void testGetColourScheme()
+ {
+ SequenceI seq = new Sequence("Seq1", "abcd");
+ AlignmentI al = new Alignment(new SequenceI[] { seq });
+ // the strings here correspond to JalviewColourScheme.toString() values
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "Clustal") instanceof ClustalxColourScheme);
+ // not case-sensitive
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "CLUSTAL") instanceof ClustalxColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "clustal") instanceof ClustalxColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "Blosum62") instanceof Blosum62ColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "% Identity") instanceof PIDColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "Zappo") instanceof ZappoColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "Taylor") instanceof TaylorColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "Hydrophobic") instanceof HydrophobicColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "Helix Propensity") instanceof HelixColourScheme);
+ assertTrue(ColourSchemeProperty
+ .getColourScheme(al, "Strand Propensity") instanceof StrandColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "Turn Propensity") instanceof TurnColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "Buried Index") instanceof BuriedColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "Nucleotide") instanceof NucleotideColourScheme);
+ assertTrue(ColourSchemeProperty
+ .getColourScheme(al, "Purine/Pyrimidine") instanceof PurinePyrimidineColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "T-Coffee Scores") instanceof TCoffeeColourScheme);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "RNA Helices") instanceof RNAHelicesColour);
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "User Defined") instanceof UserColourScheme);
+ // 'None' is a special value
+ assertNull(ColourSchemeProperty.getColourScheme(al, "None"));
+ assertNull(ColourSchemeProperty.getColourScheme(al, "none"));
+ // default is to convert the name into a fixed coloour
+ assertTrue(ColourSchemeProperty.getColourScheme(al, "elephants") instanceof UserColourScheme);
+ }
}