JAL-2349 rename ContactMatrixTest to SeqDistanceContactMatrix
[jalview.git] / src / jalview / datamodel / SeqDistanceContactMatrix.java
1 package jalview.datamodel;
2
3 import java.awt.Color;
4
5 /**
6  * Dummy contact matrix based on sequence distance
7  * 
8  * @author jprocter
9  *
10  */
11 public class SeqDistanceContactMatrix implements ContactMatrixI
12 {
13   private int width = 0;
14
15   public SeqDistanceContactMatrix(int width)
16   {
17     this.width = width;
18   }
19   @Override
20   public ContactListI getContactList(final int column)
21   {
22     if (column<0 || column >= width)
23     {
24       return null;
25     }
26     return new ContactListI() {
27       int p = column;
28       @Override
29       public Color getColorForScore(int column)
30       {
31         return jalview.util.ColorUtils.getGraduatedColour(Math.abs(column-p), 0, Color.white, width, Color.magenta);
32       }
33       @Override
34       public Color getColorForRange(int from_column, int to_column)
35       {
36         return jalview.util.ColorUtils.getGraduatedColour(
37                 Math.abs(to_column + from_column - 2 * p) / 2, 0, Color.white, width,
38                 Color.magenta);
39       }
40
41       @Override
42       public int getColumnWidth()
43       {
44         return 1;
45       }
46       @Override
47       public int getContactHeight()
48       {
49         return width;
50
51       }
52
53       @Override
54       public double getContactAt(int column)
55       {
56         return Math.abs(column - p);
57       }
58     };
59   }
60
61 }