Program: 12102
Project: 12102
Buggy source:
public FeatureEnvyDiagram(FeatureEnvyVisualizationData data){
  root=new LayeredPane();
  primary=new Layer();
  primary.setLayoutManager(new XYLayout());
  root.setFont(Display.getDefault().getSystemFont());
  root.add(primary,"String_Node_Str");
  connections=new ConnectionLayer();
  final ClassFigure source=new ClassFigure(data.getSourceClass().getName(),ClassFigure.classColor);
  source.setToolTip(new Label("String_Node_Str"));
  source.addThreeCompartments();
  final ClassFigure target=new ClassFigure(data.getTargetClass().getName(),ClassFigure.classColor);
  target.addTwoCompartments();
  target.setToolTip(new Label("String_Node_Str"));
  EntityFigure extractMethod=new EntityFigure(data.getMethodToBeMoved().getName(),EntityFigure.METHOD);
  new ClassFigureMover(extractMethod);
  extractMethod.setLabelAlignment(2);
  extractMethod.setToolTip(new Label("String_Node_Str"));
  Font font=new Font(null,"String_Node_Str",10,SWT.BOLD);
  extractMethod.setFont(font);
  EntityFigure extractMethod1=new EntityFigure(data.getMethodToBeMoved().getName(),EntityFigure.METHOD);
  extractMethod1.setFont(font);
  extractMethod1.setLabelAlignment(2);
  extractMethod1.setBorder(new SimpleRaisedBorder(3));
  source.getExtractMethodCompartment().add(extractMethod1);
  int size=data.getSourceMethodInvocationMap().size();
  float interval1=0.1f / size;
  float weight=0.3f;
  for (  Entry<MethodInvocationObject,Integer> entry : data.getSourceMethodInvocationMap().entrySet()) {
    MethodInvocationObject method=entry.getKey();
    Integer occurences=entry.getValue();
    weight=weight - interval1;
    EntityFigure methodFigure=new EntityFigure(method.getSignature(),EntityFigure.METHOD);
    source.getMethodsCompartment().add(methodFigure);
    JConnection connection=extractMethod.addToSourceMethodConnection(ConnectionType.METHOD_CALL_SOURCE,methodFigure,occurences);
    connectionList.add(connection);
    connections.add(connection);
  }
  for (  Entry<MethodInvocationObject,Integer> entry : data.getTargetMethodInvocationMap().entrySet()) {
    MethodInvocationObject method=entry.getKey();
    Integer occurences=entry.getValue();
    EntityFigure methodFigure=new EntityFigure(method.getSignature(),EntityFigure.METHOD);
    target.getMethodsCompartment().add(methodFigure);
    JConnection connection=extractMethod.addToTargetMethodConnection(ConnectionType.METHOD_CALL_TARGET,methodFigure,occurences);
    connectionList.add(connection);
    connections.add(connection);
  }
  weight=0.2f;
  float interval2=0.1f / data.getSourceFieldReadMap().size();
  for (  Entry<FieldInstructionObject,Integer> entry : data.getSourceFieldReadMap().entrySet()) {
    FieldInstructionObject field=entry.getKey();
    Integer occurences=entry.getValue();
    weight=weight + interval2;
    EntityFigure fieldFigure=new EntityFigure(field.getName(),EntityFigure.FIELD);
    source.getFieldsCompartment().add(fieldFigure);
    JConnection connection=extractMethod.addToSourceWeakReadConnection(ConnectionType.READ_FIELD_SOURCE,fieldFigure,occurences);
    connectionList.add(connection);
    connections.add(connection);
  }
  float interval3=0.4f / data.getSourceFieldWriteMap().size();
  weight=0.2f;
  for (  Entry<FieldInstructionObject,Integer> entry : data.getSourceFieldWriteMap().entrySet()) {
    FieldInstructionObject field=entry.getKey();
    Integer occurences=entry.getValue();
    weight=weight + interval3;
    EntityFigure fieldFigure=new EntityFigure(field.getName(),EntityFigure.FIELD);
    boolean contains=false;
    for (    Object child : source.getFieldsCompartment().getChildren()) {
      EntityFigure entity=(EntityFigure)child;
      if (entity.getName().equals(fieldFigure.getName()))       contains=true;
      JConnection connection=extractMethod.addToSourceBendConnection(ConnectionType.WRITE_FIELD_SOURCE,entity,occurences);
      connectionList.add(connection);
      connections.add(connection);
    }
    if (!contains) {
      source.getFieldsCompartment().add(fieldFigure);
      JConnection connection=extractMethod.addToSourceWeakWriteConnection(ConnectionType.WRITE_FIELD_SOURCE,fieldFigure,occurences);
      connectionList.add(connection);
      connections.add(connection);
    }
  }
  for (  Entry<FieldInstructionObject,Integer> entry : data.getTargetFieldReadMap().entrySet()) {
    FieldInstructionObject field=entry.getKey();
    Integer occurences=entry.getValue();
    EntityFigure fieldFigure=new EntityFigure(field.getName(),EntityFigure.FIELD);
    target.getFieldsCompartment().add(fieldFigure);
    JConnection connection=extractMethod.addToTargetReadConnection(ConnectionType.READ_FIELD_TARGET,fieldFigure,occurences);
    connectionList.add(connection);
    connections.add(connection);
  }
  for (  Entry<FieldInstructionObject,Integer> entry : data.getTargetFieldWriteMap().entrySet()) {
    FieldInstructionObject field=entry.getKey();
    Integer occurences=entry.getValue();
    EntityFigure fieldFigure=new EntityFigure(field.getName(),EntityFigure.FIELD);
    boolean contains=false;
    for (    Object child : target.getFieldsCompartment().getChildren()) {
      EntityFigure entity=(EntityFigure)child;
      if (entity.getName().equals(fieldFigure.getName())) {
        contains=true;
        JConnection connection=extractMethod.addToTargetBendConnection(ConnectionType.WRITE_FIELD_TARGET,entity,occurences);
        connectionList.add(connection);
        connections.add(connection);
      }
    }
    if (!contains) {
      target.getFieldsCompartment().add(fieldFigure);
      JConnection connection=extractMethod.addToTargetWriteConnection(ConnectionType.WRITE_FIELD_TARGET,fieldFigure,occurences);
      connectionList.add(connection);
      connections.add(connection);
    }
  }
  int classWidth=300;
  int startPointX=100;
  int startPointY=50;
  int methodWidth=150;
  int gap=100;
  extractMethod.setMaximumSize(new Dimension(methodWidth,-1));
  final Legend legend=new Legend(connectionList,false);
  int legendHeight=150;
  int legendWidth=275;
  int legendGap=200;
  primary.add(source,new Rectangle(startPointX,startPointY,classWidth,-1));
  primary.add(target,new Rectangle(startPointX + classWidth + methodWidth+ 2 * gap,startPointY,classWidth,-1));
  int sourceH=source.getPreferredSize().height;
  int targetH=target.getPreferredSize().height;
  primary.add(extractMethod,new Rectangle(startPointX + classWidth + gap,startPointY + Math.min(targetH,sourceH) / 2,-1,-1));
  primary.add(legend,new Rectangle(startPointX,sourceH + legendGap,legendWidth,legendHeight));
  root.add(connections,"String_Node_Str");
}

Fixed version (ground truth):
public FeatureEnvyDiagram(FeatureEnvyVisualizationData data){
  root=new LayeredPane();
  primary=new Layer();
  primary.setLayoutManager(new XYLayout());
  root.setFont(Display.getDefault().getSystemFont());
  root.add(primary,"String_Node_Str");
  connections=new ConnectionLayer();
  final ClassFigure source=new ClassFigure(data.getSourceClass().getName(),DecorationConstants.classColor);
  source.setToolTip(new Label("String_Node_Str"));
  source.addThreeCompartments();
  final ClassFigure target=new ClassFigure(data.getTargetClass().getName(),DecorationConstants.classColor);
  target.addTwoCompartments();
  target.setToolTip(new Label("String_Node_Str"));
  EntityFigure extractMethod=new EntityFigure(data.getMethodToBeMoved().getName(),DecorationConstants.METHOD);
  new ClassFigureMover(extractMethod);
  extractMethod.setLabelAlignment(2);
  extractMethod.setToolTip(new Label("String_Node_Str"));
  Font font=DecorationConstants.normalFont;
  extractMethod.setFont(font);
  EntityFigure extractMethod1=new EntityFigure(data.getMethodToBeMoved().getName(),DecorationConstants.METHOD);
  extractMethod1.setFont(font);
  extractMethod1.setLabelAlignment(2);
  extractMethod1.setBorder(new SimpleRaisedBorder(3));
  source.getExtractMethodCompartment().add(extractMethod1);
  int size=data.getSourceMethodInvocationMap().size();
  float interval1=0.1f / size;
  float weight=0.3f;
  for (  Entry<MethodInvocationObject,Integer> entry : data.getSourceMethodInvocationMap().entrySet()) {
    MethodInvocationObject method=entry.getKey();
    Integer occurences=entry.getValue();
    weight=weight - interval1;
    EntityFigure methodFigure=new EntityFigure(method.getSignature(),DecorationConstants.METHOD);
    source.getMethodsCompartment().add(methodFigure);
    JConnection connection=extractMethod.addToSourceMethodConnection(ConnectionType.METHOD_CALL_SOURCE,methodFigure,occurences);
    connectionList.add(connection);
    connections.add(connection);
  }
  for (  Entry<MethodInvocationObject,Integer> entry : data.getTargetMethodInvocationMap().entrySet()) {
    MethodInvocationObject method=entry.getKey();
    Integer occurences=entry.getValue();
    EntityFigure methodFigure=new EntityFigure(method.getSignature(),DecorationConstants.METHOD);
    target.getMethodsCompartment().add(methodFigure);
    JConnection connection=extractMethod.addToTargetMethodConnection(ConnectionType.METHOD_CALL_TARGET,methodFigure,occurences);
    connectionList.add(connection);
    connections.add(connection);
  }
  weight=0.2f;
  float interval2=0.1f / data.getSourceFieldReadMap().size();
  for (  Entry<FieldInstructionObject,Integer> entry : data.getSourceFieldReadMap().entrySet()) {
    FieldInstructionObject field=entry.getKey();
    Integer occurences=entry.getValue();
    weight=weight + interval2;
    EntityFigure fieldFigure=new EntityFigure(field.getName(),DecorationConstants.FIELD);
    source.getFieldsCompartment().add(fieldFigure);
    JConnection connection=extractMethod.addToSourceWeakReadConnection(ConnectionType.READ_FIELD_SOURCE,fieldFigure,occurences);
    connectionList.add(connection);
    connections.add(connection);
  }
  float interval3=0.4f / data.getSourceFieldWriteMap().size();
  weight=0.2f;
  for (  Entry<FieldInstructionObject,Integer> entry : data.getSourceFieldWriteMap().entrySet()) {
    FieldInstructionObject field=entry.getKey();
    Integer occurences=entry.getValue();
    weight=weight + interval3;
    EntityFigure fieldFigure=new EntityFigure(field.getName(),DecorationConstants.FIELD);
    boolean contains=false;
    for (    Object child : source.getFieldsCompartment().getChildren()) {
      EntityFigure entity=(EntityFigure)child;
      if (entity.getName().equals(fieldFigure.getName()))       contains=true;
      JConnection connection=extractMethod.addToSourceBendConnection(ConnectionType.WRITE_FIELD_SOURCE,entity,occurences);
      connectionList.add(connection);
      connections.add(connection);
    }
    if (!contains) {
      source.getFieldsCompartment().add(fieldFigure);
      JConnection connection=extractMethod.addToSourceWeakWriteConnection(ConnectionType.WRITE_FIELD_SOURCE,fieldFigure,occurences);
      connectionList.add(connection);
      connections.add(connection);
    }
  }
  for (  Entry<FieldInstructionObject,Integer> entry : data.getTargetFieldReadMap().entrySet()) {
    FieldInstructionObject field=entry.getKey();
    Integer occurences=entry.getValue();
    EntityFigure fieldFigure=new EntityFigure(field.getName(),DecorationConstants.FIELD);
    target.getFieldsCompartment().add(fieldFigure);
    JConnection connection=extractMethod.addToTargetReadConnection(ConnectionType.READ_FIELD_TARGET,fieldFigure,occurences);
    connectionList.add(connection);
    connections.add(connection);
  }
  for (  Entry<FieldInstructionObject,Integer> entry : data.getTargetFieldWriteMap().entrySet()) {
    FieldInstructionObject field=entry.getKey();
    Integer occurences=entry.getValue();
    EntityFigure fieldFigure=new EntityFigure(field.getName(),DecorationConstants.FIELD);
    boolean contains=false;
    for (    Object child : target.getFieldsCompartment().getChildren()) {
      EntityFigure entity=(EntityFigure)child;
      if (entity.getName().equals(fieldFigure.getName())) {
        contains=true;
        JConnection connection=extractMethod.addToTargetBendConnection(ConnectionType.WRITE_FIELD_TARGET,entity,occurences);
        connectionList.add(connection);
        connections.add(connection);
      }
    }
    if (!contains) {
      target.getFieldsCompartment().add(fieldFigure);
      JConnection connection=extractMethod.addToTargetWriteConnection(ConnectionType.WRITE_FIELD_TARGET,fieldFigure,occurences);
      connectionList.add(connection);
      connections.add(connection);
    }
  }
  int classWidth=300;
  int startPointX=100;
  int startPointY=50;
  int methodWidth=150;
  int gap=100;
  extractMethod.setMaximumSize(new Dimension(methodWidth,20));
  final Legend legend=new Legend(connectionList,false);
  int legendHeight=150;
  int legendWidth=275;
  int legendGap=200;
  primary.add(source,new Rectangle(startPointX,startPointY,classWidth,-1));
  primary.add(target,new Rectangle(startPointX + classWidth + methodWidth+ 2 * gap,startPointY,classWidth,-1));
  int sourceH=source.getPreferredSize().height;
  int targetH=target.getPreferredSize().height;
  primary.add(extractMethod,new Rectangle(startPointX + classWidth + gap,startPointY + Math.min(targetH,sourceH) / 2,-1,-1));
  primary.add(legend,new Rectangle(startPointX,sourceH + legendGap,legendWidth,legendHeight));
  root.add(connections,"String_Node_Str");
}