/// <summary> /// Marks nodes blue or red if there is a change in the represented /// class/subtree. /// </summary> private void FixStructuralRepresentatives() { PSMTreeIterator.NodeMarker additionalNodeMarker = IsContentGroupNode; foreach (PSMClass sr in Diagram.DiagramElements.Keys.OfType <PSMClass>().Where(c => c.IsStructuralRepresentative)) { foreach (PSMTreeIterator.NodeMarker nodeMarker in new[] { null, additionalNodeMarker }) { PSMElement representedClassSignificantAncestor = PSMTreeIterator.GetSignificantAncestorOrSelf(sr.RepresentedPSMClass, nodeMarker); PSMElement structuralRepresentativeSignificantAncestor = PSMTreeIterator.GetSignificantAncestorOrSelf(sr, nodeMarker); if (redNodes.Contains(representedClassSignificantAncestor)) { redNodes.AddIfNotContained(structuralRepresentativeSignificantAncestor); blueNodes.Remove(structuralRepresentativeSignificantAncestor); greenNodes.Remove(structuralRepresentativeSignificantAncestor); MakeAncestorsBlue(structuralRepresentativeSignificantAncestor, nodeMarker); } else if (blueNodes.Contains(representedClassSignificantAncestor) && !redNodes.Contains(structuralRepresentativeSignificantAncestor)) { blueNodes.AddIfNotContained(structuralRepresentativeSignificantAncestor); greenNodes.Remove(structuralRepresentativeSignificantAncestor); MakeAncestorsBlue(structuralRepresentativeSignificantAncestor, nodeMarker); } } } }
private void MakeAncestorsBlue(PSMElement node, PSMTreeIterator.NodeMarker nodeMarker) { foreach (PSMElement ancestor in PSMTreeIterator.SignificantAncestors(node, nodeMarker)) { if (!redNodes.Contains(ancestor)) { blueNodes.AddIfNotContained(ancestor); greenNodes.Remove(ancestor); } } }