2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.schemes;
30 public class ScoreColourScheme extends ResidueColourScheme
39 public double[] scores;
42 * Creates a new ScoreColourScheme object.
44 * @param scores DOCUMENT ME!
45 * @param min DOCUMENT ME!
46 * @param max DOCUMENT ME!
48 public ScoreColourScheme(double[] scores, double min, double max)
56 // Make colours in constructor
57 // Why wasn't this done earlier?
58 int i, iSize=scores.length;
59 colors = new Color[scores.length];
60 for (i = 0; i < iSize; i++)
62 float red = (float) (scores[i] - (float) min) / (float) (max - min);
73 colors[i] = makeColour(red);
80 * @param s DOCUMENT ME!
81 * @param j DOCUMENT ME!
83 * @return DOCUMENT ME!
85 public Color findColour(String s, int j)
89 if (!aboveThreshold(s, j))
97 if (jalview.util.Comparison.isGap((c)))
102 currentColour = colors[((Integer) ResidueProperties.aaHash.get(s)).intValue()];
104 if(conservationColouring)
105 applyConservation(j);
107 return currentColour;
113 * @param c DOCUMENT ME!
115 * @return DOCUMENT ME!
117 public Color makeColour(float c)
119 return new Color(c, (float) 0.0, (float) 1.0 - c);