-/* 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
+* Jalview - A Sequence Alignment Editor and Viewer\r
+* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+*/\r
+package jalview.schemes;\r
+\r
+import jalview.analysis.*;\r
+\r
+import java.awt.*;\r
+\r
+import java.util.Vector;\r
+\r
+\r
+/**\r
+ * DOCUMENT ME!\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
+ * @author $author$\r
+ * @version $Revision$\r
*/\r
+public class ConservationColourScheme extends ResidueColourScheme\r
+{\r
+ /** DOCUMENT ME!! */\r
+ public Conservation conserve;\r
+\r
+ /** DOCUMENT ME!! */\r
+ public ColourSchemeI cs;\r
+\r
+ /** DOCUMENT ME!! */\r
+ public int inc = 30;\r
+\r
+ /**\r
+ * Creates a new ConservationColourScheme object.\r
+ *\r
+ * @param cons DOCUMENT ME!\r
+ * @param oldcs DOCUMENT ME!\r
+ */\r
+ public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs)\r
+ {\r
+ super();\r
+ conserve = cons;\r
+ cs = oldcs;\r
+ }\r
\r
-package jalview.schemes;\r
-import java.awt.*;\r
-import jalview.gui.*;\r
-import jalview.datamodel.*;\r
-import jalview.analysis.*;\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param consensus DOCUMENT ME!\r
+ */\r
+ public void setConsensus(Vector consensus)\r
+ {\r
+ super.setConsensus(consensus);\r
+\r
+ if (cs != null)\r
+ {\r
+ cs.setConsensus(consensus);\r
+ }\r
+ }\r
\r
-public class ConservationColourScheme extends ResidueColourScheme {\r
- public Conservation conserve;\r
- boolean byResidue = true;\r
- public ColourSchemeI cs;\r
- public int inc = 30;\r
- int colourThreshold = 7;\r
-\r
- public ConservationColourScheme(SequenceGroup sg)\r
- {\r
- super();\r
- this.conserve = sg.getConservation();\r
- colourThreshold = 7;\r
- this.cs = sg.cs;\r
- }\r
-\r
- public void setColours(DrawableSequence seq, int j) {\r
- Color c = Color.white;\r
- String s = seq.getSequence().substring(j,j+1);\r
-\r
- if (colourThreshold > 0 && conserve.getConsSequence() != null) {\r
- if (fullConservation(j)) {\r
- if (byResidue) {\r
- c = findColour(seq,s,j);\r
- } else {\r
- c = Color.red;\r
- }\r
- } else {\r
- if (byResidue) {\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param s DOCUMENT ME!\r
+ * @param i DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public Color findColour(String s, int i)\r
+ {\r
+ Color c = Color.white;\r
+\r
+ if (cs == null)\r
+ {\r
+ return c;\r
+ }\r
\r
- int tmp = 10;\r
- int t = Integer.parseInt(conserve.getConsSequence().getSequence().substring(j,j+1));\r
- c = findColour(seq,s,j);\r
-\r
- while (tmp >= t) {\r
- // c = c.darker();\r
- c = lighter(c,inc);\r
- tmp--;\r
- }\r
- } else {\r
- c = Color.yellow;\r
- }\r
+ char ch = conserve.getConsSequence().getSequence().charAt(i);\r
+\r
+ if ((ch == '*') || (ch == '+'))\r
+ {\r
+ c = cs.findColour(s, i);\r
}\r
- }\r
-\r
- seq.setColor(c);\r
-\r
- }\r
- public Color findColour(SequenceI seq, String s, int i, java.util.Vector whatever)\r
- {\r
- Color c = null;\r
- if (colourThreshold > 0 && conserve.getConsSequence() != null)\r
- {\r
- if (fullConservation(i)) {\r
- if (byResidue) {\r
- c = findColour(null,s,i);\r
- } else {\r
- c = Color.red;\r
- }\r
- } else {\r
- if (byResidue) {\r
-\r
- int tmp = 10;\r
- int t = 0;\r
- try\r
- {t=Integer.parseInt(conserve.getConsSequence().getSequence().substring(i,i+1));}\r
- catch(NumberFormatException ex){\r
- System.out.println("fix this bug, conserveColourScheme");\r
- t=0;\r
- }\r
- c = findColour(null,s,i);\r
-\r
- while (tmp >= t) {\r
- // c = c.darker();\r
- c = lighter(c,inc);\r
- tmp--;\r
+ else\r
+ {\r
+ int tmp = 10;\r
+ int t = 0;\r
+\r
+ if (!jalview.util.Comparison.isGap(ch))\r
+ {\r
+ t = Integer.parseInt(ch + "");\r
}\r
- } else {\r
- c = Color.yellow;\r
- }\r
- }\r
- }\r
- return c;\r
- }\r
-\r
- public Color findColour(DrawableSequence seq, String s, int j) {\r
- return cs.findColour(null, s, -1, null);\r
- }\r
- public boolean fullConservation(int j) {\r
- String tmp = conserve.getConsSequence().getSequence().substring(j,j+1);\r
- if (tmp.equals("*")) return true; else return false;\r
- }\r
- public boolean aboveThreshold(DrawableSequence seq, int j, int threshold) {\r
- String tmp = conserve.getConsSequence().getSequence().substring(j,j+1);\r
-\r
- if (Integer.parseInt(tmp) >= threshold || tmp.equals("*")) {\r
- return true;\r
- } else {\r
- return false;\r
+\r
+ c = cs.findColour(s, i);\r
+\r
+ while (tmp >= t)\r
+ {\r
+ c = lighter(c, inc);\r
+ tmp--;\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
+ * DOCUMENT ME!\r
+ *\r
+ * @param c DOCUMENT ME!\r
+ * @param inc DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public Color lighter(Color c, int inc)\r
+ {\r
+ int red = c.getRed();\r
+ int blue = c.getBlue();\r
+ int green = c.getGreen();\r
+\r
+ if (red < (255 - inc))\r
+ {\r
+ red = red + inc;\r
+ }\r
+ else\r
+ {\r
+ red = 255;\r
+ }\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
+ if (blue < (255 - inc))\r
+ {\r
+ blue = blue + inc;\r
+ }\r
+ else\r
+ {\r
+ blue = 255;\r
+ }\r
\r
- return new Color(red,green,blue);\r
- }\r
+ if (green < (255 - inc))\r
+ {\r
+ green = green + inc;\r
+ }\r
+ else\r
+ {\r
+ green = 255;\r
+ }\r
\r
+ return new Color(red, green, blue);\r
+ }\r
}\r