2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.schemes;
\r
23 import jalview.datamodel.*;
\r
25 public class AnnotationColourGradient extends ResidueColourScheme
\r
27 AlignmentAnnotation annotation;
\r
28 float minCol, maxCol, minValue, maxValue;
\r
29 boolean aboveAnnotationThreshold = false;
\r
31 float r1, g1, b1, rr, gg, bb, dr, dg, db;
\r
35 * Creates a new AnnotationColourGradient object.
\r
37 public AnnotationColourGradient(AlignmentAnnotation annotation,
\r
38 Color minColour, Color maxColour, boolean aboveThreshold)
\r
40 this.annotation = annotation;
\r
42 aboveAnnotationThreshold = aboveThreshold;
\r
44 r1 = minColour.getRed();
\r
45 g1 = minColour.getGreen();
\r
46 b1 = minColour.getBlue();
\r
48 rr = maxColour.getRed() - r1;
\r
49 gg = maxColour.getGreen() - g1;
\r
50 bb = maxColour.getBlue() - b1;
\r
52 range = annotation.graphMax - annotation.graphMin;
\r
59 * @param n DOCUMENT ME!
\r
61 * @return DOCUMENT ME!
\r
63 public Color findColour(String n)
\r
65 System.out.println("AnnotationColourGradient findColour(string)");
\r
72 * @param n DOCUMENT ME!
\r
73 * @param j DOCUMENT ME!
\r
75 * @return DOCUMENT ME!
\r
77 public Color findColour(String n, int j)
\r
79 if ((threshold == 0) || aboveThreshold(n, j))
\r
81 if(annotation.annotations[j]==null)
\r
82 currentColour = Color.white;
\r
85 if(!aboveAnnotationThreshold || (annotation.graphLines!=null
\r
86 && annotation.annotations[j].value>=annotation.getGraphLine(0).value))
\r
89 ((annotation.annotations[j].value-annotation.graphMin) / range )
\r
92 ((annotation.annotations[j].value-annotation.graphMin) / range )
\r
95 ((annotation.annotations[j].value-annotation.graphMin) / range )
\r
98 currentColour = new Color( (int) dr, (int) dg, (int) db);
\r
101 currentColour = Color.white;
\r
106 return Color.white;
\r
109 if(conservationColouring)
\r
110 applyConservation(j);
\r
112 return currentColour;
\r