Program: 74157
Project: 74157
Buggy source:
/** 
 * Creates a graph for the KIELER API from a ptolemy model.
 * @param composite
 * @return
 */
private KNode createGraph(Object composite){
  _ptolemy2KielerNodes=new HashMap<Object,KNode>();
  _kieler2ptolemyDivaNodes=new HashMap<KNode,Object>();
  _kieler2ptolemyEntityNodes=new HashMap<KNode,NamedObj>();
  _ptolemy2KielerEdges=new HashMap<Set<Relation>,Set<KEdge>>();
  _ptolemy2KielerPorts=new HashMap<Port,KPort>();
  _relations2EdgesVertices=new HashMap<Relation,List<Object>>();
  KNode kgraph=KimlLayoutUtil.createInitializedNode();
  LayoutOptions.setLayoutDirection(KimlLayoutUtil.getShapeLayout(kgraph),LayoutDirection.HORIZONTAL);
  LayoutTarget target=this.getLayoutTarget();
  GraphModel graph=target.getGraphModel();
  if (graph instanceof ActorGraphModel) {
    ActorGraphModel aGraph=(ActorGraphModel)graph;
    Set relationSet=new HashSet<Relation>();
    for (Iterator iterator=aGraph.nodes(composite); iterator.hasNext(); ) {
      Object node=iterator.next();
      Rectangle2D bounds=target.getBounds(node);
      System.out.println("String_Node_Str" + aGraph.getSemanticObject(node) + "String_Node_Str"+ bounds);
      Object semanticNode=aGraph.getSemanticObject(node);
      if (semanticNode instanceof Actor || semanticNode instanceof Attribute || semanticNode instanceof Port) {
        KNode knode=KimlLayoutUtil.createInitializedNode();
        knode.setParent(kgraph);
        KShapeLayout klayout=KimlLayoutUtil.getShapeLayout(knode);
        klayout.setHeight((float)bounds.getHeight());
        klayout.setWidth((float)bounds.getWidth());
        klayout.setXpos((float)bounds.getX());
        klayout.setYpos((float)bounds.getY());
        ptolemy2KNode(klayout);
        LayoutOptions.setFixedSize(klayout);
        _ptolemy2KielerNodes.put(node,knode);
        _kieler2ptolemyDivaNodes.put(knode,node);
        _kieler2ptolemyEntityNodes.put(knode,(NamedObj)semanticNode);
        if (semanticNode instanceof Actor) {
          Actor actor=(Actor)semanticNode;
          List<Port> inputs=actor.inputPortList();
          List<Port> outputs=actor.outputPortList();
          createKPorts(knode,inputs,KPortType.INPUT);
          createKPorts(knode,outputs,KPortType.OUTPUT);
          for (          Port outputPort : outputs) {
            List<Relation> relations=outputPort.linkedRelationList();
            for (            Relation relation : relations) {
              if (!_relations2EdgesVertices.containsKey(relation)) {
                ArrayList list=new ArrayList();
                _relations2EdgesVertices.put(relation,list);
              }
              System.out.println("String_Node_Str" + relation);
            }
          }
        }
      }
      if (semanticNode instanceof Relation) {
        Relation relation=(Relation)semanticNode;
        if (!_relations2EdgesVertices.containsKey(relation)) {
          ArrayList list=new ArrayList();
          list.add(node);
          _relations2EdgesVertices.put(relation,list);
        }
 else         _relations2EdgesVertices.get(relation).add(node);
      }
      for (Iterator iterator2=aGraph.outEdges(node); iterator2.hasNext(); ) {
        Object edge=iterator2.next();
        Relation relation=(Relation)aGraph.getSemanticObject(edge);
        if (!_relations2EdgesVertices.containsKey(relation)) {
          ArrayList list=new ArrayList();
          list.add(node);
          _relations2EdgesVertices.put(relation,list);
        }
        System.out.println("String_Node_Str" + relation);
      }
    }
    Set<List<Relation>> relationGroups=getRelationGroups(_relations2EdgesVertices.keySet());
    for (    List<Relation> relationGroup : relationGroups) {
      Set<Relation> relationGroupSet=new HashSet<Relation>();
      relationGroupSet.addAll(relationGroup);
      createKEdges(relationGroupSet);
    }
  }
  return kgraph;
}

Fixed version (ground truth):
/** 
 * Creates a graph for the KIELER API from a ptolemy model.
 * @param composite
 * @return
 */
private KNode createGraph(Object composite){
  _ptolemy2KielerNodes=new HashMap<Object,KNode>();
  _kieler2ptolemyDivaNodes=new HashMap<KNode,Object>();
  _kieler2ptolemyEntityNodes=new HashMap<KNode,NamedObj>();
  _ptolemy2KielerEdges=new HashMap<Set<Relation>,Set<KEdge>>();
  _ptolemy2KielerPorts=new HashMap<Port,KPort>();
  _kieler2PtolemyPorts=new HashMap<KPort,Port>();
  _relations2EdgesVertices=new HashMap<Relation,List<Object>>();
  KNode kgraph=KimlLayoutUtil.createInitializedNode();
  LayoutOptions.setLayoutDirection(KimlLayoutUtil.getShapeLayout(kgraph),LayoutDirection.HORIZONTAL);
  LayoutTarget target=this.getLayoutTarget();
  GraphModel graph=target.getGraphModel();
  if (graph instanceof ActorGraphModel) {
    ActorGraphModel aGraph=(ActorGraphModel)graph;
    Set relationSet=new HashSet<Relation>();
    for (Iterator iterator=aGraph.nodes(composite); iterator.hasNext(); ) {
      Object node=iterator.next();
      Rectangle2D bounds=target.getBounds(node);
      System.out.println("String_Node_Str" + aGraph.getSemanticObject(node) + "String_Node_Str"+ bounds);
      Object semanticNode=aGraph.getSemanticObject(node);
      if (semanticNode instanceof Actor || semanticNode instanceof Attribute || semanticNode instanceof Port) {
        KNode knode=KimlLayoutUtil.createInitializedNode();
        knode.setParent(kgraph);
        KShapeLayout klayout=KimlLayoutUtil.getShapeLayout(knode);
        klayout.setHeight((float)bounds.getHeight());
        klayout.setWidth((float)bounds.getWidth());
        klayout.setXpos((float)bounds.getX());
        klayout.setYpos((float)bounds.getY());
        ptolemy2KNode(klayout);
        LayoutOptions.setFixedSize(klayout);
        _ptolemy2KielerNodes.put(node,knode);
        _kieler2ptolemyDivaNodes.put(knode,node);
        _kieler2ptolemyEntityNodes.put(knode,(NamedObj)semanticNode);
        if (semanticNode instanceof Actor) {
          Actor actor=(Actor)semanticNode;
          List<Port> inputs=actor.inputPortList();
          List<Port> outputs=actor.outputPortList();
          createKPorts(knode,inputs,KPortType.INPUT);
          createKPorts(knode,outputs,KPortType.OUTPUT);
          for (          Port outputPort : outputs) {
            List<Relation> relations=outputPort.linkedRelationList();
            for (            Relation relation : relations) {
              if (!_relations2EdgesVertices.containsKey(relation)) {
                ArrayList list=new ArrayList();
                _relations2EdgesVertices.put(relation,list);
              }
              System.out.println("String_Node_Str" + relation);
            }
          }
        }
      }
      if (semanticNode instanceof Relation) {
        Relation relation=(Relation)semanticNode;
        if (!_relations2EdgesVertices.containsKey(relation)) {
          ArrayList list=new ArrayList();
          list.add(node);
          _relations2EdgesVertices.put(relation,list);
        }
 else         _relations2EdgesVertices.get(relation).add(node);
      }
      for (Iterator iterator2=aGraph.outEdges(node); iterator2.hasNext(); ) {
        Object edge=iterator2.next();
        Relation relation=(Relation)aGraph.getSemanticObject(edge);
        if (!_relations2EdgesVertices.containsKey(relation)) {
          ArrayList list=new ArrayList();
          list.add(node);
          _relations2EdgesVertices.put(relation,list);
        }
        System.out.println("String_Node_Str" + relation);
      }
    }
    Set<List<Relation>> relationGroups=getRelationGroups(_relations2EdgesVertices.keySet());
    for (    List<Relation> relationGroup : relationGroups) {
      Set<Relation> relationGroupSet=new HashSet<Relation>();
      relationGroupSet.addAll(relationGroup);
      createKEdges(relationGroupSet);
    }
  }
  return kgraph;
}