Program: 168411
Project: 168411
Buggy source:
/** 
 * Draws the overview diagram according to the current selections.
 */
private void updateDiagram(){
  updateSelectionControlsState();
  TimeRangeType timeType=getCurrentTimeRangeType();
  ValueType vType=getCurrentValueType();
  String vTypeName=getCurrentValueTypeName();
  int year=((Number)spYear.getValue()).intValue();
  TimeTableXYDataset dataset=new TimeTableXYDataset();
  List<Color> lGraphColors=new ArrayList<>();
  if (getCurrentValueType() == ValueType.EQUIPMENT) {
    SportType sportType=document.getSportTypeList().getAt(cbSportTypeList.getSelectedIndex());
    for (    Equipment equipment : sportType.getEquipmentList()) {
      addEquipmentTimeSeries(dataset,timeType,year,sportType,equipment);
    }
    addEquipmentTimeSeries(dataset,timeType,year,sportType,null);
    for (int i=1; i <= 8; i++) {
      lGraphColors.add(context.getResReader().getColor("String_Node_Str" + i));
    }
  }
 else   if (getCurrentValueType() != ValueType.WEIGHT) {
switch ((OverviewType)cbSportTypeMode.getSelectedItem()) {
case ALL_SUMMARY:
case EACH_STACKED:
      addExerciseTimeSeries(dataset,timeType,year,vType,null);
    lGraphColors.add(context.getResReader().getColor("String_Node_Str"));
  break;
case EACH_SPLITTED:
for (SportType sportType : document.getSportTypeList()) {
  addExerciseTimeSeries(dataset,timeType,year,vType,sportType);
  lGraphColors.add(sportType.getColor());
}
break;
}
}
 else {
addWeightTimeSeries(dataset,timeType,year);
lGraphColors.add(context.getResReader().getColor("String_Node_Str"));
}
JFreeChart chart=ChartFactory.createTimeSeriesChart(null,null,vTypeName,dataset,true,true,false);
ChartUtils.customizeChart(chart,chartPanel);
XYPlot plot=(XYPlot)chart.getPlot();
XYLineAndShapeRenderer renderer=(XYLineAndShapeRenderer)plot.getRenderer();
renderer.setBaseShapesVisible(true);
renderer.setBaseShapesFilled(true);
for (int i=0; i < lGraphColors.size(); i++) {
Color tempColor=lGraphColors.get(i);
renderer.setSeriesPaint(i,tempColor);
}
String dateFormatTooltip=null;
String dateFormatAxis=null;
DateTickUnit dateTickUnit=null;
switch (timeType) {
case LAST_12_MONTHS:
dateFormatTooltip="String_Node_Str";
dateFormatAxis="String_Node_Str";
dateTickUnit=new DateTickUnit(DateTickUnitType.MONTH,1);
break;
case MONTHS_OF_YEAR:
dateFormatTooltip="String_Node_Str";
dateFormatAxis="String_Node_Str";
dateTickUnit=new DateTickUnit(DateTickUnitType.MONTH,1);
break;
case WEEKS_OF_YEAR:
dateFormatTooltip="String_Node_Str";
dateFormatAxis="String_Node_Str";
dateTickUnit=new DateTickUnit(DateTickUnitType.YEAR,2);
break;
default :
dateFormatTooltip="String_Node_Str";
dateFormatAxis="String_Node_Str";
dateTickUnit=new DateTickUnit(DateTickUnitType.YEAR,1);
break;
}
String toolTipFormat="String_Node_Str";
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator(toolTipFormat,new SimpleDateFormat(dateFormatTooltip),new DecimalFormat()){
@Override public String generateToolTip(XYDataset dataset,int series,int item){
return dataset.getSeriesKey(series) + "String_Node_Str" + super.generateToolTip(dataset,series,item);
}
}
);
if (cbSportTypeMode.getSelectedItem() == OverviewType.EACH_STACKED && getCurrentValueType() != ValueType.WEIGHT) {
renderer.setSeriesLinesVisible(0,false);
renderer.setSeriesShapesVisible(0,false);
renderer.setSeriesVisibleInLegend(0,false);
dataset=new TimeTableXYDataset();
lGraphColors=new ArrayList<>();
for (SportType sportType : document.getSportTypeList()) {
addExerciseTimeSeries(dataset,timeType,year,vType,sportType);
lGraphColors.add(sportType.getColor());
}
plot.setDataset(1,dataset);
StackedRenderer stackedRenderer=new StackedRenderer();
for (int i=0; i < lGraphColors.size(); i++) {
Color tempColor=lGraphColors.get(i);
stackedRenderer.setSeriesPaint(i,tempColor);
}
stackedRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator(toolTipFormat,new SimpleDateFormat(dateFormatTooltip),new DecimalFormat()){
@Override public String generateToolTip(XYDataset dataset,int series,int item){
return dataset.getSeriesKey(series) + "String_Node_Str" + super.generateToolTip(dataset,series,item);
}
}
);
plot.setRenderer(1,stackedRenderer);
}
DateAxis axis=(DateAxis)plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat(dateFormatAxis));
if (dateTickUnit != null) {
axis.setTickUnit(dateTickUnit);
}
if (plot.getRangeAxis().getRange().getCentralValue() == 0d) {
plot.getRangeAxis().setRange(new Range(0,10));
}
if (timeType == TimeRangeType.LAST_12_MONTHS) {
Calendar today=Calendar.getInstance();
Calendar newYear=createCalendarFor(today.get(Calendar.YEAR),0,1,true);
newYear.add(Calendar.DAY_OF_MONTH,-15);
ValueMarker newYearMarker=new ValueMarker(newYear.getTimeInMillis());
newYearMarker.setPaint(context.getResReader().getColor("String_Node_Str"));
newYearMarker.setStroke(new BasicStroke(0.8f));
newYearMarker.setLabel("String_Node_Str" + today.get(Calendar.YEAR));
newYearMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
newYearMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
plot.addDomainMarker(newYearMarker);
}
chart.getLegend().setPosition(RectangleEdge.RIGHT);
chartPanel.setChart(chart);
}

Fixed version (ground truth):
/** 
 * Draws the overview diagram according to the current selections.
 */
private void updateDiagram(){
  updateSelectionControlsState();
  TimeRangeType timeType=getCurrentTimeRangeType();
  ValueType vType=getCurrentValueType();
  String vTypeName=getCurrentValueTypeName();
  int year=getSelectedYear();
  TimeTableXYDataset dataset=new TimeTableXYDataset();
  List<Color> lGraphColors=new ArrayList<>();
  if (getCurrentValueType() == ValueType.EQUIPMENT) {
    setupEquipmentDiagram(dataset,lGraphColors);
  }
 else   if (getCurrentValueType() == ValueType.WEIGHT) {
    setupWeightDiagram(dataset,lGraphColors);
  }
 else {
    setupExerciseDiagram(dataset,lGraphColors);
  }
  JFreeChart chart=ChartFactory.createTimeSeriesChart(null,null,vTypeName,dataset,true,true,false);
  ChartUtils.customizeChart(chart,chartPanel);
  XYPlot plot=(XYPlot)chart.getPlot();
  XYLineAndShapeRenderer renderer=(XYLineAndShapeRenderer)plot.getRenderer();
  renderer.setBaseShapesVisible(true);
  renderer.setBaseShapesFilled(true);
  for (int i=0; i < lGraphColors.size(); i++) {
    Color tempColor=lGraphColors.get(i);
    renderer.setSeriesPaint(i,tempColor);
  }
  String dateFormatTooltip=null;
  String dateFormatAxis=null;
  DateTickUnit dateTickUnit=null;
switch (timeType) {
case LAST_12_MONTHS:
    dateFormatTooltip="String_Node_Str";
  dateFormatAxis="String_Node_Str";
dateTickUnit=new DateTickUnit(DateTickUnitType.MONTH,1);
break;
case MONTHS_OF_YEAR:
dateFormatTooltip="String_Node_Str";
dateFormatAxis="String_Node_Str";
dateTickUnit=new DateTickUnit(DateTickUnitType.MONTH,1);
break;
case WEEKS_OF_YEAR:
dateFormatTooltip="String_Node_Str";
dateFormatAxis="String_Node_Str";
dateTickUnit=new DateTickUnit(DateTickUnitType.YEAR,2);
break;
default :
dateFormatTooltip="String_Node_Str";
dateFormatAxis="String_Node_Str";
dateTickUnit=new DateTickUnit(DateTickUnitType.YEAR,1);
break;
}
String toolTipFormat="String_Node_Str";
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator(toolTipFormat,new SimpleDateFormat(dateFormatTooltip),new DecimalFormat()){
@Override public String generateToolTip(XYDataset dataset,int series,int item){
return dataset.getSeriesKey(series) + "String_Node_Str" + super.generateToolTip(dataset,series,item);
}
}
);
if (cbSportTypeMode.getSelectedItem() == OverviewType.EACH_STACKED && vType != ValueType.EQUIPMENT && vType != ValueType.WEIGHT) {
renderer.setSeriesLinesVisible(0,false);
renderer.setSeriesShapesVisible(0,false);
renderer.setSeriesVisibleInLegend(0,false);
dataset=new TimeTableXYDataset();
lGraphColors=new ArrayList<>();
for (SportType sportType : document.getSportTypeList()) {
addExerciseTimeSeries(dataset,timeType,year,vType,sportType);
lGraphColors.add(sportType.getColor());
}
plot.setDataset(1,dataset);
StackedRenderer stackedRenderer=new StackedRenderer();
for (int i=0; i < lGraphColors.size(); i++) {
Color tempColor=lGraphColors.get(i);
stackedRenderer.setSeriesPaint(i,tempColor);
}
stackedRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator(toolTipFormat,new SimpleDateFormat(dateFormatTooltip),new DecimalFormat()){
@Override public String generateToolTip(XYDataset dataset,int series,int item){
return dataset.getSeriesKey(series) + "String_Node_Str" + super.generateToolTip(dataset,series,item);
}
}
);
plot.setRenderer(1,stackedRenderer);
}
DateAxis axis=(DateAxis)plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat(dateFormatAxis));
if (dateTickUnit != null) {
axis.setTickUnit(dateTickUnit);
}
if (plot.getRangeAxis().getRange().getCentralValue() == 0d) {
plot.getRangeAxis().setRange(new Range(0,10));
}
if (timeType == TimeRangeType.LAST_12_MONTHS) {
Calendar today=Calendar.getInstance();
Calendar newYear=createCalendarFor(today.get(Calendar.YEAR),0,1,true);
newYear.add(Calendar.DAY_OF_MONTH,-15);
ValueMarker newYearMarker=new ValueMarker(newYear.getTimeInMillis());
newYearMarker.setPaint(context.getResReader().getColor("String_Node_Str"));
newYearMarker.setStroke(new BasicStroke(0.8f));
newYearMarker.setLabel("String_Node_Str" + today.get(Calendar.YEAR));
newYearMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
newYearMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
plot.addDomainMarker(newYearMarker);
}
chart.getLegend().setPosition(RectangleEdge.RIGHT);
chartPanel.setChart(chart);
}