Comparable key = (Comparable) it.next(); Number newValue = dataset.getValue(key); Number oldValue = previousDataset.getValue(key); if (oldValue == null) { if (greenForIncrease) { plot.setSectionPaint(key, Color.green); } else { plot.setSectionPaint(key, Color.red); } if (showDifference) { series.setValue(key + " (+100%)", newValue); } } else { double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) { plot.setSectionPaint(key, new Color(0, (int) shade, 0)); } else { plot.setSectionPaint(key, new Color((int) shade, 0, 0)); }
Comparable key = (Comparable) it.next(); Number newValue = dataset.getValue(key); Number oldValue = previousDataset.getValue(key); if (oldValue == null) { if (greenForIncrease) { plot.setSectionPaint(key, Color.green); } else { plot.setSectionPaint(key, Color.red); } if (showDifference) { series.setValue(key + " (+100%)", newValue); } } else { double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) { plot.setSectionPaint(key, new Color(0, (int) shade, 0)); } else { plot.setSectionPaint(key, new Color((int) shade, 0, 0)); }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/ChartFactory.java File path: /jfreechart-1.0.10/src/org/jfree/chart/ChartFactory.java
Method name: JFreeChart createPieChart(String, PieDataset, PieDataset, int, boolean, boolean, boolean, Locale, boolean, boolean) Method name: JFreeChart createPieChart(String, PieDataset, PieDataset, int, boolean, boolean, boolean, boolean, boolean, boolean)
Number of AST nodes: 13 Number of AST nodes: 13
1
Comparable key = (Comparable) it.next();
1
Comparable key = (Comparable) it.next();
2
            Number newValue = dataset.getValue(key);
2
            Number newValue = dataset.getValue(key);
3
            Number oldValue = previousDataset.getValue(key);
3
            Number oldValue = previousDataset.getValue(key);
4
            if (oldValue == null) {
4
            if (oldValue == null) {
5
                if (greenForIncrease) {
5
                if (greenForIncrease) {
6
                    plot.setSectionPaint(key, Color.green);
6
                    plot.setSectionPaint(key, Color.green);
7
                } 
7
                } 
8
                else {
8
                else {
9
                    plot.setSectionPaint(key, Color.red);
9
                    plot.setSectionPaint(key, Color.red);
10
                }
10
                }
11
                if (showDifference) {
11
                if (showDifference) {
12
                    series.setValue(key + " (+100%)", newValue);
12
                    series.setValue(key + " (+100%)", newValue);
13
                }
13
                }
14
            }
14
            }
15
            else {
15
            else {
16
                double percentChange = (newValue.doubleValue() 
16
                double percentChange = (newValue.doubleValue() 
17
                        / oldValue.doubleValue() - 1.0) * 100.0;
17
                        / oldValue.doubleValue() - 1.0) * 100.0;
18
                double shade
18
                double shade
19
                    = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255
19
                    = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255
20
                    : Math.abs(percentChange) * colorPerPercent);
20
                    : Math.abs(percentChange) * colorPerPercent);
21
                if (greenForIncrease 
21
                if (greenForIncrease 
22
                        && newValue.doubleValue() > oldValue.doubleValue()
22
                        && newValue.doubleValue() > oldValue.doubleValue()
23
                        || !greenForIncrease && newValue.doubleValue() 
23
                        || !greenForIncrease && newValue.doubleValue() 
24
                        < oldValue.doubleValue()) {
24
                        < oldValue.doubleValue()) {
25
                    plot.setSectionPaint(key, new Color(0, (int) shade, 0));
25
                    plot.setSectionPaint(key, new Color(0, (int) shade, 0));
26
                }
26
                }
27
                else {
27
                else {
28
                    plot.setSectionPaint(key, new Color((int) shade, 0, 0));
28
                    plot.setSectionPaint(key, new Color((int) shade, 0, 0));
29
                }
29
                }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are declared in the same class
Number of node comparisons17
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)136.6
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    16
    if (greenForIncrease)
    18
    if (greenForIncrease)
    17
    plot.setSectionPaint(key, Color.green);
    19
    plot.setSectionPaint(key, Color.green);
    else
    else
    18
    plot.setSectionPaint(key, Color.red);
    20
    plot.setSectionPaint(key, Color.red);
    19
    if (showDifference)
    21
    if (showDifference)
    20
    series.setValue(key + " (+100%)", newValue);
    22
    series.setValue(key + " (+100%)", newValue);
    Precondition Violations (0)
    Row Violation