import java.awt.Color;
/**
- * DOCUMENT ME!
- *
- * @author $author$
- * @version $Revision$
+ * A base class for colour schemes which define a graduated colour range based
+ * on
+ * <ul>
+ * <li>a minimum colour</li>
+ * <li>a maximum colour</li>
+ * <li>a score assigned to each residue</li>
+ * </ul>
*/
public class ScoreColourScheme extends ResidueColourScheme
{
public double[] scores;
/**
- * Creates a new ScoreColourScheme object.
+ * Constructor
*
+ * @param symbolIndex
+ * a lookup where the index is a character e.g. 'R' or 'r', and the
+ * value is its position in the colour table lookup
* @param scores
- * DOCUMENT ME!
- * @param min
- * DOCUMENT ME!
- * @param max
- * DOCUMENT ME!
+ * per residue, indices matching colors lookup
*/
- public ScoreColourScheme(int symbolIndex[], double[] scores, double min,
- double max)
+ public ScoreColourScheme(int symbolIndex[], double[] scores)
{
super(symbolIndex);
-
+ setMinMax(scores);
this.scores = scores;
- this.min = min;
- this.max = max;
// Make colours in constructor
// Why wasn't this done earlier?
}
}
+ /**
+ * Inspects score values and saves the minimum and maximum
+ *
+ * @param vals
+ */
+ void setMinMax(double[] vals)
+ {
+ double dMin = Double.MAX_VALUE;
+ double dMax = -Double.MAX_VALUE;
+
+ for (int i = 0; i < vals.length - 1; i++)
+ {
+ dMin = Math.min(dMin, vals[i]);
+ dMax = Math.max(dMax, vals[i]);
+ }
+
+ this.min = vals.length == 0 ? 0d : dMin;
+ this.max = vals.length == 0 ? 0d : dMax;
+ }
+
@Override
public Color findColour(char c, int j, SequenceI seq)
{
public ColourSchemeI getInstance(AlignViewportI view,
AnnotatedCollectionI coll)
{
- return new ScoreColourScheme(symbolIndex, scores, min, max);
+ return new ScoreColourScheme(symbolIndex, scores);
}
}