* 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
-\r
package jalview.schemes;\r
-import java.awt.*;\r
+\r
import jalview.analysis.*;\r
+\r
+import java.awt.*;\r
+\r
import java.util.Vector;\r
\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
+ public Conservation conserve;\r
+ public ColourSchemeI cs;\r
+ public int inc = 30;\r
+\r
+ public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs) {\r
+ super();\r
+ conserve = cons;\r
+ cs = oldcs;\r
+ }\r
+\r
+ public void setConsensus(Vector consensus) {\r
+ this.consensus = consensus;\r
+\r
+ if (cs != null) {\r
+ cs.setConsensus(consensus);\r
+ }\r
+ }\r
+\r
+ public Color findColour(String s, int i) {\r
+ Color c = Color.white;\r
+\r
+ if (cs == null) {\r
+ return c;\r
+ }\r
+\r
+ char ch = conserve.getConsSequence().getSequence().charAt(i);\r
+\r
+ if ((ch == '*') || (ch == '+')) {\r
+ c = cs.findColour(s, i);\r
+ } else {\r
+ int tmp = 10;\r
+ int t = 0;\r
+\r
+ if (!jalview.util.Comparison.isGap(ch)) {\r
+ t = Integer.parseInt(ch + "");\r
+ }\r
+\r
+ c = cs.findColour(s, i);\r
+\r
+ while (tmp >= t) {\r
+ c = lighter(c, inc);\r
+ tmp--;\r
+ }\r
+ }\r
+\r
+ return c;\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)) {\r
+ red = red + inc;\r
+ } else {\r
+ red = 255;\r
+ }\r
+\r
+ if (blue < (255 - inc)) {\r
+ blue = blue + inc;\r
+ } else {\r
+ blue = 255;\r
+ }\r
+\r
+ if (green < (255 - inc)) {\r
+ green = green + inc;\r
+ } else {\r
+ green = 255;\r
+ }\r
\r
+ return new Color(red, green, blue);\r
+ }\r
}\r