import static org.testng.AssertJUnit.assertEquals;
+import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignViewport;
import jalview.gui.JvOptionPane;
+import jalview.gui.Preferences;
import jalview.schemes.UserColourScheme;
import jalview.schemes.ZappoColourScheme;
assertEquals(Color.pink, rcf.getResidueColour(false,
av.getResidueShading(), null, seq, 3, null));
}
+
+ @Test
+ public void testGetBoxColour()
+ {
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
+
+ SequenceI seq = new Sequence("name", "MAT--GSPRAPAFF"); // FER1_MAIZE... + a
+ // gap
+ AlignmentI al = new Alignment(new SequenceI[] { seq });
+ final AlignViewport av = new AlignViewport(al);
+
+ // non-legacy colouring
+ ResidueColourFinder rcf = new OverviewResColourFinder();
+ ResidueShaderI shader = new ResidueShader();
+
+ // residues white
+ Color c = rcf.getBoxColour(shader, seq, 0);
+ assertEquals(Color.white, c);
+
+ // gaps gap colour
+ c = rcf.getBoxColour(shader, seq, 3);
+ assertEquals(Preferences.OVERVIEW_DEFAULT_GAP, c);
+
+ // legacy colouring set explicitly via constructor
+ rcf = new OverviewResColourFinder(true, Color.blue, Color.red);
+ shader = new ResidueShader();
+
+ // residues light gray
+ c = rcf.getBoxColour(shader, seq, 0);
+ assertEquals(Color.lightGray, c);
+
+ // gaps white
+ c = rcf.getBoxColour(shader, seq, 3);
+ assertEquals(Color.white, c);
+
+ // legacy colouring off
+ rcf = new OverviewResColourFinder();
+ shader = new ResidueShader();
+
+ // residues white
+ c = rcf.getBoxColour(shader, seq, 0);
+ assertEquals(Color.white, c);
+
+ // gaps gap colour
+ c = rcf.getBoxColour(shader, seq, 3);
+ assertEquals(Preferences.OVERVIEW_DEFAULT_GAP, c);
+
+ // non legacy colouring with colour scheme
+ rcf = new OverviewResColourFinder(false, Color.blue, Color.red);
+ shader = new ResidueShader(new ZappoColourScheme());
+
+ // M residue pink
+ c = rcf.getBoxColour(shader, seq, 0);
+ assertEquals(Color.pink, c);
+
+ // gaps blue
+ c = rcf.getBoxColour(shader, seq, 3);
+ assertEquals(Color.blue, c);
+
+ // legacy colouring with colour scheme
+ rcf = new OverviewResColourFinder(true, Color.blue, Color.red);
+
+ // M residue pink
+ c = rcf.getBoxColour(shader, seq, 0);
+ assertEquals(Color.pink, c);
+
+ // gaps white
+ c = rcf.getBoxColour(shader, seq, 3);
+ assertEquals(Color.white, c);
+ }
}