Program: 74068
Project: 74068
Buggy source:
/** 
 * Show or hide unnecessary relation vertices. Iterate all relations in the parent composite actor and find unnecessary relations. I.e. relations that are connected to exactly 2 other object. These relation vertices have no  semantic impact and are likely only added to manipulate the routing of the corresponding edges. Either hide or show those relation vertices. Relations with connection degree 0 or 1 do not get hidden, because they are not only inserted for layout. Usually those are completely unnecessary and should be removed, so the user should be able to see them.
 * @param parent Composite actor that should be searched for unnecessary vertices.
 * @param show True iff the vertices should be shown, false if hidden.
 */
protected static void _showUnnecessaryRelations(CompositeActor parent,boolean show){
  PtolemyModelUtil util=new PtolemyModelUtil();
  for (Iterator containedIterator=parent.containedObjectsIterator(); containedIterator.hasNext(); ) {
    Object containedElement=containedIterator.next();
    if (containedElement instanceof Relation) {
      Relation relation=(Relation)containedElement;
      List<Vertex> vertices=relation.attributeList(ptolemy.moml.Vertex.class);
      for (      Vertex vertex : vertices) {
        List linkedObjects=relation.linkedObjectsList();
        if (linkedObjects.size() == 2) {
          try {
            if (show)             if (vertex.getAttribute("String_Node_Str") != null)             util._hideVertex(relation.getName(),vertex.getName(),false);
 else {
            }
 else {
              util._hideVertex(relation.getName(),vertex.getName(),true);
            }
          }
 catch (          Exception e) {
          }
        }
      }
    }
  }
  util._performChangeRequest(parent);
}

Fixed version (ground truth):
/** 
 * Show or hide unnecessary relation vertices. Iterate all relations in the parent composite actor and find unnecessary relations. I.e. relations that are connected to exactly 2 other object. These relation vertices have no  semantic impact and are likely only added to manipulate the routing of the corresponding edges. Either hide or show those relation vertices. Relations with connection degree 0 or 1 do not get hidden, because they are not only inserted for layout. Usually those are completely unnecessary and should be removed, so the user should be able to see them.
 * @param parent Composite actor that should be searched for unnecessary vertices.
 * @param show True iff the vertices should be shown, false if hidden.
 */
protected static void _showUnnecessaryRelations(CompositeActor parent,boolean show){
  PtolemyModelUtil util=new PtolemyModelUtil();
  for (Iterator containedIterator=parent.containedObjectsIterator(); containedIterator.hasNext(); ) {
    Object containedElement=containedIterator.next();
    if (containedElement instanceof Relation) {
      Relation relation=(Relation)containedElement;
      List<Vertex> vertices=relation.attributeList(ptolemy.moml.Vertex.class);
      for (      Vertex vertex : vertices) {
        List linkedObjects=relation.linkedObjectsList();
        if (linkedObjects.size() <= 2) {
          try {
            if (show)             if (vertex.getAttribute("String_Node_Str") != null)             util._hideVertex(relation.getName(),vertex.getName(),false);
 else {
            }
 else             if (linkedObjects.size() == 2) {
              util._hideVertex(relation.getName(),vertex.getName(),true);
            }
          }
 catch (          Exception e) {
          }
        }
      }
    }
  }
  util._performChangeRequest(parent);
}