JAL-1551 spotlessApply
[jalview.git] / src / jalview / datamodel / ContactMatrixI.java
1 package jalview.datamodel;
2
3 import java.awt.Color;
4 import java.util.Arrays;
5 import java.util.BitSet;
6 import java.util.List;
7
8 public interface ContactMatrixI
9 {
10
11   ContactListI getContactList(int column);
12
13   float getMin();
14
15   float getMax();
16
17   String getAnnotDescr();
18
19   String getAnnotLabel();
20
21   /**
22    * string indicating how the contactMatrix should be rendered - stored in
23    * calcId
24    * 
25    * @return
26    */
27   String getType();
28
29   int getWidth();
30
31   int getHeight();
32
33   public GroupSetI getGroupSet();
34
35   /// proxy methods to simplify use of the interface
36   /// Mappable contact matrices can override these to perform mapping
37
38   default public boolean hasGroupSet()
39   {
40     return getGroupSet() != null;
41   }
42
43   default boolean hasGroups()
44   {
45     return hasGroupSet() && getGroupSet().hasGroups();
46   }
47
48   default BitSet getGroupsFor(int column)
49   {
50     if (!hasGroupSet())
51     {
52       BitSet colbitset = new BitSet();
53       colbitset.set(column);
54       return colbitset;
55     }
56     return getGroupSet().getGroupsFor(column);
57   }
58
59   default List<BitSet> getGroups()
60   {
61     if (!hasGroupSet())
62     {
63       return Arrays.asList();
64     }
65     return getGroupSet().getGroups();
66   }
67
68   default boolean hasTree()
69   {
70     return hasGroupSet() ? getGroupSet().hasTree() : false;
71   }
72
73   /**
74    * Newick representation of clustered matrix
75    * 
76    * @return null unless hasTree is true
77    */
78   default String getNewick()
79   {
80     return hasGroupSet() ? getGroupSet().getNewick() : null;
81   }
82
83   default String getTreeMethod()
84   {
85     return hasGroupSet() ? getGroupSet().getTreeMethod() : null;
86   }
87
88   default boolean hasCutHeight()
89   {
90     return hasGroupSet() ? getGroupSet().hasCutHeight() : false;
91   }
92
93   default double getCutHeight()
94   {
95     return hasGroupSet() ? getGroupSet().getCutHeight() : 0;
96   }
97
98   default void updateGroups(List<BitSet> colGroups)
99   {
100     if (hasGroupSet())
101     {
102       getGroupSet().updateGroups(colGroups);
103     }
104   }
105
106   default void setColorForGroup(BitSet bs, Color color)
107   {
108     if (hasGroupSet())
109     {
110       getGroupSet().setColorForGroup(bs, color);
111     }
112   }
113
114   default Color getColourForGroup(BitSet bs)
115   {
116     if (hasGroupSet())
117     {
118       return getGroupSet().getColourForGroup(bs);
119     }
120     else
121     {
122       return Color.white;
123     }
124   }
125
126   void setGroupSet(GroupSet makeGroups);
127
128 }