just tidying up unused imports
[jalview.git] / src / jalview / schemes / ConservationColourScheme.java
1 /* Jalview - a java multiple alignment editor
2  * Copyright (C) 1998  Michele Clamp
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18
19 package jalview.schemes;
20 import java.awt.*;
21 import jalview.analysis.*;
22 import java.util.Vector;
23
24 public class ConservationColourScheme extends ResidueColourScheme {
25   public Conservation conserve;
26   public ColourSchemeI cs;
27   public int inc = 30;
28
29   public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs)
30   {
31     super();
32     conserve = cons;
33     cs = oldcs;
34   }
35
36   public void setConsensus(Vector consensus)
37   {
38     this.consensus = consensus;
39     cs.setConsensus(consensus);
40   }
41
42    public Color findColour(String s, int i)
43    {
44      Color c = Color.white;
45      if (cs == null)
46        return c;
47
48      char ch = conserve.getConsSequence().getSequence().charAt(i);
49      if (ch == '*' || ch == '+')
50      {
51        c = cs.findColour(s, i);
52      }
53      else
54      {
55        int tmp = 10;
56        int t = 0;
57        if (!jalview.util.Comparison.isGap(ch))
58          t = Integer.parseInt(ch + "");
59
60        c = cs.findColour(s, i);
61
62        while (tmp >= t)
63        {
64          c = lighter(c, inc);
65          tmp--;
66        }
67
68      }
69
70    return c;
71    }
72
73
74   public Color lighter(Color c, int inc) {
75     int red = c.getRed();
76     int blue = c.getBlue();
77     int green = c.getGreen();
78
79     if (red < 255-inc) { red = red +inc;} else {red = 255;}
80     if (blue < 255-inc) { blue = blue +inc;} else {blue = 255;}
81     if (green < 255-inc) { green = green +inc;} else {green = 255;}
82
83     return new Color(red,green,blue);
84   }
85
86 }