2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.schemes;
\r
30 * @version $Revision$
\r
32 public class ResidueColourScheme implements ColourSchemeI
\r
37 /* Set when threshold colouring to either pid_gaps or pid_nogaps*/
\r
38 protected String ignoreGaps = "pid_gaps";
\r
40 /** DOCUMENT ME!! */
\r
41 public Hashtable [] consensus;
\r
44 * Creates a new ResidueColourScheme object.
\r
46 * @param colors DOCUMENT ME!
\r
47 * @param threshold DOCUMENT ME!
\r
49 public ResidueColourScheme(Color[] colors, int threshold)
\r
51 this.colors = colors;
\r
52 this.threshold = threshold;
\r
56 * Creates a new ResidueColourScheme object.
\r
58 public ResidueColourScheme()
\r
65 * @param consensus DOCUMENT ME!
\r
67 public void setConsensus(Vector vconsensus)
\r
69 int i, iSize=vconsensus.size();
\r
70 consensus = new Hashtable[iSize];
\r
71 for(i=0; i<iSize; i++)
\r
72 consensus[i] = (Hashtable)vconsensus.elementAt(i);
\r
78 * @param aa DOCUMENT ME!
\r
80 * @return DOCUMENT ME!
\r
82 public Color findColour(String aa)
\r
84 return colors[((Integer) (ResidueProperties.aaHash.get(aa))).intValue()];
\r
90 * @param s DOCUMENT ME!
\r
91 * @param j DOCUMENT ME!
\r
93 * @return DOCUMENT ME!
\r
95 public Color findColour(String s, int j)
\r
97 if ((threshold == 0) || aboveThreshold(s, j))
\r
99 return colors[((Integer) (ResidueProperties.aaHash.get(s))).intValue()];
\r
103 return Color.white;
\r
110 * @return DOCUMENT ME!
\r
112 public int getThreshold()
\r
120 * @param ct DOCUMENT ME!
\r
122 public void setThreshold(int ct, boolean ignoreGaps)
\r
126 this.ignoreGaps = "pid_nogaps";
\r
128 this.ignoreGaps = "pid_gaps";
\r
134 * @param s DOCUMENT ME!
\r
135 * @param j DOCUMENT ME!
\r
137 * @return DOCUMENT ME!
\r
139 public boolean aboveThreshold(String s, int j)
\r
141 if ((((Integer) consensus[j].get("maxCount")).intValue() != -1) &&
\r
142 consensus[j].contains(s))
\r
144 float ratio = ((Float)consensus[j].get(ignoreGaps)).floatValue();
\r
146 if (ratio >= threshold)
\r