-package jalview.schemes;
-
-public class ColourSchemeProperty
-{
- public static final int CLUSTAL = 0;
- public static final int BLOSUM = 1;
- public static final int PID = 2;
- public static final int ZAPPO = 3;
- public static final int HYDROPHOBIC=4;
- public static final int HELIX=5;
- public static final int STRAND=6;
- public static final int TURN = 7;
- public static final int BURIED = 8;
- public static final int NUCLEOTIDE = 9;
- public static final int USER_DEFINED = 10;
- public static final int NONE = 11;
-
- public static int getColourIndexFromName(String name)
- {
- int ret=11;
- if(name.equals("Clustal"))
- ret = CLUSTAL;
- else if(name.equals("Blosum62"))
- ret = BLOSUM;
- else if(name.equals("% Identity"))
- ret = PID;
- else if(name.equals("Zappo"))
- ret = ZAPPO;
- else if(name.equals("Hydrophobic"))
- ret = HYDROPHOBIC;
- else if(name.equals("Helix Propensity"))
- ret = HELIX;
- else if(name.equals("Strand Propensity"))
- ret = STRAND;
- else if(name.equals("Turn Propensity"))
- ret = TURN;
- else if(name.equals("Buried Index"))
- ret = BURIED;
- else if(name.equals("Nucleotide"))
- ret = NUCLEOTIDE;
- else if(name.equals("User Defined"))
- ret = USER_DEFINED;
-
- return ret;
- }
-
- public static String getColourName(int index)
- {
- String ret=null;
- switch(index)
- {
- case CLUSTAL: ret = "Clustal"; break;
- case BLOSUM: ret = "Blosum62"; break;
- case PID: ret = "% Identity"; break;
- case ZAPPO: ret = "Zappo"; break;
- case HYDROPHOBIC: ret="Hydrophobic";break;
- case HELIX: ret="Helix Propensity";break;
- case STRAND: ret="Strand Propensity";break;
- case TURN: ret="Turn Propensity";break;
- case BURIED: ret="Buried Index";break;
- case NUCLEOTIDE:ret="Nucleotide"; break;
- case USER_DEFINED:ret="User Defined";break;
- default: ret = "None"; break;
- }
- return ret;
- }
-
- public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, String name)
- {
- return getColour(al, getColourIndexFromName(name));
- }
-
- public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, int index)
- {
- ColourSchemeI cs = null;
- switch(index)
- {
- case CLUSTAL: cs = new ClustalxColourScheme(al.getSequences(), al.getWidth()); break;
- case BLOSUM: cs = new Blosum62ColourScheme(); break;
- case PID: cs = new PIDColourScheme(); break;
- case ZAPPO: cs = new ZappoColourScheme(); break;
- case HYDROPHOBIC: cs = new HydrophobicColourScheme(); break;
- case HELIX: cs = new HelixColourScheme(); break;
- case STRAND: cs = new StrandColourScheme(); break;
- case TURN: cs = new TurnColourScheme(); break;
- case BURIED: cs = new BuriedColourScheme(); break;
- case NUCLEOTIDE: cs = new NucleotideColourScheme(); break;
- case USER_DEFINED:
- if(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")!=null)
- {
- cs = jalview.gui.UserDefinedColours.loadDefaultColours(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR"));
- }
- break;
-
- default: break;
- }
-
- return cs;
- }
-}
+package jalview.schemes;\r
+\r
+public class ColourSchemeProperty\r
+{\r
+ public static final int CLUSTAL = 0;\r
+ public static final int BLOSUM = 1;\r
+ public static final int PID = 2;\r
+ public static final int ZAPPO = 3;\r
+ public static final int HYDROPHOBIC=4;\r
+ public static final int HELIX=5;\r
+ public static final int STRAND=6;\r
+ public static final int TURN = 7;\r
+ public static final int BURIED = 8;\r
+ public static final int NUCLEOTIDE = 9;\r
+ public static final int USER_DEFINED = 10;\r
+ public static final int NONE = 11;\r
+\r
+ public static int getColourIndexFromName(String name)\r
+ {\r
+ int ret=11;\r
+ if(name.equalsIgnoreCase("Clustal"))\r
+ ret = CLUSTAL;\r
+ else if(name.equalsIgnoreCase("Blosum62"))\r
+ ret = BLOSUM;\r
+ else if(name.equalsIgnoreCase("% Identity"))\r
+ ret = PID;\r
+ else if(name.equalsIgnoreCase("Zappo"))\r
+ ret = ZAPPO;\r
+ else if(name.equalsIgnoreCase("Hydrophobic"))\r
+ ret = HYDROPHOBIC;\r
+ else if(name.equalsIgnoreCase("Helix Propensity"))\r
+ ret = HELIX;\r
+ else if(name.equalsIgnoreCase("Strand Propensity"))\r
+ ret = STRAND;\r
+ else if(name.equalsIgnoreCase("Turn Propensity"))\r
+ ret = TURN;\r
+ else if(name.equalsIgnoreCase("Buried Index"))\r
+ ret = BURIED;\r
+ else if(name.equalsIgnoreCase("Nucleotide"))\r
+ ret = NUCLEOTIDE;\r
+ else if(name.equalsIgnoreCase("User Defined"))\r
+ ret = USER_DEFINED;\r
+\r
+ return ret;\r
+ }\r
+\r
+ public static String getColourName(int index)\r
+ {\r
+ String ret=null;\r
+ switch(index)\r
+ {\r
+ case CLUSTAL: ret = "Clustal"; break;\r
+ case BLOSUM: ret = "Blosum62"; break;\r
+ case PID: ret = "% Identity"; break;\r
+ case ZAPPO: ret = "Zappo"; break;\r
+ case HYDROPHOBIC: ret="Hydrophobic";break;\r
+ case HELIX: ret="Helix Propensity";break;\r
+ case STRAND: ret="Strand Propensity";break;\r
+ case TURN: ret="Turn Propensity";break;\r
+ case BURIED: ret="Buried Index";break;\r
+ case NUCLEOTIDE:ret="Nucleotide"; break;\r
+ case USER_DEFINED:ret="User Defined";break;\r
+ default: ret = "None"; break;\r
+ }\r
+ return ret;\r
+ }\r
+\r
+ public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, String name)\r
+ {\r
+ return getColour(al, getColourIndexFromName(name));\r
+ }\r
+\r
+ public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, int index)\r
+ {\r
+ ColourSchemeI cs = null;\r
+ switch(index)\r
+ {\r
+ case CLUSTAL: cs = new ClustalxColourScheme(al.getSequences(), al.getWidth()); break;\r
+ case BLOSUM: cs = new Blosum62ColourScheme(); break;\r
+ case PID: cs = new PIDColourScheme(); break;\r
+ case ZAPPO: cs = new ZappoColourScheme(); break;\r
+ case HYDROPHOBIC: cs = new HydrophobicColourScheme(); break;\r
+ case HELIX: cs = new HelixColourScheme(); break;\r
+ case STRAND: cs = new StrandColourScheme(); break;\r
+ case TURN: cs = new TurnColourScheme(); break;\r
+ case BURIED: cs = new BuriedColourScheme(); break;\r
+ case NUCLEOTIDE: cs = new NucleotideColourScheme(); break;\r
+ case USER_DEFINED:\r
+ // if(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")!=null)\r
+ {\r
+ // cs = jalview.gui.UserDefinedColours.loadDefaultColours(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR"));\r
+ }\r
+ break;\r
+\r
+ default: break;\r
+ }\r
+\r
+ return cs;\r
+ }\r
+}\r
-/* Jalview - a java multiple alignment editor
- * Copyright (C) 1998 Michele Clamp
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-package jalview.schemes;
-import java.awt.*;
-import jalview.analysis.*;
-import java.util.Vector;
-
-public class ConservationColourScheme extends ResidueColourScheme {
- public Conservation conserve;
- public ColourSchemeI cs;
- public int inc = 30;
-
- public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs)
- {
- super();
- conserve = cons;
- cs = oldcs;
- }
-
- public void setConsensus(Vector consensus)
- {
- this.consensus = consensus;
- cs.setConsensus(consensus);
- }
-
- public Color findColour(String s, int i)
- {
- Color c = Color.white;
- if (cs == null)
- return c;
-
- char ch = conserve.getConsSequence().getSequence().charAt(i);
- if (ch == '*' || ch == '+')
- {
- c = cs.findColour(s, i);
- }
- else
- {
- int tmp = 10;
- int t = 0;
- if (!jalview.util.Comparison.isGap(ch))
- t = Integer.parseInt(ch + "");
-
- c = cs.findColour(s, i);
-
- while (tmp >= t)
- {
- c = lighter(c, inc);
- tmp--;
- }
-
- }
-
- return c;
- }
-
-
- public Color lighter(Color c, int inc) {
- int red = c.getRed();
- int blue = c.getBlue();
- int green = c.getGreen();
-
- if (red < 255-inc) { red = red +inc;} else {red = 255;}
- if (blue < 255-inc) { blue = blue +inc;} else {blue = 255;}
- if (green < 255-inc) { green = green +inc;} else {green = 255;}
-
- return new Color(red,green,blue);
- }
-
-}
+/* Jalview - a java multiple alignment editor\r
+ * Copyright (C) 1998 Michele Clamp\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
+ */\r
+\r
+package jalview.schemes;\r
+import java.awt.*;\r
+import jalview.analysis.*;\r
+import java.util.Vector;\r
+\r
+public class ConservationColourScheme extends ResidueColourScheme {\r
+ public Conservation conserve;\r
+ public ColourSchemeI cs;\r
+ public int inc = 30;\r
+\r
+ public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs)\r
+ {\r
+ super();\r
+ conserve = cons;\r
+ cs = oldcs;\r
+ }\r
+\r
+ public void setConsensus(Vector consensus)\r
+ {\r
+ this.consensus = consensus;\r
+ if(cs!=null)\r
+ cs.setConsensus(consensus);\r
+ }\r
+\r
+ public Color findColour(String s, int i)\r
+ {\r
+ Color c = Color.white;\r
+ if (cs == null)\r
+ return c;\r
+\r
+ char ch = conserve.getConsSequence().getSequence().charAt(i);\r
+ if (ch == '*' || ch == '+')\r
+ {\r
+ c = cs.findColour(s, i);\r
+ }\r
+ else\r
+ {\r
+ int tmp = 10;\r
+ int t = 0;\r
+ if (!jalview.util.Comparison.isGap(ch))\r
+ t = Integer.parseInt(ch + "");\r
+\r
+ c = cs.findColour(s, i);\r
+\r
+ while (tmp >= t)\r
+ {\r
+ c = lighter(c, inc);\r
+ tmp--;\r
+ }\r
+\r
+ }\r
+\r
+ return c;\r
+ }\r
+\r
+\r
+ public Color lighter(Color c, int inc) {\r
+ int red = c.getRed();\r
+ int blue = c.getBlue();\r
+ int green = c.getGreen();\r
+\r
+ if (red < 255-inc) { red = red +inc;} else {red = 255;}\r
+ if (blue < 255-inc) { blue = blue +inc;} else {blue = 255;}\r
+ if (green < 255-inc) { green = green +inc;} else {green = 255;}\r
+\r
+ return new Color(red,green,blue);\r
+ }\r
+\r
+}\r