{
// TODO replace 8 or so code duplications with calls to this method
// (refactored as needed)
- return resColourFinder.getResidueColour(av.getResidueShading(),
+ return resColourFinder.getResidueColour(av.getShowBoxes(),
+ av.getResidueShading(),
allGroups, seq, position, finder);
}
public Color getResidueColour(final SequenceI seq, int position,
FeatureColourFinder finder)
{
- return resColourFinder.getResidueColour(av.getResidueShading(),
+ return resColourFinder.getResidueColour(av.getShowBoxes(),
+ av.getResidueShading(),
allGroups, seq, position,
finder);
}
if ((seq != null) && (seq.getLength() > lastcol))
{
- color = resColFinder.getResidueColour(shader, allGroups, seq, lastcol,
+ color = resColFinder.getResidueColour(true, shader, allGroups, seq,
+ lastcol,
fcfinder);
}
*/
package jalview.renderer;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.util.Comparison;
Color resBoxColour = Color.white;
char currentChar = seq.getCharAt(i);
+ // In the overview window, gaps are coloured grey, unless the colour scheme
+ // specifies a gap colour, in which case gaps honour the colour scheme
+ // settings
if (shader.getColourScheme() != null)
{
if (Comparison.isGap(currentChar)
return resBoxColour;
}
+
+ /**
+ * {@inheritDoc} In the overview, the showBoxes setting is ignored, as the
+ * overview displays the colours regardless.
+ */
+ @Override
+ protected Color getResidueBoxColour(boolean showBoxes,
+ ResidueShaderI shader,
+ SequenceGroup[] allGroups, SequenceI seq, int i)
+ {
+ ResidueShaderI currentShader;
+ SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
+ i);
+ if (currentSequenceGroup != null)
+ {
+ currentShader = currentSequenceGroup.getGroupColourScheme();
+ }
+ else
+ {
+ currentShader = shader;
+ }
+
+ return getBoxColour(currentShader, seq, i);
+ }
}
{
}
- public Color getResidueColour(ResidueShaderI shader,
+ /**
+ * Get the colour of a residue in a sequence
+ *
+ * @param showBoxes
+ * true if the viewport's Show Boxes setting is true
+ * @param shader
+ * the viewport's colour scheme
+ * @param allGroups
+ * all the groups which seq participates in
+ * @param seq
+ * the sequence containing the residue
+ * @param position
+ * the position of the residue in the sequence
+ * @param finder
+ * FeatureColourFinder for the viewport
+ * @return colour of the residue
+ */
+ public Color getResidueColour(boolean showBoxes, ResidueShaderI shader,
SequenceGroup[] allGroups,
final SequenceI seq, int position, FeatureColourFinder finder)
{
- Color col = getResidueBoxColour(shader, allGroups, seq, position);
+ Color col = getResidueBoxColour(showBoxes, shader, allGroups, seq,
+ position);
+ // if there's a FeatureColourFinder we might override the residue colour
+ // here with feature colouring
if (finder != null)
{
col = finder.findFeatureColour(col, seq, position);
return col;
}
- private Color getResidueBoxColour(ResidueShaderI shader,
+ /**
+ * Get the residue colour without accounting for any features
+ *
+ * @param showBoxes
+ * true if the viewport's Show Boxes setting is true
+ * @param shader
+ * the viewport's colour scheme
+ * @param allGroups
+ * all the groups which seq participates in
+ * @param seq
+ * the sequence containing the residue
+ * @param i
+ * the position of the residue in the sequence
+ * @return
+ */
+ protected Color getResidueBoxColour(boolean showBoxes,
+ ResidueShaderI shader,
SequenceGroup[] allGroups,
SequenceI seq, int i)
{
-
- ResidueShaderI currentShader;
-
SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
i);
if (currentSequenceGroup != null)
{
- currentShader = currentSequenceGroup.getGroupColourScheme();
+ if (currentSequenceGroup.getDisplayBoxes())
+ {
+ return getBoxColour(currentSequenceGroup.getGroupColourScheme(),
+ seq, i);
+ }
}
- else
+ else if (showBoxes)
{
- currentShader = shader;
+ return getBoxColour(shader, seq, i);
}
-
- return getBoxColour(currentShader, seq, i);
+
+ return Color.white;
}
+ /**
+ * Search all the groups for a sequence to find the one which a given res
+ * falls into
+ *
+ * @param allGroups
+ * all the groups a sequence participates in
+ * @param res
+ * the residue to search for
+ * @return a sequence group for res, or null if no sequence group applies
+ */
public SequenceGroup getCurrentSequenceGroup(SequenceGroup[] allGroups,
int res)
{
* DOCUMENT ME!
*
* @param shader
- * DOCUMENT ME!
+ * the viewport's colour scheme
* @param seq
- * DOCUMENT ME!
+ * the sequence containing the residue
* @param i
- * DOCUMENT ME!
+ * the position of the residue in the sequence
*/
public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
{
ResidueColourFinder rcf = new OverviewResColourFinder();
// gaps are grey, residues white
- assertEquals(Color.white, rcf.getResidueColour(av.getResidueShading(),
+ assertEquals(Color.white, rcf.getResidueColour(true,
+ av.getResidueShading(),
null, seq, 0, null));
assertEquals(Color.lightGray, rcf
- .getResidueColour(av.getResidueShading(), null, seq, 2, null));
+ .getResidueColour(true, av.getResidueShading(), null, seq, 2,
+ null));
+
+ // unaffected by showBoxes setting
+ assertEquals(Color.white, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 0, null));
+ assertEquals(Color.lightGray, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 2, null));
}
@Test(groups = { "Functional" })
av.setGlobalColourScheme(new ZappoColourScheme());
// @see ResidueProperties.zappo
- assertEquals(Color.pink, rcf.getResidueColour(av.getResidueShading(),
+ assertEquals(Color.pink,
+ rcf.getResidueColour(true, av.getResidueShading(),
null, seq, 0, null)); // M
- assertEquals(Color.green, rcf.getResidueColour(av.getResidueShading(),
+ assertEquals(Color.green,
+ rcf.getResidueColour(true, av.getResidueShading(),
null, seq, 2, null)); // T
- assertEquals(Color.magenta, rcf.getResidueColour(av.getResidueShading(),
+ assertEquals(Color.magenta,
+ rcf.getResidueColour(true, av.getResidueShading(),
null, seq, 5, null)); // G
- assertEquals(Color.orange, rcf.getResidueColour(av.getResidueShading(),
+ assertEquals(Color.orange,
+ rcf.getResidueColour(true, av.getResidueShading(),
null, seq, 12, null)); // F
// gap colour not specified so gaps are lightGray
assertEquals(Color.lightGray, rcf
- .getResidueColour(av.getResidueShading(), null, seq, 3, null));
+ .getResidueColour(true, av.getResidueShading(), null, seq, 3,
+ null));
+
+ // unaffected by showBoxes setting
+ assertEquals(Color.pink, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 0, null)); // M
+ assertEquals(Color.green, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 2, null)); // T
+ assertEquals(Color.magenta, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 5, null)); // G
+ assertEquals(Color.orange, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 12, null)); // F
// gap colour not specified so gaps are lightGray
assertEquals(Color.lightGray, rcf
- .getResidueColour(av.getResidueShading(), null, seq, 3, null));
+ .getResidueColour(false, av.getResidueShading(), null, seq, 3,
+ null));
}
// gap colour not specified so gaps are lightGray
assertEquals(Color.lightGray, rcf
- .getResidueColour(av.getResidueShading(), null, seq, 3, null));
+ .getResidueColour(true, av.getResidueShading(), null, seq, 3,
+ null));
newColours[23] = Color.pink;
av.setGlobalColourScheme(new UserColourScheme(newColours));
// gap colour specified as pink
- assertEquals(Color.pink, rcf.getResidueColour(av.getResidueShading(),
+ assertEquals(Color.pink, rcf.getResidueColour(true,
+ av.getResidueShading(),
null, seq, 3, null));
+
+ // unaffected by showBoxes setting
+ // gap colour not specified so gaps are lightGray
+ newColours[23] = null;
+ assertEquals(Color.lightGray, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 3, null));
+
+ newColours[23] = Color.pink;
+ av.setGlobalColourScheme(new UserColourScheme(newColours));
+
+ // gap colour specified as pink
+ assertEquals(Color.pink, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 3, null));
}
}
// @see ResidueProperties.zappo
assertEquals(Color.pink,
- rcf.getResidueColour(av.getResidueShading(), null, seq, 0,
+ rcf.getResidueColour(true, av.getResidueShading(), null, seq, 0,
null)); // M
assertEquals(Color.green,
- rcf.getResidueColour(av.getResidueShading(), null, seq, 2,
+ rcf.getResidueColour(true, av.getResidueShading(), null, seq, 2,
null)); // T
assertEquals(Color.magenta,
- rcf.getResidueColour(av.getResidueShading(), null, seq, 5,
+ rcf.getResidueColour(true, av.getResidueShading(), null, seq, 5,
null)); // G
assertEquals(Color.orange,
- rcf.getResidueColour(av.getResidueShading(), null, seq, 12,
+ rcf.getResidueColour(true, av.getResidueShading(), null, seq,
+ 12,
null)); // F
+
+ // everything is white if showBoxes is false
+ assertEquals(Color.white, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 0, null)); // M
+ assertEquals(Color.white, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 2, null)); // T
+ assertEquals(Color.white, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 5, null)); // G
+ assertEquals(Color.white, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 12, null)); // F
}
@Test(groups = { "Functional" })
final AlignViewport av = new AlignViewport(al);
ResidueColourFinder rcf = new ResidueColourFinder();
- assertEquals(Color.white, rcf.getResidueColour(av.getResidueShading(),
+ assertEquals(Color.white,
+ rcf.getResidueColour(true, av.getResidueShading(),
null, seq, 0, null));
- assertEquals(Color.white, rcf.getResidueColour(av.getResidueShading(),
+ assertEquals(Color.white,
+ rcf.getResidueColour(true, av.getResidueShading(),
null, seq, 2, null));
+
+ // no change if showBoxes is false
+ assertEquals(Color.white, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 0, null));
+ assertEquals(Color.white, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 2, null));
}
@Test(groups = { "Functional" })
// gap colour not specified so gap colour is null
// this is consistent with previous behaviour, but may not be correct?
- assertEquals(null, rcf.getResidueColour(av.getResidueShading(),
+ assertEquals(null, rcf.getResidueColour(true, av.getResidueShading(),
null, seq, 3, null));
newColours[23] = Color.pink;
av.setGlobalColourScheme(new UserColourScheme(newColours));
// gap colour specified as pink
- assertEquals(Color.pink, rcf.getResidueColour(av.getResidueShading(),
+ assertEquals(Color.pink, rcf.getResidueColour(true,
+ av.getResidueShading(),
+ null, seq, 3, null));
+
+ // everything is white if showBoxes is false
+ newColours[23] = null;
+ assertEquals(Color.white, rcf.getResidueColour(false,
+ av.getResidueShading(),
null, seq, 3, null));
- }
- // TODO more tests for getResidueColour covering groups, feature rendering,
- // gaps, overview...
+ newColours[23] = Color.pink;
+ av.setGlobalColourScheme(new UserColourScheme(newColours));
+
+ // gap colour specified as pink
+ assertEquals(Color.white, rcf.getResidueColour(false,
+ av.getResidueShading(), null, seq, 3, null));
+ }
+ // TODO more tests for getResidueColour covering groups, feature rendering...
}