{
/**
- * compute the perceived colour for a given column position in sequenceI,
- * taking transparency and feature visibility into account.
+ * Returns the combined feature colour for a given sequence and column
+ * position, taking into account feature colour schemes, ordering, feature and
+ * feature group visibility, and transparency. Returns null if there is no
+ * visible feature at the position.
+ * <p>
+ * The Graphics argument is optional and may be null if no transparency is
+ * applied. With feature transparency, visible features are written to the
+ * graphics context and the composite colour can be read off.
+ * <p>
+ * This is provided for use by Structure Viewers and the Overview Window to
+ * get the feature colour of the rendered sequence.
*
- * @param sequenceI
- * - sequence providing features
- * @param r
- * - column position
+ * @param sequence
+ * @param column
* @param g
* @return
*/
- Color findFeatureColour(SequenceI sequenceI, int r, Graphics g);
+ Color findFeatureColour(SequenceI sequence, int column, Graphics g);
/**
* trigger the feature discovery process for a newly created feature renderer.
/*
* the FeatureSettings transparency slider has range 0-70 which
* corresponds to a transparency value of 1 - 0.3
+ * A value of 0.4 gives a combination of
+ * 0.4 * red(255, 0, 0) + 0.6 * cyan(0, 255, 255) = (102, 153, 153)
*/
- fr.setTransparency(0.5f);
- Color c = finder.findFeatureColour(Color.blue, seq, 10);
- assertEquals(c, new Color(85, 170, 0));
+ fr.setTransparency(0.4f);
+ Color c = finder.findFeatureColour(Color.cyan, seq, 10);
+ assertEquals(c, new Color(102, 153, 153));
}
@Test(groups = "Functional")
av.setShowSequenceFeatures(true);
/*
- * Domain (green(0, 255, 0)) rendered above Metal (red(255, 0, 0))
+ * Domain (green) rendered above Metal (red) above background (cyan)
+ * 1) 0.6 * red(255, 0, 0) + 0.4 * cyan(0, 255, 255) = (153, 102, 102)
+ * 2) 0.6* green(0, 255, 0) + 0.4 * (153, 102, 102) = (61, 194, 41) rounded
*/
- fr.setTransparency(0.5f);
- Color c = finder.findFeatureColour(Color.blue, seq, 10);
- assertEquals(c, new Color(85, 170, 0));
+ fr.setTransparency(0.6f);
+ Color c = finder.findFeatureColour(Color.cyan, seq, 10);
+ assertEquals(c, new Color(61, 194, 41));
/*
* now promote Metal above Domain
* - currently no way other than mimicking reordering of
* table in Feature Settings
+ * Metal (red) rendered above Domain (green) above background (cyan)
+ * 1) 0.6 * green(0, 255, 0) + 0.4 * cyan(0, 255, 255) = (0, 255, 102)
+ * 2) 0.6* red(255, 0, 0) + 0.4 * (0, 255, 102) = (153, 102, 41) rounded
*/
Object[][] data = new Object[2][];
data[0] = new Object[] { "Metal", red, true };
data[1] = new Object[] { "Domain", green, true };
fr.setFeaturePriority(data);
- c = finder.findFeatureColour(Color.blue, seq, 10);
- assertEquals(c, new Color(153, 102, 0));
+ c = finder.findFeatureColour(Color.cyan, seq, 10);
+ assertEquals(c, new Color(153, 102, 41));
/*
* ..and turn off display of Metal
+ * Domain (green) above background (pink)
+ * 0.6 * green(0, 255, 0) + 0.4 * pink(255, 175, 175) = (102, 223, 70)
*/
data[0][2] = false;
fr.setFeaturePriority(data);
- c = finder.findFeatureColour(Color.blue, seq, 10);
- assertEquals(c, Color.green);
+ c = finder.findFeatureColour(Color.pink, seq, 10);
+ assertEquals(c, new Color(102, 223, 70));
}
}