Fix a `SE_BAD_FIELD` SpotBugs violation in `Job`
@@ -132,7 +132,6 @@ import org.kohsuke.stapler.verb.POST;
*
* @author Kohsuke Kawaguchi
*/
-@SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "TODO needs triage")
public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, RunT>>
extends AbstractItem implements ExtensionPoint, StaplerOverridable, ModelObjectWithChildren {
@@ -1410,11 +1409,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return getIconColor().getIconClassName();
}
- public Graph getBuildTimeGraph() {
- return new Graph(getLastBuildTime(),500,400) {
- @Override
- protected JFreeChart createGraph() {
- class ChartLabel implements Comparable<ChartLabel> {
+ private static class ChartLabel implements Comparable<ChartLabel> {
final Run run;
ChartLabel(Run r) {
@@ -1466,9 +1461,39 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
}
return l;
}
+ }
+
+ @SuppressFBWarnings(value = "EQ_DOESNT_OVERRIDE_EQUALS", justification = "category dataset is only relevant for coloring, not equality")
+ private static class ChartLabelStackedAreaRenderer2 extends StackedAreaRenderer2 {
+ private final CategoryDataset categoryDataset;
+
+ ChartLabelStackedAreaRenderer2(CategoryDataset categoryDataset) {
+ this.categoryDataset = categoryDataset;
+ }
+
+ @Override
+ public Paint getItemPaint(int row, int column) {
+ ChartLabel key = (ChartLabel) categoryDataset.getColumnKey(column);
+ return key.getColor();
+ }
+ @Override
+ public String generateURL(CategoryDataset dataset, int row, int column) {
+ ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
+ return String.valueOf(label.run.number);
}
+ @Override
+ public String generateToolTip(CategoryDataset dataset, int row, int column) {
+ ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
+ return label.run.getDisplayName() + " : " + label.run.getDurationString();
+ }
+ }
+
+ public Graph getBuildTimeGraph() {
+ return new Graph(getLastBuildTime(), 500, 400) {
+ @Override
+ protected JFreeChart createGraph() {
DataSetBuilder<String, ChartLabel> data = new DataSetBuilder<>();
for (Run r : getNewBuilds()) {
if (r.isBuilding())
@@ -1512,28 +1537,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
ChartUtil.adjustChebyshev(dataset, rangeAxis);
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
- StackedAreaRenderer ar = new StackedAreaRenderer2() {
- @Override
- public Paint getItemPaint(int row, int column) {
- ChartLabel key = (ChartLabel) dataset.getColumnKey(column);
- return key.getColor();
- }
-
- @Override
- public String generateURL(CategoryDataset dataset, int row,
- int column) {
- ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
- return String.valueOf(label.run.number);
- }
-
- @Override
- public String generateToolTip(CategoryDataset dataset, int row,
- int column) {
- ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
- return label.run.getDisplayName() + " : "
- + label.run.getDurationString();
- }
- };
+ StackedAreaRenderer ar = new ChartLabelStackedAreaRenderer2(dataset);
plot.setRenderer(ar);
// crop extra space around the graph
