package jalview.datamodel; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; public class ContactMapHolder implements ContactMapHolderI { Map contactmaps = new HashMap<>(); @Override public Collection getContactMaps() { if (contactmaps != null && contactmaps.size() > 0) { return contactmaps.values(); } return Collections.EMPTY_LIST; } @Override public ContactListI getContactListFor(AlignmentAnnotation _aa, int column) { ContactMatrixI cm = contactmaps.get(_aa.annotationId); if (cm == null) { return null; } // TODO: could resolve sequence position to column position here // TODO: what about for complexes - where contactMatrix may involve two or // more sequences return cm.getContactList(column); } @Override public AlignmentAnnotation addContactList(ContactMatrixI cm) { AlignmentAnnotation aa = new AlignmentAnnotation(cm.getAnnotLabel(), cm.getAnnotDescr(), new Annotation[0]); aa.graph = AlignmentAnnotation.CUSTOMRENDERER; aa.graphMin = cm.getMin(); aa.graphMax = cm.getMax(); aa.editable = false; contactmaps.put(aa.annotationId, cm); // TODO: contact matrices could be intra or inter - more than one refseq // possible! if (cm.hasReferenceSeq()) { aa.setSequenceRef(cm.getReferenceSeq()); } return aa; } @Override public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann) { return contactmaps == null ? null : contactmaps.get(ann.annotationId); } @Override public void addContactListFor(AlignmentAnnotation annotation, ContactMatrixI cm) { contactmaps.put(annotation.annotationId, cm); } }