public static final int CONTACT_MAP = 4;
+ /**
+ * property that when set to non-empty string disables display of column groups defined on the contact matrix
+ */
+ public static final String CONTACT_MAP_NOGROUPS = "CMNOGRPS";
+
public boolean belowAlignment = true;
public SequenceGroup groupRef = null;
}
return aa;
}
+
+ /**
+ * convenience method to check for the 'CONTACT_MAP_NOGROUPS' property for this alignment annotation row
+ * @return true if no CONTACT_MAP_NOGROUPS property is found, or it is set to ""
+ */
+ public boolean isShowGroupsForContactMatrix()
+ {
+ return getProperty(AlignmentAnnotation.CONTACT_MAP_NOGROUPS)==null || "".equals(getProperty(AlignmentAnnotation.CONTACT_MAP_NOGROUPS));
+ }
+ /**
+ * set the 'CONTACT_MAP_NOGROUPS' property for this alignment annotation row
+ * @see isShowGroupsForContactMatrix
+ */
+ public void setShowGroupsForContactMatrix(boolean showGroups)
+ {
+ setProperty(AlignmentAnnotation.CONTACT_MAP_NOGROUPS, showGroups ? "" : "nogroups");
+ }
+
}
import jalview.commands.CommandI;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.ContactMatrixI;
{
this.viewName = viewName;
}
+
}
{
pop.addSeparator();
+ if (cm.hasGroups())
+ {
+ JCheckBoxMenuItem chitem = new JCheckBoxMenuItem("Show Groups on Matrix");
+ boolean showGroups = aa[selectedRow].isShowGroupsForContactMatrix();
+ final AlignmentAnnotation sel_row=aa[selectedRow];
+ chitem.setState(showGroups);
+ chitem.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ sel_row.setShowGroupsForContactMatrix(chitem.getState());
+ ap.getAnnotationPanel()
+ .paint(ap.getAnnotationPanel().getGraphics());
+ }
+ });
+ pop.add(chitem);
+ }
if (cm.hasTree())
{
item = new JMenuItem("Show Tree for Matrix");
HiddenColumns hiddenColumns, ColumnSelection columnSelection,
AlignmentAnnotation _aa, Annotation[] aa_annotations, int sRes,
int eRes, float min, float max, int y)
- {
+ {
if (sRes > aa_annotations.length)
{
return;
g.setColor(shade.no_data);
g.drawLine(x, y2, (eRes - sRes) * charWidth, y2);
-
+ boolean showGroups = _aa.isShowGroupsForContactMatrix();
int column;
int aaMax = aa_annotations.length - 1;
ContactMatrixI cm = viewport.getContactMatrix(_aa);
{
col = shade.hidden;
}
- if (gpcol != null && gpcol != Color.white)
+ if (showGroups && gpcol != null && gpcol != Color.white)
{
// todo - could overlay group as a transparent rectangle ?
col = new Color(
*/
package jalview.datamodel;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
import static org.testng.AssertJUnit.assertEquals;
import jalview.analysis.AlignSeq;
assertNull(ann.annotations[0]);
assertNull(ann.annotations[4]);
}
+ /**
+ * test the contact matrix nogroups property methods
+ */
+ @Test(groups= {"Functional"})
+ public void test_contactMatrixGroups()
+ {
+ AlignmentAnnotation aa = new AlignmentAnnotation("foo","foo desc",null);
+ assertTrue(aa.isShowGroupsForContactMatrix());
+ aa.setShowGroupsForContactMatrix(false);
+ assertFalse(aa.isShowGroupsForContactMatrix());
+ AlignmentAnnotation copy = new AlignmentAnnotation(aa);
+ assertFalse(copy.isShowGroupsForContactMatrix());
+ aa.setShowGroupsForContactMatrix(true);
+ assertTrue(aa.isShowGroupsForContactMatrix());
+ // copy should not be updated
+ assertFalse(copy.isShowGroupsForContactMatrix());
+
+
+ }
}