Program: 73398
Project: 73398
Buggy source:
/** 
 * Render a visual representation of the given node. If the StringAttribute _color of the node is set then use that color to render the node. If the StringAttribute _explanation of the node is set then use it to set the tooltip.
 * @see diva.graph.NodeRenderer#render(java.lang.Object)
 */
public Figure render(Object n){
  final Port port=(Port)n;
  if (_isPropertySet(port,"String_Node_Str")) {
    return null;
  }
  boolean isInput=false;
  boolean isOutput=false;
  boolean isInputOutput=false;
  if (port instanceof IOPort) {
    isInput=((IOPort)port).isInput();
    isOutput=((IOPort)port).isOutput();
    isInputOutput=isInput && isOutput;
  }
  Shape shape;
  if (isInputOutput) {
    Polygon2D.Double polygon=new Polygon2D.Double();
    polygon.moveTo(0,-4);
    polygon.lineTo(-4,-4);
    polygon.lineTo(-2,0);
    polygon.lineTo(-4,4);
    polygon.lineTo(4,4);
    polygon.lineTo(2,0);
    polygon.lineTo(4,-4);
    polygon.lineTo(0,-4);
    polygon.closePath();
    shape=polygon;
  }
 else   if (isInput) {
    Polygon2D.Double polygon=new Polygon2D.Double();
    polygon.moveTo(-4,0);
    polygon.lineTo(-4,4);
    polygon.lineTo(4,0);
    polygon.lineTo(-4,-4);
    polygon.lineTo(-4,0);
    polygon.closePath();
    shape=polygon;
  }
 else   if (isOutput) {
    Polygon2D.Double polygon=new Polygon2D.Double();
    polygon.moveTo(4,0);
    polygon.lineTo(4,-4);
    polygon.lineTo(-4,0);
    polygon.lineTo(4,4);
    polygon.lineTo(4,0);
    polygon.closePath();
    shape=polygon;
  }
 else {
    shape=new Ellipse2D.Double(-4,-4,8,8);
  }
  Color fill;
  if (port instanceof ParameterPort) {
    fill=Color.lightGray;
  }
 else   if (port instanceof IOPort && ((IOPort)port).isMultiport()) {
    fill=Color.white;
  }
 else {
    fill=Color.black;
  }
  try {
    if (port instanceof IOPort) {
      List<MonitoredQuantityManager> qmList;
      List list=((IOPort)port).getQuantityManagers();
      if (list != null) {
        qmList=new ArrayList(list);
        if (qmList != _qmList && qmList.size() > 0) {
          _qmList=qmList;
          if (((IOPort)port).isOutput()) {
            fill=qmList.get(0).color.asColor();
          }
 else {
            fill=qmList.get(qmList.size() - 1).color.asColor();
          }
          StringAttribute info=(StringAttribute)port.getAttribute("String_Node_Str");
          String qmString="String_Node_Str";
          if (info == null) {
            info=new StringAttribute(port,"String_Node_Str");
          }
          for (int j=0; j < qmList.size(); j++) {
            qmString=qmString + qmList.get(j).getName() + "String_Node_Str";
          }
          info.setExpression("String_Node_Str" + qmString.substring(0,qmString.length() - 2));
        }
      }
    }
  }
 catch (  IllegalActionException e1) {
    e1.printStackTrace();
  }
catch (  NameDuplicationException e) {
  }
  ColorAttribute colorAttribute;
  try {
    colorAttribute=(ColorAttribute)(port.getAttribute("String_Node_Str",ColorAttribute.class));
    if (colorAttribute != null) {
      Color color=colorAttribute.asColor();
      fill=color;
    }
  }
 catch (  IllegalActionException e1) {
    e1.printStackTrace();
  }
  int portRotation=_getCardinality(port);
  int direction=_getDirection(portRotation);
  double rotation=portRotation;
  AffineTransform transform=AffineTransform.getRotateInstance(Math.toRadians(rotation));
  shape=ShapeUtilities.transformModify(shape,transform);
  Figure figure=new BasicFigure(shape,fill,(float)1.5){
    public String getToolTipText(){
      String tipText=port.getName();
      String displayName=port.getDisplayName();
      if (!tipText.equals(displayName)) {
        tipText=displayName + "String_Node_Str" + tipText+ "String_Node_Str";
      }
      StringAttribute _explAttr=(StringAttribute)(port.getAttribute("String_Node_Str"));
      if (_explAttr != null) {
        tipText=_explAttr.getExpression();
      }
 else       if (port instanceof Typeable) {
        try {
          tipText=tipText + "String_Node_Str" + ((Typeable)port).getType();
        }
 catch (        IllegalActionException ex) {
        }
      }
      return tipText;
    }
  }
;
  String tipText=port.getName();
  String displayName=port.getDisplayName();
  if (!tipText.equals(displayName)) {
    tipText=displayName + "String_Node_Str" + tipText+ "String_Node_Str";
  }
  figure.setToolTipText(tipText);
  double normal=CanvasUtilities.getNormal(direction);
  if (port instanceof IOPort) {
    IOPort ioPort=(IOPort)port;
    if (ioPort.isMultiport()) {
      int numberOfLinks=ioPort.linkedRelationList().size();
      if (numberOfLinks > 1) {
        CompositeFigure compositeFigure=new CompositeFigure(figure){
          public String getToolTipText(){
            String tipText=port.getName();
            String displayName=port.getDisplayName();
            if (!tipText.equals(displayName)) {
              tipText=displayName + "String_Node_Str" + tipText+ "String_Node_Str";
            }
            StringAttribute _explAttr=(StringAttribute)(port.getAttribute("String_Node_Str"));
            if (_explAttr != null) {
              tipText=_explAttr.getExpression();
            }
 else             if (port instanceof Typeable) {
              try {
                tipText=tipText + "String_Node_Str" + ((Typeable)port).getType();
              }
 catch (              IllegalActionException ex) {
              }
            }
            return tipText;
          }
        }
;
        double startX;
        double startY;
        double endX;
        double endY;
        Rectangle2D bounds=figure.getShape().getBounds2D();
        double x=bounds.getX();
        double y=bounds.getY();
        double width=bounds.getWidth();
        double height=bounds.getHeight();
        int extent=numberOfLinks - 1;
        if (direction == SwingConstants.EAST) {
          startX=x + width;
          startY=y + (height / 2);
          endX=startX + (extent * MULTIPORT_CONNECTION_SPACING);
          endY=startY + (extent * MULTIPORT_CONNECTION_SPACING);
        }
 else         if (direction == SwingConstants.WEST) {
          startX=x;
          startY=y + (height / 2);
          endX=startX - (extent * MULTIPORT_CONNECTION_SPACING);
          endY=startY - (extent * MULTIPORT_CONNECTION_SPACING);
        }
 else         if (direction == SwingConstants.NORTH) {
          startX=x + (width / 2);
          startY=y;
          endX=startX - (extent * MULTIPORT_CONNECTION_SPACING);
          endY=startY - (extent * MULTIPORT_CONNECTION_SPACING);
        }
 else {
          startX=x + (width / 2);
          startY=y + height;
          endX=startX + (extent * MULTIPORT_CONNECTION_SPACING);
          endY=startY + (extent * MULTIPORT_CONNECTION_SPACING);
        }
        Line2D line=new Line2D.Double(startX,startY,endX,endY);
        Figure lineFigure=new BasicFigure(line,fill,(float)2.0);
        compositeFigure.add(lineFigure);
        figure=compositeFigure;
      }
    }
    figure=_decoratePortFigure(n,figure);
    figure=new PortTerminal(ioPort,figure,normal,false);
  }
 else {
    figure=_decoratePortFigure(n,figure);
    Site tsite=new PerimeterSite(figure,0);
    tsite.setNormal(normal);
    figure=new TerminalFigure(figure,tsite);
  }
  try {
    ColorAttribute highlightAttribute=(ColorAttribute)(port.getAttribute("String_Node_Str",ColorAttribute.class));
    if (highlightAttribute != null && !highlightAttribute.getExpression().trim().equals("String_Node_Str")) {
      Color color=highlightAttribute.asColor();
      AnimationRenderer animationRenderer=new AnimationRenderer(color);
      animationRenderer.renderSelected(figure);
    }
  }
 catch (  IllegalActionException e) {
  }
  return figure;
}

Fixed version (ground truth):
/** 
 * Render a visual representation of the given node. If the StringAttribute _color of the node is set then use that color to render the node. If the StringAttribute _explanation of the node is set then use it to set the tooltip.
 * @see diva.graph.NodeRenderer#render(java.lang.Object)
 */
public Figure render(Object n){
  final Port port=(Port)n;
  if (_isPropertySet(port,"String_Node_Str")) {
    return null;
  }
  boolean isInput=false;
  boolean isOutput=false;
  boolean isInputOutput=false;
  if (port instanceof IOPort) {
    isInput=((IOPort)port).isInput();
    isOutput=((IOPort)port).isOutput();
    isInputOutput=isInput && isOutput;
  }
  Shape shape;
  if (isInputOutput) {
    Polygon2D.Double polygon=new Polygon2D.Double();
    polygon.moveTo(0,-4);
    polygon.lineTo(-4,-4);
    polygon.lineTo(-2,0);
    polygon.lineTo(-4,4);
    polygon.lineTo(4,4);
    polygon.lineTo(2,0);
    polygon.lineTo(4,-4);
    polygon.lineTo(0,-4);
    polygon.closePath();
    shape=polygon;
  }
 else   if (isInput) {
    Polygon2D.Double polygon=new Polygon2D.Double();
    polygon.moveTo(-4,0);
    polygon.lineTo(-4,4);
    polygon.lineTo(4,0);
    polygon.lineTo(-4,-4);
    polygon.lineTo(-4,0);
    polygon.closePath();
    shape=polygon;
  }
 else   if (isOutput) {
    Polygon2D.Double polygon=new Polygon2D.Double();
    polygon.moveTo(4,0);
    polygon.lineTo(4,-4);
    polygon.lineTo(-4,0);
    polygon.lineTo(4,4);
    polygon.lineTo(4,0);
    polygon.closePath();
    shape=polygon;
  }
 else {
    shape=new Ellipse2D.Double(-4,-4,8,8);
  }
  Color fill;
  if (port instanceof ParameterPort) {
    fill=Color.lightGray;
  }
 else   if (port instanceof IOPort && ((IOPort)port).isMultiport()) {
    fill=Color.white;
  }
 else {
    fill=Color.black;
  }
  try {
    if (port instanceof IOPort) {
      List<MonitoredQuantityManager> qmList;
      List list=((IOPort)port).getQuantityManagers();
      if (list != null) {
        qmList=new ArrayList(list);
        if (qmList != _qmList && qmList.size() > 0) {
          _qmList=qmList;
          if (((IOPort)port).isOutput()) {
            fill=qmList.get(0).color.asColor();
          }
 else {
            fill=qmList.get(qmList.size() - 1).color.asColor();
          }
          StringAttribute info=(StringAttribute)port.getAttribute("String_Node_Str");
          if (info == null) {
            info=new StringAttribute(port,"String_Node_Str");
          }
          StringBuffer qmStringBuffer=new StringBuffer();
          for (int j=0; j < qmList.size(); j++) {
            if (qmStringBuffer.length() > 0) {
              qmStringBuffer.append("String_Node_Str");
            }
            qmStringBuffer.append(qmList.get(j).getName());
          }
          info.setExpression("String_Node_Str" + qmStringBuffer.toString());
        }
      }
    }
  }
 catch (  IllegalActionException e1) {
    e1.printStackTrace();
  }
catch (  NameDuplicationException e) {
  }
  ColorAttribute colorAttribute;
  try {
    colorAttribute=(ColorAttribute)(port.getAttribute("String_Node_Str",ColorAttribute.class));
    if (colorAttribute != null) {
      Color color=colorAttribute.asColor();
      fill=color;
    }
  }
 catch (  IllegalActionException e1) {
    e1.printStackTrace();
  }
  int portRotation=_getCardinality(port);
  int direction=_getDirection(portRotation);
  double rotation=portRotation;
  AffineTransform transform=AffineTransform.getRotateInstance(Math.toRadians(rotation));
  shape=ShapeUtilities.transformModify(shape,transform);
  Figure figure=new BasicFigure(shape,fill,(float)1.5){
    public String getToolTipText(){
      String tipText=port.getName();
      String displayName=port.getDisplayName();
      if (!tipText.equals(displayName)) {
        tipText=displayName + "String_Node_Str" + tipText+ "String_Node_Str";
      }
      StringAttribute _explAttr=(StringAttribute)(port.getAttribute("String_Node_Str"));
      if (_explAttr != null) {
        tipText=_explAttr.getExpression();
      }
 else       if (port instanceof Typeable) {
        try {
          tipText=tipText + "String_Node_Str" + ((Typeable)port).getType();
        }
 catch (        IllegalActionException ex) {
        }
      }
      return tipText;
    }
  }
;
  String tipText=port.getName();
  String displayName=port.getDisplayName();
  if (!tipText.equals(displayName)) {
    tipText=displayName + "String_Node_Str" + tipText+ "String_Node_Str";
  }
  figure.setToolTipText(tipText);
  double normal=CanvasUtilities.getNormal(direction);
  if (port instanceof IOPort) {
    IOPort ioPort=(IOPort)port;
    if (ioPort.isMultiport()) {
      int numberOfLinks=ioPort.linkedRelationList().size();
      if (numberOfLinks > 1) {
        CompositeFigure compositeFigure=new CompositeFigure(figure){
          public String getToolTipText(){
            String tipText=port.getName();
            String displayName=port.getDisplayName();
            if (!tipText.equals(displayName)) {
              tipText=displayName + "String_Node_Str" + tipText+ "String_Node_Str";
            }
            StringAttribute _explAttr=(StringAttribute)(port.getAttribute("String_Node_Str"));
            if (_explAttr != null) {
              tipText=_explAttr.getExpression();
            }
 else             if (port instanceof Typeable) {
              try {
                tipText=tipText + "String_Node_Str" + ((Typeable)port).getType();
              }
 catch (              IllegalActionException ex) {
              }
            }
            return tipText;
          }
        }
;
        double startX;
        double startY;
        double endX;
        double endY;
        Rectangle2D bounds=figure.getShape().getBounds2D();
        double x=bounds.getX();
        double y=bounds.getY();
        double width=bounds.getWidth();
        double height=bounds.getHeight();
        int extent=numberOfLinks - 1;
        if (direction == SwingConstants.EAST) {
          startX=x + width;
          startY=y + (height / 2);
          endX=startX + (extent * MULTIPORT_CONNECTION_SPACING);
          endY=startY + (extent * MULTIPORT_CONNECTION_SPACING);
        }
 else         if (direction == SwingConstants.WEST) {
          startX=x;
          startY=y + (height / 2);
          endX=startX - (extent * MULTIPORT_CONNECTION_SPACING);
          endY=startY - (extent * MULTIPORT_CONNECTION_SPACING);
        }
 else         if (direction == SwingConstants.NORTH) {
          startX=x + (width / 2);
          startY=y;
          endX=startX - (extent * MULTIPORT_CONNECTION_SPACING);
          endY=startY - (extent * MULTIPORT_CONNECTION_SPACING);
        }
 else {
          startX=x + (width / 2);
          startY=y + height;
          endX=startX + (extent * MULTIPORT_CONNECTION_SPACING);
          endY=startY + (extent * MULTIPORT_CONNECTION_SPACING);
        }
        Line2D line=new Line2D.Double(startX,startY,endX,endY);
        Figure lineFigure=new BasicFigure(line,fill,(float)2.0);
        compositeFigure.add(lineFigure);
        figure=compositeFigure;
      }
    }
    figure=_decoratePortFigure(n,figure);
    figure=new PortTerminal(ioPort,figure,normal,false);
  }
 else {
    figure=_decoratePortFigure(n,figure);
    Site tsite=new PerimeterSite(figure,0);
    tsite.setNormal(normal);
    figure=new TerminalFigure(figure,tsite);
  }
  try {
    ColorAttribute highlightAttribute=(ColorAttribute)(port.getAttribute("String_Node_Str",ColorAttribute.class));
    if (highlightAttribute != null && !highlightAttribute.getExpression().trim().equals("String_Node_Str")) {
      Color color=highlightAttribute.asColor();
      AnimationRenderer animationRenderer=new AnimationRenderer(color);
      animationRenderer.renderSelected(figure);
    }
  }
 catch (  IllegalActionException e) {
  }
  return figure;
}