Program: 68027
Project: 68027
Buggy source:
private Chart getConvertedChart(Chart currentChart,String sNewSubType,Orientation newOrientation,String sNewDimension){
  Chart helperModel=currentChart.copyInstance();
  helperModel.eAdapters().addAll(currentChart.eAdapters());
  ChartCacheManager.getInstance().cacheSeries(ChartUIUtil.getAllOrthogonalSeriesDefinitions(helperModel));
  IChartType oldType=ChartUIUtil.getChartType(currentChart.getType());
  if ((currentChart instanceof ChartWithAxes)) {
    Axis xAxis=((ChartWithAxes)currentChart).getAxes().get(0);
    if (currentChart.getType().equals(TYPE_LITERAL)) {
      if (!currentChart.getSubType().equals(sNewSubType)) {
        currentChart.setSubType(sNewSubType);
        for (        Axis yAxis : xAxis.getAssociatedAxes()) {
          yAxis.setPercent(false);
          for (          SeriesDefinition ysd : yAxis.getSeriesDefinitions()) {
            Series series=ysd.getDesignTimeSeries();
            series.setStacked(false);
            if (series instanceof StockSeries) {
              ((StockSeries)series).setShowAsBarStick(BAR_STICK_SUBTYPE_LITERAL.equals(currentChart.getSubType()));
            }
          }
        }
      }
    }
 else {
      if (!currentChart.getType().equals(TYPE_LITERAL)) {
        currentChart.setSampleData(getConvertedSampleData(currentChart.getSampleData(),false));
      }
      currentChart.setType(TYPE_LITERAL);
      Text title=currentChart.getTitle().getLabel().getCaption();
      if (title.getValue() == null || title.getValue().trim().length() == 0 || title.getValue().trim().equals(oldType.getDefaultTitle().trim())) {
        title.setValue(getDefaultTitle());
      }
      xAxis.setCategoryAxis(true);
      currentChart.setSubType(sNewSubType);
      int seriesIndex=0;
      for (      Axis yAxis : xAxis.getAssociatedAxes()) {
        if (!ChartPreviewPainter.isLivePreviewActive()) {
          yAxis.setType(AxisType.LINEAR_LITERAL);
        }
        yAxis.setPercent(false);
        for (        SeriesDefinition ysd : yAxis.getSeriesDefinitions()) {
          Series series=ysd.getDesignTimeSeries();
          series=getConvertedSeries(series,seriesIndex);
          series.setStacked(false);
          ysd.getSeries().clear();
          ysd.getSeries().add(series);
          seriesIndex++;
        }
      }
    }
  }
 else {
    currentChart=ChartWithAxesImpl.create();
    currentChart.eAdapters().addAll(helperModel.eAdapters());
    currentChart.setType(TYPE_LITERAL);
    currentChart.setSubType(sNewSubType);
    ((ChartWithAxes)currentChart).setOrientation(newOrientation);
    currentChart.setDimension(getDimensionFor(sNewDimension));
    Axis xAxis=((ChartWithAxes)currentChart).getAxes().get(0);
    xAxis.setOrientation(Orientation.HORIZONTAL_LITERAL);
    xAxis.setCategoryAxis(true);
    Axis yAxis=xAxis.getAssociatedAxes().get(0);
    yAxis.setOrientation(Orientation.VERTICAL_LITERAL);
    yAxis.setType(AxisType.LINEAR_LITERAL);
    currentChart.setBlock(helperModel.getBlock());
    currentChart.setDescription(helperModel.getDescription());
    currentChart.setGridColumnCount(helperModel.getGridColumnCount());
    currentChart.setSampleData(getConvertedSampleData(helperModel.getSampleData(),true));
    currentChart.setScript(helperModel.getScript());
    currentChart.setSeriesThickness(helperModel.getSeriesThickness());
    currentChart.setUnits(helperModel.getUnits());
    if (helperModel.getInteractivity() != null) {
      currentChart.getInteractivity().setEnable(helperModel.getInteractivity().isEnable());
      currentChart.getInteractivity().setLegendBehavior(helperModel.getInteractivity().getLegendBehavior());
    }
    if (helperModel.getType().equals(PieChart.TYPE_LITERAL) || helperModel.getType().equals(MeterChart.TYPE_LITERAL)) {
      xAxis.getSeriesDefinitions().clear();
      xAxis.getSeriesDefinitions().add(((ChartWithoutAxes)helperModel).getSeriesDefinitions().get(0));
      yAxis.getSeriesDefinitions().clear();
      yAxis.getSeriesDefinitions().addAll(xAxis.getSeriesDefinitions().get(0).getSeriesDefinitions());
      SeriesDefinition bsd=xAxis.getSeriesDefinitions().get(0);
      Series series=bsd.getDesignTimeSeries();
      bsd.getSeries().clear();
      bsd.getSeries().add(series);
      int j=0;
      for (      SeriesDefinition vsd : yAxis.getSeriesDefinitions()) {
        series=vsd.getDesignTimeSeries();
        series=getConvertedSeries(series,j++);
        series.getLabel().setVisible(false);
        series.setStacked(false);
        vsd.getSeries().clear();
        vsd.getSeries().add(series);
      }
    }
 else {
      return null;
    }
    currentChart.getLegend().setItemType(LegendItemType.SERIES_LITERAL);
    Text title=currentChart.getTitle().getLabel().getCaption();
    if (title.getValue() == null || title.getValue().trim().length() == 0 || title.getValue().trim().equals(oldType.getDefaultTitle().trim())) {
      title.setValue(getDefaultTitle());
    }
  }
  if (!((ChartWithAxes)currentChart).getOrientation().equals(newOrientation)) {
    ((ChartWithAxes)currentChart).setOrientation(newOrientation);
  }
  if (!currentChart.getDimension().equals(getDimensionFor(sNewDimension))) {
    currentChart.setDimension(getDimensionFor(sNewDimension));
  }
  ChartUIUtil.restoreLabelPositionFromCache(currentChart);
  SeriesGrouping sg=ChartUtil.getBaseSeriesDefinitions(currentChart).get(0).getGrouping();
  if (sg.getGroupType().getValue() == DataType.DATE_TIME) {
    ChartUIUtil.updateDefaultAggregations(currentChart);
  }
  return currentChart;
}

Fixed version (ground truth):
private Chart getConvertedChart(Chart currentChart,String sNewSubType,Orientation newOrientation,String sNewDimension){
  Chart helperModel=currentChart.copyInstance();
  helperModel.eAdapters().addAll(currentChart.eAdapters());
  ChartCacheManager.getInstance().cacheSeries(ChartUIUtil.getAllOrthogonalSeriesDefinitions(helperModel));
  IChartType oldType=ChartUIUtil.getChartType(currentChart.getType());
  if ((currentChart instanceof ChartWithAxes)) {
    Axis xAxis=((ChartWithAxes)currentChart).getAxes().get(0);
    if (currentChart.getType().equals(TYPE_LITERAL)) {
      if (!currentChart.getSubType().equals(sNewSubType)) {
        currentChart.setSubType(sNewSubType);
        for (        Axis yAxis : xAxis.getAssociatedAxes()) {
          yAxis.setPercent(false);
          for (          SeriesDefinition ysd : yAxis.getSeriesDefinitions()) {
            Series series=ysd.getDesignTimeSeries();
            series.setStacked(false);
            if (series instanceof StockSeries) {
              ((StockSeries)series).setShowAsBarStick(BAR_STICK_SUBTYPE_LITERAL.equals(currentChart.getSubType()));
            }
          }
        }
      }
    }
 else {
      if (!currentChart.getType().equals(TYPE_LITERAL)) {
        currentChart.setSampleData(getConvertedSampleData(currentChart.getSampleData(),false));
      }
      currentChart.setType(TYPE_LITERAL);
      Text title=currentChart.getTitle().getLabel().getCaption();
      if (title.getValue() == null || title.getValue().trim().length() == 0 || title.getValue().trim().equals(oldType.getDefaultTitle().trim())) {
        title.setValue(getDefaultTitle());
      }
      xAxis.setCategoryAxis(true);
      currentChart.setSubType(sNewSubType);
      int seriesIndex=0;
      for (      Axis yAxis : xAxis.getAssociatedAxes()) {
        if (!ChartPreviewPainter.isLivePreviewActive()) {
          yAxis.setType(AxisType.LINEAR_LITERAL);
        }
        yAxis.setPercent(false);
        for (        SeriesDefinition ysd : yAxis.getSeriesDefinitions()) {
          Series series=ysd.getDesignTimeSeries();
          series=getConvertedSeries(series,seriesIndex);
          series.setStacked(false);
          ysd.getSeries().clear();
          ysd.getSeries().add(series);
          seriesIndex++;
        }
      }
    }
  }
 else {
    currentChart=ChartWithAxesImpl.create();
    currentChart.eAdapters().addAll(helperModel.eAdapters());
    currentChart.setType(TYPE_LITERAL);
    currentChart.setSubType(sNewSubType);
    ((ChartWithAxes)currentChart).setOrientation(newOrientation);
    currentChart.setDimension(getDimensionFor(sNewDimension));
    Axis xAxis=((ChartWithAxes)currentChart).getAxes().get(0);
    xAxis.setOrientation(Orientation.HORIZONTAL_LITERAL);
    xAxis.setCategoryAxis(true);
    Axis yAxis=xAxis.getAssociatedAxes().get(0);
    yAxis.setOrientation(Orientation.VERTICAL_LITERAL);
    yAxis.setType(AxisType.LINEAR_LITERAL);
    currentChart.setBlock(helperModel.getBlock());
    currentChart.setDescription(helperModel.getDescription());
    currentChart.setGridColumnCount(helperModel.getGridColumnCount());
    currentChart.setSampleData(getConvertedSampleData(helperModel.getSampleData(),true));
    currentChart.setScript(helperModel.getScript());
    currentChart.setSeriesThickness(helperModel.getSeriesThickness());
    currentChart.setUnits(helperModel.getUnits());
    if (helperModel.getInteractivity() != null) {
      currentChart.getInteractivity().setEnable(helperModel.getInteractivity().isEnable());
      currentChart.getInteractivity().setLegendBehavior(helperModel.getInteractivity().getLegendBehavior());
    }
{
      xAxis.getSeriesDefinitions().clear();
      xAxis.getSeriesDefinitions().add(((ChartWithoutAxes)helperModel).getSeriesDefinitions().get(0));
      yAxis.getSeriesDefinitions().clear();
      yAxis.getSeriesDefinitions().addAll(xAxis.getSeriesDefinitions().get(0).getSeriesDefinitions());
      SeriesDefinition bsd=xAxis.getSeriesDefinitions().get(0);
      Series series=bsd.getDesignTimeSeries();
      bsd.getSeries().clear();
      bsd.getSeries().add(series);
      int j=0;
      for (      SeriesDefinition vsd : yAxis.getSeriesDefinitions()) {
        series=vsd.getDesignTimeSeries();
        series=getConvertedSeries(series,j++);
        series.getLabel().setVisible(false);
        series.setStacked(false);
        vsd.getSeries().clear();
        vsd.getSeries().add(series);
      }
    }
    currentChart.getLegend().setItemType(LegendItemType.SERIES_LITERAL);
    Text title=currentChart.getTitle().getLabel().getCaption();
    if (title.getValue() == null || title.getValue().trim().length() == 0 || title.getValue().trim().equals(oldType.getDefaultTitle().trim())) {
      title.setValue(getDefaultTitle());
    }
  }
  if (!((ChartWithAxes)currentChart).getOrientation().equals(newOrientation)) {
    ((ChartWithAxes)currentChart).setOrientation(newOrientation);
  }
  if (!currentChart.getDimension().equals(getDimensionFor(sNewDimension))) {
    currentChart.setDimension(getDimensionFor(sNewDimension));
  }
  ChartUIUtil.restoreLabelPositionFromCache(currentChart);
  SeriesGrouping sg=ChartUtil.getBaseSeriesDefinitions(currentChart).get(0).getGrouping();
  if (sg.getGroupType().getValue() == DataType.DATE_TIME) {
    ChartUIUtil.updateDefaultAggregations(currentChart);
  }
  return currentChart;
}