Program: 68699
Project: 68699
Buggy source:
private Chart getConvertedChart(Chart currentChart,String sNewSubType,String sNewDimension){
  Chart helperModel=currentChart.copyInstance();
  ChartCacheManager.getInstance().cacheSeries(ChartUIUtil.getAllOrthogonalSeriesDefinitions(helperModel));
  IChartType oldType=ChartUIUtil.getChartType(currentChart.getType());
  if (currentChart instanceof ChartWithAxes) {
    if (!ChartPreviewPainter.isLivePreviewActive()) {
      helperModel.setSampleData(getConvertedSampleData(helperModel.getSampleData(),((ChartWithAxes)currentChart).getAxes().get(0).getType()));
    }
    currentChart=ChartWithoutAxesImpl.create();
    currentChart.setType(getName());
    currentChart.setSubType(sNewSubType);
    currentChart.setDimension(getDimensionFor(sNewDimension));
    currentChart.setBlock(helperModel.getBlock());
    currentChart.setDescription(helperModel.getDescription());
    currentChart.setGridColumnCount(helperModel.getGridColumnCount());
    if (helperModel.getInteractivity() != null) {
      currentChart.getInteractivity().setEnable(helperModel.getInteractivity().isEnable());
      currentChart.getInteractivity().setLegendBehavior(helperModel.getInteractivity().getLegendBehavior());
    }
    currentChart.setSampleData(helperModel.getSampleData());
    currentChart.setScript(helperModel.getScript());
    if (helperModel.isSetSeriesThickness()) {
      currentChart.setSeriesThickness(helperModel.getSeriesThickness());
    }
 else {
      currentChart.setSeriesThickness(15);
    }
    currentChart.setUnits(helperModel.getUnits());
    if (helperModel.getGridColumnCount() > 0) {
      currentChart.setGridColumnCount(helperModel.getGridColumnCount());
    }
 else {
      currentChart.setGridColumnCount(0);
    }
    ((ChartWithoutAxes)currentChart).getSeriesDefinitions().add(((Axis)((ChartWithAxes)helperModel).getAxes().get(0)).getSeriesDefinitions().get(0));
    Vector vOSD=new Vector();
    Axis primaryOrthogonalAxis=((ChartWithAxes)helperModel).getPrimaryOrthogonalAxis((Axis)((ChartWithAxes)helperModel).getAxes().get(0));
    EList osd=primaryOrthogonalAxis.getSeriesDefinitions();
    for (int j=0; j < osd.size(); j++) {
      SeriesDefinition sd=(SeriesDefinition)osd.get(j);
      Series series=sd.getDesignTimeSeries();
      sd.getSeries().clear();
      sd.getSeries().add(getConvertedSeries(series,j));
      vOSD.add(sd);
    }
    ((SeriesDefinition)((ChartWithoutAxes)currentChart).getSeriesDefinitions().get(0)).getSeriesDefinitions().clear();
    ((SeriesDefinition)((ChartWithoutAxes)currentChart).getSeriesDefinitions().get(0)).getSeriesDefinitions().addAll(vOSD);
    currentChart.getLegend().setItemType(LegendItemType.CATEGORIES_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());
    }
  }
 else   if (currentChart instanceof ChartWithoutAxes) {
    if (currentChart.getType().equals(getName())) {
      currentChart.setSubType(sNewSubType);
      if (!currentChart.getDimension().equals(getDimensionFor(sNewDimension))) {
        currentChart.setDimension(getDimensionFor(sNewDimension));
      }
      if (!currentChart.isSetSeriesThickness()) {
        currentChart.setSeriesThickness(15);
      }
    }
 else {
      currentChart=ChartWithoutAxesImpl.create();
      currentChart.setType(getName());
      currentChart.setSubType(sNewSubType);
      currentChart.setDimension(getDimensionFor(sNewDimension));
      currentChart.setBlock(helperModel.getBlock());
      currentChart.setDescription(helperModel.getDescription());
      currentChart.setGridColumnCount(helperModel.getGridColumnCount());
      currentChart.setSampleData(helperModel.getSampleData());
      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());
      }
      ((ChartWithoutAxes)currentChart).getSeriesDefinitions().clear();
      ((ChartWithoutAxes)currentChart).getSeriesDefinitions().addAll(((ChartWithoutAxes)helperModel).getSeriesDefinitions());
      EList seriesdefinitions=((SeriesDefinition)((ChartWithoutAxes)currentChart).getSeriesDefinitions().get(0)).getSeriesDefinitions();
      for (int j=0; j < seriesdefinitions.size(); j++) {
        Series series=((SeriesDefinition)seriesdefinitions.get(j)).getDesignTimeSeries();
        series=getConvertedSeries(series,j);
        ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().clear();
        ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().add(series);
      }
      currentChart.getLegend().setItemType(LegendItemType.CATEGORIES_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());
      }
    }
  }
 else {
    return null;
  }
  return currentChart;
}

Fixed version (ground truth):
private Chart getConvertedChart(Chart currentChart,String sNewSubType,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) {
    if (!ChartPreviewPainter.isLivePreviewActive()) {
      helperModel.setSampleData(getConvertedSampleData(helperModel.getSampleData(),((ChartWithAxes)currentChart).getAxes().get(0).getType()));
    }
    currentChart=ChartWithoutAxesImpl.create();
    currentChart.eAdapters().addAll(helperModel.eAdapters());
    currentChart.setType(getName());
    currentChart.setSubType(sNewSubType);
    currentChart.setDimension(getDimensionFor(sNewDimension));
    currentChart.setBlock(helperModel.getBlock());
    currentChart.setDescription(helperModel.getDescription());
    currentChart.setGridColumnCount(helperModel.getGridColumnCount());
    if (helperModel.getInteractivity() != null) {
      currentChart.getInteractivity().setEnable(helperModel.getInteractivity().isEnable());
      currentChart.getInteractivity().setLegendBehavior(helperModel.getInteractivity().getLegendBehavior());
    }
    currentChart.setSampleData(helperModel.getSampleData());
    currentChart.setScript(helperModel.getScript());
    if (helperModel.isSetSeriesThickness()) {
      currentChart.setSeriesThickness(helperModel.getSeriesThickness());
    }
 else {
      currentChart.setSeriesThickness(15);
    }
    currentChart.setUnits(helperModel.getUnits());
    if (helperModel.getGridColumnCount() > 0) {
      currentChart.setGridColumnCount(helperModel.getGridColumnCount());
    }
 else {
      currentChart.setGridColumnCount(0);
    }
    ((ChartWithoutAxes)currentChart).getSeriesDefinitions().add(((Axis)((ChartWithAxes)helperModel).getAxes().get(0)).getSeriesDefinitions().get(0));
    Vector vOSD=new Vector();
    Axis primaryOrthogonalAxis=((ChartWithAxes)helperModel).getPrimaryOrthogonalAxis((Axis)((ChartWithAxes)helperModel).getAxes().get(0));
    EList osd=primaryOrthogonalAxis.getSeriesDefinitions();
    for (int j=0; j < osd.size(); j++) {
      SeriesDefinition sd=(SeriesDefinition)osd.get(j);
      Series series=sd.getDesignTimeSeries();
      sd.getSeries().clear();
      sd.getSeries().add(getConvertedSeries(series,j));
      vOSD.add(sd);
    }
    ((SeriesDefinition)((ChartWithoutAxes)currentChart).getSeriesDefinitions().get(0)).getSeriesDefinitions().clear();
    ((SeriesDefinition)((ChartWithoutAxes)currentChart).getSeriesDefinitions().get(0)).getSeriesDefinitions().addAll(vOSD);
    currentChart.getLegend().setItemType(LegendItemType.CATEGORIES_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());
    }
  }
 else   if (currentChart instanceof ChartWithoutAxes) {
    if (currentChart.getType().equals(getName())) {
      currentChart.setSubType(sNewSubType);
      if (!currentChart.getDimension().equals(getDimensionFor(sNewDimension))) {
        currentChart.setDimension(getDimensionFor(sNewDimension));
      }
      if (!currentChart.isSetSeriesThickness()) {
        currentChart.setSeriesThickness(15);
      }
    }
 else {
      currentChart=ChartWithoutAxesImpl.create();
      currentChart.eAdapters().addAll(helperModel.eAdapters());
      currentChart.setType(getName());
      currentChart.setSubType(sNewSubType);
      currentChart.setDimension(getDimensionFor(sNewDimension));
      currentChart.setBlock(helperModel.getBlock());
      currentChart.setDescription(helperModel.getDescription());
      currentChart.setGridColumnCount(helperModel.getGridColumnCount());
      currentChart.setSampleData(helperModel.getSampleData());
      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());
      }
      ((ChartWithoutAxes)currentChart).getSeriesDefinitions().clear();
      ((ChartWithoutAxes)currentChart).getSeriesDefinitions().addAll(((ChartWithoutAxes)helperModel).getSeriesDefinitions());
      EList seriesdefinitions=((SeriesDefinition)((ChartWithoutAxes)currentChart).getSeriesDefinitions().get(0)).getSeriesDefinitions();
      for (int j=0; j < seriesdefinitions.size(); j++) {
        Series series=((SeriesDefinition)seriesdefinitions.get(j)).getDesignTimeSeries();
        series=getConvertedSeries(series,j);
        ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().clear();
        ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().add(series);
      }
      currentChart.getLegend().setItemType(LegendItemType.CATEGORIES_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());
      }
    }
  }
 else {
    return null;
  }
  return currentChart;
}