Program: 72463
Project: 72463
Buggy source:
/** 
 * Traverse a composite KNode containing corresponding KIELER nodes, ports and edges for the Ptolemy model and apply all layout information contained by it back to the Ptolemy model. Do most changes to the Ptolemy model via MoMLChangeRequests. Set location attributes for all visible Ptolemy nodes. Optionally route edges by inserting   {@link LayoutHint} attributes.
 * @param parentNode The KIELER graph object containing all layout informationto apply to the Ptolemy model
 * @exception IllegalActionException if routing of edges fails.
 */
private void _applyLayout(KNode parentNode) throws IllegalActionException {
  ApplyLayoutRequest layoutRequest=new ApplyLayoutRequest(_compositeEntity);
  for (  KNode knode : parentNode.getChildren()) {
    KShapeLayout nodeLayout=knode.getData(KShapeLayout.class);
    KVector nodePos=nodeLayout.createVector();
    Object divaNode=_kieler2ptolemyDivaNodes.get(knode);
    if (divaNode instanceof Location) {
      Locatable location=(Location)divaNode;
      KimlUtil.toAbsolute(nodePos,parentNode);
      _kNode2Ptolemy(nodePos,divaNode,location);
      double[] snapToGridNodePoint=SnapConstraint.constrainPoint(nodePos.x,nodePos.y);
      layoutRequest.addLocation(location,snapToGridNodePoint[0],snapToGridNodePoint[1]);
    }
  }
  GraphModel graphModel=getLayoutTarget().getGraphModel();
  if (graphModel instanceof ActorGraphModel) {
    for (    Pair<KEdge,Link> entry : _edgeList) {
      _applyEdgeLayoutBendPointAnnotation(entry.getFirst(),entry.getSecond(),layoutRequest);
    }
  }
 else   if (graphModel instanceof FSMGraphModel) {
    for (    Pair<KEdge,Link> entry : _edgeList) {
      if (parentNode.getData(KLayoutData.class).getProperty(Parameters.SPLINES)) {
        _applyEdgeLayoutBendPointAnnotation(entry.getFirst(),entry.getSecond(),layoutRequest);
      }
 else {
        _applyEdgeLayoutCurve(entry.getFirst(),entry.getSecond(),layoutRequest);
      }
    }
  }
  _compositeEntity.requestChange(layoutRequest);
}

Fixed version (ground truth):
/** 
 * Traverse a composite KNode containing corresponding KIELER nodes, ports and edges for the Ptolemy model and apply all layout information contained by it back to the Ptolemy model. Do most changes to the Ptolemy model via MoMLChangeRequests. Set location attributes for all visible Ptolemy nodes. Optionally route edges by inserting   {@link LayoutHint} attributes.
 * @param parentNode The KIELER graph object containing all layout informationto apply to the Ptolemy model
 * @param layoutRequest the common layout request for the current layout run
 * @exception IllegalActionException if routing of edges fails.
 */
private void _applyLayout(KNode parentNode,ApplyLayoutRequest layoutRequest) throws IllegalActionException {
  for (  KNode knode : parentNode.getChildren()) {
    KShapeLayout nodeLayout=knode.getData(KShapeLayout.class);
    KVector nodePos=nodeLayout.createVector();
    Object divaNode=_kieler2ptolemyDivaNodes.get(knode);
    if (divaNode instanceof Location) {
      Locatable location=(Location)divaNode;
      KimlUtil.toAbsolute(nodePos,parentNode);
      _kNode2Ptolemy(nodePos,divaNode,location);
      double[] snapToGridNodePoint=SnapConstraint.constrainPoint(nodePos.x,nodePos.y);
      layoutRequest.addLocation(location,snapToGridNodePoint[0],snapToGridNodePoint[1]);
    }
  }
  GraphModel graphModel=getLayoutTarget().getGraphModel();
  if (graphModel instanceof ActorGraphModel) {
    for (    Pair<KEdge,Link> entry : _edgeList) {
      _applyEdgeLayoutBendPointAnnotation(entry.getFirst(),entry.getSecond(),layoutRequest);
    }
  }
 else   if (graphModel instanceof FSMGraphModel) {
    for (    Pair<KEdge,Link> entry : _edgeList) {
      if (parentNode.getData(KLayoutData.class).getProperty(Parameters.SPLINES)) {
        _applyEdgeLayoutBendPointAnnotation(entry.getFirst(),entry.getSecond(),layoutRequest);
      }
 else {
        _applyEdgeLayoutCurve(entry.getFirst(),entry.getSecond(),layoutRequest);
      }
    }
  }
}