Program: 133503
Project: 133503
Buggy source:
/** 
 * Resets the entire graphical viewer with the current settings.
 */
private void resetViewer(){
  int size=assembly.getSize();
  int rows=size;
  int columns=size;
  int fullColumns=size;
  List<State> states;
  TreeSet<Integer> validLocations=new TreeSet<Integer>();
  fullIndices.clear();
  int rowMin=size - 1;
  int rowMax=0;
  int colMin=rowMin;
  int colMax=rowMax;
  if (symmetry == Symmetry.FULL) {
    for (int row=0; row < rows; row++) {
      for (int column=0; column < columns; column++) {
        validLocations.add(row * columns + column);
        fullIndices.add(row * columns + column);
      }
    }
    states=assemblyCellStates;
    rowMin=0;
    rowMax=rows - 1;
    colMin=0;
    colMax=columns - 1;
  }
 else {
    List<Point> locations;
    if (symmetry == Symmetry.QUARTER) {
      locations=GridEditorTools.getQuadrant(size,symmetryIndex);
    }
 else {
      locations=GridEditorTools.getOctant(size,symmetryIndex);
    }
    for (    Point p : locations) {
      if (p.y < rowMin) {
        rowMin=p.y;
      }
      if (p.y > rowMax) {
        rowMax=p.y;
      }
      if (p.x < colMin) {
        colMin=p.x;
      }
      if (p.x > colMax) {
        colMax=p.x;
      }
      validLocations.add(p.y * fullColumns + p.x);
    }
    size=(int)Math.ceil(size / 2.0);
    rows=size;
    columns=size;
    states=new ArrayList<State>(rows * columns);
    for (int row=0; row < rows; row++) {
      for (int col=0; col < columns; col++) {
        int fullIndex=(row + rowMin) * fullColumns + col + colMin;
        fullIndices.add(fullIndex);
        Cell.State state=assemblyCellStates.get(fullIndex);
        if (!validLocations.contains(fullIndex)) {
          state=State.INVALID;
        }
        states.add(state);
      }
    }
  }
  GridEditorInput input=new GridEditorInput(rows,columns);
  input.setStates(states);
  GridLabelProvider labelProvider=assembly.getGridLabelProvider();
  if (labelProvider != null) {
    List<String> labels=new ArrayList<String>();
    for (int row=rowMin; row <= rowMax; row++) {
      labels.add(labelProvider.getLabelFromRow(row));
    }
    if (!labels.contains(null)) {
      input.setRowLabels(labels);
    }
 else {
      input.showRowLabels=false;
    }
    labels.clear();
    for (int column=colMin; column <= colMax; column++) {
      labels.add(labelProvider.getLabelFromColumn(column));
    }
    if (!labels.contains(null)) {
      input.setColumnLabels(labels);
    }
 else {
      input.showColumnLabels=false;
    }
  }
  input.showCellLabels=false;
  grid=new Grid(input);
  GridEditorTools.setViewerContents(viewer,grid);
  Map<?,?> registry=viewer.getEditPartRegistry();
  List<Cell> cells=grid.getCells();
  figures.clear();
  for (int row=0; row < rows; row++) {
    for (int col=0; col < columns; col++) {
      int fullIndex=(row + rowMin) * fullColumns + col + colMin;
      int gridIndex=row * columns + col;
      LWRComponent lwrComp;
      if (validLocations.contains(fullIndex) && (lwrComp=assemblyLocations.get(fullIndex)) != null) {
        AssemblyCellEditPart editPart=(AssemblyCellEditPart)registry.get(cells.get(gridIndex));
        RodFigure figure=(RodFigure)editPart.getFigure();
        figures.add(figure);
        figure.setComponent(lwrComp,maxRadius);
        figure.setDataProvider(assemblyData.get(fullIndex));
        figure.setFeature(feature);
        figure.setAxialLevel(axialLevel);
        figure.setDisplayType(displayType);
        figure.setMinValue(customMinValue);
        figure.setMaxValue(customMaxValue);
        figure.useCustomExtrema(extrema != Extrema.PIECEWISE);
      }
    }
  }
  return;
}

Fixed version (ground truth):
/** 
 * Resets the entire graphical viewer with the current settings.
 */
private void resetViewer(){
  int size=assembly.getSize();
  int rows=size;
  int columns=size;
  int fullColumns=size;
  List<State> states;
  TreeSet<Integer> validLocations=new TreeSet<Integer>();
  fullIndices.clear();
  int rowMin=size - 1;
  int rowMax=0;
  int colMin=rowMin;
  int colMax=rowMax;
  if (symmetry == Symmetry.FULL) {
    for (int row=0; row < rows; row++) {
      for (int column=0; column < columns; column++) {
        validLocations.add(row * columns + column);
        fullIndices.add(row * columns + column);
      }
    }
    states=assemblyCellStates;
    rowMin=0;
    rowMax=rows - 1;
    colMin=0;
    colMax=columns - 1;
  }
 else {
    List<Point> locations;
    if (symmetry == Symmetry.QUARTER) {
      locations=GridEditorTools.getQuadrant(size,symmetryIndex);
    }
 else {
      locations=GridEditorTools.getOctant(size,symmetryIndex);
    }
    for (    Point p : locations) {
      if (p.y < rowMin) {
        rowMin=p.y;
      }
      if (p.y > rowMax) {
        rowMax=p.y;
      }
      if (p.x < colMin) {
        colMin=p.x;
      }
      if (p.x > colMax) {
        colMax=p.x;
      }
      validLocations.add(p.y * fullColumns + p.x);
    }
    size=(int)Math.ceil(size / 2.0);
    rows=size;
    columns=size;
    states=new ArrayList<State>(rows * columns);
    for (int row=0; row < rows; row++) {
      for (int col=0; col < columns; col++) {
        int fullIndex=(row + rowMin) * fullColumns + col + colMin;
        fullIndices.add(fullIndex);
        Cell.State state=assemblyCellStates.get(fullIndex);
        if (!validLocations.contains(fullIndex)) {
          state=State.INVALID;
        }
        states.add(state);
      }
    }
  }
  GridEditorInput input=new GridEditorInput(rows,columns);
  input.setStates(states);
  GridLabelProvider labelProvider=assembly.getGridLabelProvider();
  if (labelProvider != null) {
    List<String> labels=new ArrayList<String>();
    for (int row=rowMin; row <= rowMax; row++) {
      labels.add(labelProvider.getLabelFromRow(row));
    }
    if (!labels.contains(null)) {
      input.setRowLabels(labels);
    }
 else {
      input.showRowLabels=false;
    }
    labels.clear();
    for (int column=colMin; column <= colMax; column++) {
      labels.add(labelProvider.getLabelFromColumn(column));
    }
    if (!labels.contains(null)) {
      input.setColumnLabels(labels);
    }
 else {
      input.showColumnLabels=false;
    }
  }
  input.showCellLabels=false;
  grid=new Grid(input);
  GridEditorTools.setViewerContents(viewer,grid);
  Map<?,?> registry=viewer.getEditPartRegistry();
  List<Cell> cells=grid.getCells();
  figures.clear();
  for (int row=0; row < rows; row++) {
    for (int col=0; col < columns; col++) {
      int fullIndex=(row + rowMin) * fullColumns + col + colMin;
      int gridIndex=row * columns + col;
      LWRComponent lwrComp;
      if (validLocations.contains(fullIndex) && (lwrComp=assemblyLocations.get(fullIndex)) != null) {
        AssemblyCellEditPart editPart=(AssemblyCellEditPart)registry.get(cells.get(gridIndex));
        RodFigure figure=(RodFigure)editPart.getFigure();
        figures.add(figure);
        figure.setColorFactory(colorFactory);
        figure.setComponent(lwrComp,maxRadius);
        figure.setDataProvider(assemblyData.get(fullIndex));
        figure.setFeature(feature);
        figure.setAxialLevel(axialLevel);
        figure.setDisplayType(displayType);
        figure.setMinValue(customMinValue);
        figure.setMaxValue(customMaxValue);
        figure.useCustomExtrema(extrema != Extrema.PIECEWISE);
      }
    }
  }
  return;
}