2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 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;
24 * ColourSchemeProperty Binds names to hardwired colourschemes and tries to deal
25 * intelligently with mapping unknown names to user defined colourschemes (that
26 * exist or can be created from the string representation of the colourscheme
27 * name - either a hex RGB triplet or a named colour under java.awt.color )
32 public class ColourSchemeProperty
35 public static final int CLUSTAL = 0;
38 public static final int BLOSUM = 1;
41 public static final int PID = 2;
44 public static final int ZAPPO = 3;
47 public static final int TAYLOR = 4;
50 public static final int HYDROPHOBIC = 5;
53 public static final int HELIX = 6;
56 public static final int STRAND = 7;
59 public static final int TURN = 8;
62 public static final int BURIED = 9;
65 public static final int NUCLEOTIDE = 10;
68 public static final int USER_DEFINED = 11;
70 /** No Colourscheme Index */
71 public static final int NONE = 12;
72 /** Undefined Colourscheme Index */
73 public static final int UNDEFINED = 13;
82 * @return DOCUMENT ME!
84 public static int getColourIndexFromName(String name)
88 if (name.equalsIgnoreCase("Clustal"))
92 else if (name.equalsIgnoreCase("Blosum62"))
96 else if (name.equalsIgnoreCase("% Identity"))
100 else if (name.equalsIgnoreCase("Zappo"))
104 else if (name.equalsIgnoreCase("Taylor"))
108 else if (name.equalsIgnoreCase("Hydrophobic"))
112 else if (name.equalsIgnoreCase("Helix Propensity"))
116 else if (name.equalsIgnoreCase("Strand Propensity"))
120 else if (name.equalsIgnoreCase("Turn Propensity"))
124 else if (name.equalsIgnoreCase("Buried Index"))
128 else if (name.equalsIgnoreCase("Nucleotide"))
132 else if (name.equalsIgnoreCase("User Defined"))
136 else if (name.equalsIgnoreCase("None"))
150 * @return DOCUMENT ME!
152 public static String getColourName(ColourSchemeI cs)
157 if (cs instanceof ClustalxColourScheme)
161 else if (cs instanceof Blosum62ColourScheme)
165 else if (cs instanceof PIDColourScheme)
169 else if (cs instanceof ZappoColourScheme)
173 else if (cs instanceof TaylorColourScheme)
177 else if (cs instanceof HydrophobicColourScheme)
181 else if (cs instanceof HelixColourScheme)
185 else if (cs instanceof StrandColourScheme)
189 else if (cs instanceof TurnColourScheme)
193 else if (cs instanceof BuriedColourScheme)
197 else if (cs instanceof NucleotideColourScheme)
201 else if (cs instanceof UserColourScheme)
203 if ((((UserColourScheme) cs).getName() != null)
204 && (((UserColourScheme) cs).getName().length() > 0))
206 return ((UserColourScheme) cs).getName();
208 // get default colourscheme name
209 index = USER_DEFINED;
212 return getColourName(index);
221 * @return DOCUMENT ME!
223 public static String getColourName(int index)
259 ret = "Helix Propensity";
264 ret = "Strand Propensity";
269 ret = "Turn Propensity";
274 ret = "Buried Index";
284 ret = "User Defined";
305 * @return DOCUMENT ME!
307 public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al,
310 return getColour(al.getSequences(), al.getWidth(), name);
323 * @return DOCUMENT ME!
325 public static ColourSchemeI getColour(java.util.Vector seqs, int width,
328 int colindex = getColourIndexFromName(name);
329 if (colindex == UNDEFINED) // USER_DEFINED)
333 return new UserColourScheme(name);
334 } catch (Exception e)
336 // System.err.println("Ignoring unknown colourscheme name");
339 return getColour(seqs, width, getColourIndexFromName(name));
352 * @return DOCUMENT ME!
354 public static ColourSchemeI getColour(java.util.Vector seqs, int width,
357 ColourSchemeI cs = null;
362 cs = new ClustalxColourScheme(seqs, width);
367 cs = new Blosum62ColourScheme();
372 cs = new PIDColourScheme();
377 cs = new ZappoColourScheme();
382 cs = new TaylorColourScheme();
386 cs = new HydrophobicColourScheme();
391 cs = new HelixColourScheme();
396 cs = new StrandColourScheme();
401 cs = new TurnColourScheme();
406 cs = new BuriedColourScheme();
411 cs = new NucleotideColourScheme();
416 Color[] col = new Color[24];
417 for (int i = 0; i < 24; i++)
419 col[i] = Color.white;
421 cs = new UserColourScheme(col);
431 public static Color getAWTColorFromName(String name)
434 name = name.toLowerCase();
435 if (name.equals("black"))
439 else if (name.equals("blue"))
443 else if (name.equals("cyan"))
447 else if (name.equals("darkGray"))
449 col = Color.darkGray;
451 else if (name.equals("gray"))
455 else if (name.equals("green"))
459 else if (name.equals("lightGray"))
461 col = Color.lightGray;
463 else if (name.equals("magenta"))
467 else if (name.equals("orange"))
471 else if (name.equals("pink"))
475 else if (name.equals("red"))
479 else if (name.equals("white"))
483 else if (name.equals("yellow"))