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;
71 public static final int NONE = 12;
79 * @return DOCUMENT ME!
81 public static int getColourIndexFromName(String name)
85 if (name.equalsIgnoreCase("Clustal"))
89 else if (name.equalsIgnoreCase("Blosum62"))
93 else if (name.equalsIgnoreCase("% Identity"))
97 else if (name.equalsIgnoreCase("Zappo"))
101 else if (name.equalsIgnoreCase("Taylor"))
105 else if (name.equalsIgnoreCase("Hydrophobic"))
109 else if (name.equalsIgnoreCase("Helix Propensity"))
113 else if (name.equalsIgnoreCase("Strand Propensity"))
117 else if (name.equalsIgnoreCase("Turn Propensity"))
121 else if (name.equalsIgnoreCase("Buried Index"))
125 else if (name.equalsIgnoreCase("Nucleotide"))
129 else if (name.equalsIgnoreCase("User Defined"))
143 * @return DOCUMENT ME!
145 public static String getColourName(ColourSchemeI cs)
150 if (cs instanceof ClustalxColourScheme)
154 else if (cs instanceof Blosum62ColourScheme)
158 else if (cs instanceof PIDColourScheme)
162 else if (cs instanceof ZappoColourScheme)
166 else if (cs instanceof TaylorColourScheme)
170 else if (cs instanceof HydrophobicColourScheme)
174 else if (cs instanceof HelixColourScheme)
178 else if (cs instanceof StrandColourScheme)
182 else if (cs instanceof TurnColourScheme)
186 else if (cs instanceof BuriedColourScheme)
190 else if (cs instanceof NucleotideColourScheme)
194 else if (cs instanceof UserColourScheme)
196 if ((((UserColourScheme) cs).getName() != null)
197 && (((UserColourScheme) cs).getName().length() > 0))
199 return ((UserColourScheme) cs).getName();
201 // get default colourscheme name
202 index = USER_DEFINED;
205 return getColourName(index);
214 * @return DOCUMENT ME!
216 public static String getColourName(int index)
252 ret = "Helix Propensity";
257 ret = "Strand Propensity";
262 ret = "Turn Propensity";
267 ret = "Buried Index";
277 ret = "User Defined";
298 * @return DOCUMENT ME!
300 public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al,
303 return getColour(al.getSequences(), al.getWidth(), name);
316 * @return DOCUMENT ME!
318 public static ColourSchemeI getColour(java.util.Vector seqs, int width,
321 int colindex = getColourIndexFromName(name);
322 if (colindex > USER_DEFINED)
326 return new UserColourScheme(name);
327 } catch (Exception e)
329 // System.err.println("Ignoring unknown colourscheme name");
332 return getColour(seqs, width, getColourIndexFromName(name));
345 * @return DOCUMENT ME!
347 public static ColourSchemeI getColour(java.util.Vector seqs, int width,
350 ColourSchemeI cs = null;
355 cs = new ClustalxColourScheme(seqs, width);
360 cs = new Blosum62ColourScheme();
365 cs = new PIDColourScheme();
370 cs = new ZappoColourScheme();
375 cs = new TaylorColourScheme();
379 cs = new HydrophobicColourScheme();
384 cs = new HelixColourScheme();
389 cs = new StrandColourScheme();
394 cs = new TurnColourScheme();
399 cs = new BuriedColourScheme();
404 cs = new NucleotideColourScheme();
409 Color[] col = new Color[24];
410 for (int i = 0; i < 24; i++)
412 col[i] = Color.white;
414 cs = new UserColourScheme(col);
424 public static Color getAWTColorFromName(String name)
427 name = name.toLowerCase();
428 if (name.equals("black"))
432 else if (name.equals("blue"))
436 else if (name.equals("cyan"))
440 else if (name.equals("darkGray"))
442 col = Color.darkGray;
444 else if (name.equals("gray"))
448 else if (name.equals("green"))
452 else if (name.equals("lightGray"))
454 col = Color.lightGray;
456 else if (name.equals("magenta"))
460 else if (name.equals("orange"))
464 else if (name.equals("pink"))
468 else if (name.equals("red"))
472 else if (name.equals("white"))
476 else if (name.equals("yellow"))