X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FContactMatrixI.java;h=1d20987117ba409ebb79782c9453ca51acf03f19;hb=d4271d32477e99e9fbbfa5db3e11f1b79324e60d;hp=9eabb10763d8aa9ce9b29c0946bb4201d34c1dde;hpb=a81e74154d35e10958b58c3c9411aa9ee21880a6;p=jalview.git diff --git a/src/jalview/datamodel/ContactMatrixI.java b/src/jalview/datamodel/ContactMatrixI.java index 9eabb10..1d20987 100644 --- a/src/jalview/datamodel/ContactMatrixI.java +++ b/src/jalview/datamodel/ContactMatrixI.java @@ -1,5 +1,6 @@ package jalview.datamodel; +import java.awt.Color; import java.util.Arrays; import java.util.BitSet; import java.util.List; @@ -13,57 +14,112 @@ public interface ContactMatrixI float getMax(); - boolean hasReferenceSeq(); - - SequenceI getReferenceSeq(); - String getAnnotDescr(); String getAnnotLabel(); /** - * string indicating how the contactMatrix should be rendered - stored in calcId - * @return + * string indicating how the contactMatrix should be rendered - stored in + * calcId + * + * @return */ String getType(); int getWidth(); int getHeight(); - - default boolean hasGroups() { - return false; + public GroupSetI getGroupSet(); + + /// proxy methods to simplify use of the interface + /// Mappable contact matrices can override these to perform mapping + + default public boolean hasGroupSet() + { + return getGroupSet() != null; } - default BitSet getGroupsFor(int column) { - BitSet colbitset = new BitSet(); - colbitset.set(column); - return colbitset; + + default boolean hasGroups() + { + return hasGroupSet() && getGroupSet().hasGroups(); + } + + default BitSet getGroupsFor(int column) + { + if (!hasGroupSet()) + { + BitSet colbitset = new BitSet(); + colbitset.set(column); + return colbitset; + } + return getGroupSet().getGroupsFor(column); } - default List getGroups() { - return Arrays.asList(); + default List getGroups() + { + if (!hasGroupSet()) + { + return Arrays.asList(); + } + return getGroupSet().getGroups(); } - default boolean hasTree() { - return false; + default boolean hasTree() + { + return hasGroupSet() ? getGroupSet().hasTree() : false; } /** * Newick representation of clustered matrix + * * @return null unless hasTree is true */ - default String getNewick() { - return null; + default String getNewick() + { + return hasGroupSet() ? getGroupSet().getNewick() : null; } - default String getTreeMethod() { - return null; + default String getTreeMethod() + { + return hasGroupSet() ? getGroupSet().getTreeMethod() : null; } - default boolean hasCutHeight() { - return false; + default boolean hasCutHeight() + { + return hasGroupSet() ? getGroupSet().hasCutHeight() : false; } - default double getCutHeight() { - return 0; + default double getCutHeight() + { + return hasGroupSet() ? getGroupSet().getCutHeight() : 0; } + + default void updateGroups(List colGroups) + { + if (hasGroupSet()) + { + getGroupSet().updateGroups(colGroups); + } + } + + default void setColorForGroup(BitSet bs, Color color) + { + if (hasGroupSet()) + { + getGroupSet().setColorForGroup(bs, color); + } + } + + default Color getColourForGroup(BitSet bs) + { + if (hasGroupSet()) + { + return getGroupSet().getColourForGroup(bs); + } + else + { + return Color.white; + } + } + + void setGroupSet(GroupSet makeGroups); }