/**
* Constructor
*
+ * @param name
* @param symbolIndex
* a lookup where the index is a char e.g. 'R' or 'r', and the value
* is its position in the colour table lookup
- * @param scores
+ * @param theScores
* per residue, with indices corresponding to those for colour lookup
+ * @param minColour
+ * graduated colour at minimum score value
+ * @param maxColour
+ * graduated colour at maximum score value
*/
- public ScoreColourScheme(String name, int[] symbolIndex, double[] scores,
+ public ScoreColourScheme(String name, int[] symbolIndex, double[] theScores,
Color minColour, Color maxColour)
{
super(symbolIndex);
this.minColour = minColour;
this.maxColour = maxColour;
- setMinMax(scores);
- this.scores = scores;
+ setMinMax(theScores);
+ computeColours(theScores);
+ }
+
+ /**
+ * Calculates and saves a graduated score based colour for each residue
+ *
+ * @param theScores
+ */
+ protected void computeColours(double[] theScores)
+ {
+ this.scores = theScores;
- int iSize = scores.length;
- colors = new Color[scores.length];
+ int iSize = theScores.length;
+ colors = new Color[theScores.length];
for (int i = 0; i < iSize; i++)
{
- colors[i] = getScoreColour(scores[i]);
+ colors[i] = getScoreColour(theScores[i]);
}
}
double dMin = Double.MAX_VALUE;
double dMax = -Double.MAX_VALUE;
- for (int i = 0; i < vals.length - 1; i++)
+ for (int i = 0; i < vals.length; i++)
{
dMin = Math.min(dMin, vals[i]);
dMax = Math.max(dMax, vals[i]);