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: 35 | Number of AST nodes: 37 | |||
1 | PiePlot plot = new PiePlot(dataset);↵ | 1 | PiePlot plot = new PiePlot(dataset);↵ | |
2 | plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));↵ | 2 | plot.setLabelGenerator(new StandardPieSectionLabelGenerator());↵ | |
3 | plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));↵ | 3 | plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));↵ | |
4 | if (tooltips) {↵ | 4 | if (tooltips) {↵ | |
5 | plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale↵ | 5 | plot.setToolTipGenerator(new StandardPieToolTipGenerator());↵ | |
6 | }↵ | |||
7 | if (urls) {↵ | |||
6 | ));↵ | 8 | plot.setURLGenerator(new StandardPieURLGenerator());↵ | |
7 | }↵ | 9 | }↵ | |
8 | List keys = dataset.getKeys();↵ | 10 | List keys = dataset.getKeys();↵ | |
9 | DefaultPieDataset series = null;↵ | 11 | DefaultPieDataset series = null;↵ | |
10 | if (showDifference) {↵ | 12 | if (showDifference) {↵ | |
11 | series = new DefaultPieDataset();↵ | 13 | series = new DefaultPieDataset();↵ | |
12 | }↵ | 14 | }↵ | |
13 | double colorPerPercent = 255.0 / percentDiffForMaxScale;↵ | 15 | double colorPerPercent = 255.0 / percentDiffForMaxScale;↵ | |
14 | for (Iterator it = keys.iterator(); it.hasNext();) {↵ | 16 | for (Iterator it = keys.iterator(); it.hasNext();) {↵ | |
15 | Comparable key = (Comparable) it.next();↵ | 17 | Comparable key = (Comparable) it.next();↵ | |
16 | Number newValue = dataset.getValue(key);↵ | 18 | Number newValue = dataset.getValue(key);↵ | |
17 | Number oldValue = previousDataset.getValue(key);↵ | 19 | Number oldValue = previousDataset.getValue(key);↵ | |
18 | if (oldValue == null) {↵ | 20 | if (oldValue == null) {↵ | |
19 | if (greenForIncrease) {↵ | 21 | if (greenForIncrease) {↵ | |
20 | plot.setSectionPaint(key, Color.green);↵ | 22 | plot.setSectionPaint(key, Color.green);↵ | |
21 | } ↵ | 23 | } ↵ | |
22 | else {↵ | 24 | else {↵ | |
23 | plot.setSectionPaint(key, Color.red);↵ | 25 | plot.setSectionPaint(key, Color.red);↵ | |
24 | }↵ | 26 | }↵ | |
25 | if (showDifference) {↵ | 27 | if (showDifference) {↵ | |
26 | series.setValue(key + " (+100%)", newValue);↵ | 28 | series.setValue(key + " (+100%)", newValue);↵ | |
27 | }↵ | 29 | }↵ | |
28 | }↵ | 30 | }↵ | |
29 | else {↵ | 31 | else {↵ | |
30 | double percentChange = (newValue.doubleValue() ↵ | 32 | double percentChange = (newValue.doubleValue() ↵ | |
31 | / oldValue.doubleValue() - 1.0) * 100.0;↵ | 33 | / oldValue.doubleValue() - 1.0) * 100.0;↵ | |
32 | double shade↵ | 34 | double shade↵ | |
33 | = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255↵ | 35 | = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255↵ | |
34 | : Math.abs(percentChange) * colorPerPercent);↵ | 36 | : Math.abs(percentChange) * colorPerPercent);↵ | |
35 | if (greenForIncrease ↵ | 37 | if (greenForIncrease ↵ | |
36 | && newValue.doubleValue() > oldValue.doubleValue()↵ | 38 | && newValue.doubleValue() > oldValue.doubleValue()↵ | |
37 | || !greenForIncrease && newValue.doubleValue() ↵ | 39 | || !greenForIncrease && newValue.doubleValue() ↵ | |
38 | < oldValue.doubleValue()) {↵ | 40 | < oldValue.doubleValue()) {↵ | |
39 | plot.setSectionPaint(key, new Color(0, (int) shade, 0));↵ | 41 | plot.setSectionPaint(key, new Color(0, (int) shade, 0));↵ | |
40 | }↵ | 42 | }↵ | |
41 | else {↵ | 43 | else {↵ | |
42 | plot.setSectionPaint(key, new Color((int) shade, 0, 0));↵ | 44 | plot.setSectionPaint(key, new Color((int) shade, 0, 0));↵ | |
43 | }↵ | 45 | }↵ | |
44 | if (showDifference) {↵ | 46 | if (showDifference) {↵ | |
45 | series.setValue(key + " (" + (percentChange >= 0 ? "+" : "")↵ | 47 | series.setValue(key + " (" + (percentChange >= 0 ? "+" : "")↵ | |
46 | + NumberFormat.getPercentInstance().format(↵ | 48 | + NumberFormat.getPercentInstance().format(↵ | |
47 | percentChange / 100.0) + ")", newValue);↵ | 49 | percentChange / 100.0) + ")", newValue);↵ | |
48 | }↵ | 50 | }↵ | |
49 | }↵ | 51 | }↵ | |
50 | }↵ | 52 | }↵ | |
51 | if (showDifference) {↵ | 53 | if (showDifference) {↵ | |
52 | plot.setDataset(series);↵ | 54 | plot.setDataset(series);↵ | |
53 | }↵ | 55 | }↵ | |
54 | JFreeChart chart = new JFreeChart(title, ↵ | 56 | JFreeChart chart = new JFreeChart(title, ↵ | |
55 | JFreeChart.DEFAULT_TITLE_FONT, plot, legend);↵ | 57 | JFreeChart.DEFAULT_TITLE_FONT, plot, legend);↵ | |
56 | if (subTitle) {↵ | 58 | if (subTitle) {↵ | |
57 | TextTitle subtitle = null;↵ | 59 | TextTitle subtitle = null;↵ | |
58 | subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" ↵ | 60 | subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" ↵ | |
59 | : "green") + "=change >=-" + percentDiffForMaxScale ↵ | 61 | : "green") + "=change >=-" + percentDiffForMaxScale ↵ | |
60 | + "%, Bright " + (!greenForIncrease ? "red" : "green") ↵ | 62 | + "%, Bright " + (!greenForIncrease ? "red" : "green") ↵ | |
61 | + "=change >=+" + percentDiffForMaxScale + "%", ↵ | 63 | + "=change >=+" + percentDiffForMaxScale + "%", ↵ | |
62 | new Font("SansSerif", Font.PLAIN, 10));↵ | 64 | new Font("SansSerif", Font.PLAIN, 10));↵ | |
63 | chart.addSubtitle(subtitle);↵ | 65 | chart.addSubtitle(subtitle);↵ | |
64 | }↵ | 66 | }↵ | |
65 | return chart; | 67 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 3.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 153 |
Number of mapped statements | 32 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 6400.7 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | PiePlot plot = new PiePlot(dataset); | 1 | PiePlot plot = new PiePlot(dataset); | |||||||||||
2 | plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale)); |
| 2 | plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); | ||||||||||
3 | plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); | 3 | plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); | |||||||||||
4 | if (tooltips) | 4 | if (tooltips) | |||||||||||
5 | plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); |
| 5 | plot.setToolTipGenerator(new StandardPieToolTipGenerator()); | ||||||||||
6 | List keys = dataset.getKeys(); | 8 | List keys = dataset.getKeys(); | |||||||||||
7 | DefaultPieDataset series = null; | 9 | DefaultPieDataset series = null; | |||||||||||
8 | if (showDifference) | 10 | if (showDifference) | |||||||||||
9 | series = new DefaultPieDataset(); | 11 | series = new DefaultPieDataset(); | |||||||||||
10 | double colorPerPercent = 255.0 / percentDiffForMaxScale; | 12 | double colorPerPercent = 255.0 / percentDiffForMaxScale; | |||||||||||
11 | for (Iterator it = keys.iterator(); it.hasNext(); ) | 13 | for (Iterator it = keys.iterator(); it.hasNext(); ) | |||||||||||
12 | Comparable key = (Comparable)it.next(); | 14 | Comparable key = (Comparable)it.next(); | |||||||||||
13 | Number newValue = dataset.getValue(key); | 15 | Number newValue = dataset.getValue(key); | |||||||||||
14 | Number oldValue = previousDataset.getValue(key); | 16 | Number oldValue = previousDataset.getValue(key); | |||||||||||
15 | if (oldValue == null) | 17 | if (oldValue == null) | |||||||||||
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); | |||||||||||
else | else | |||||||||||||
21 | double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; | 23 | double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; | |||||||||||
22 | double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); | 24 | double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); | |||||||||||
23 | if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) | 25 | if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) | |||||||||||
24 | plot.setSectionPaint(key, new Color(0, (int)shade, 0)); | 26 | plot.setSectionPaint(key, new Color(0, (int)shade, 0)); | |||||||||||
else | else | |||||||||||||
25 | plot.setSectionPaint(key, new Color((int)shade, 0, 0)); | 27 | plot.setSectionPaint(key, new Color((int)shade, 0, 0)); | |||||||||||
26 | if (showDifference) | 28 | if (showDifference) | |||||||||||
27 | series.setValue(key + " (" + (percentChange >= 0 ? "+" : "") + NumberFormat.getPercentInstance().format(percentChange / 100.0) + ")", newValue); | 29 | series.setValue(key + " (" + (percentChange >= 0 ? "+" : "") + NumberFormat.getPercentInstance().format(percentChange / 100.0) + ")", newValue); | |||||||||||
28 | if (showDifference) | 30 | if (showDifference) | |||||||||||
29 | plot.setDataset(series); | 31 | plot.setDataset(series); | |||||||||||
30 | JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); | 32 | JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); | |||||||||||
31 | if (subTitle) |
| 6 | if (urls) | ||||||||||
|
| 7 | plot.setURLGenerator(new StandardPieURLGenerator()); | |||||||||||
32 | TextTitle subtitle = null; | | ||||||||||||
33 | subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-" + percentDiffForMaxScale + "%, Bright " + (!greenForIncrease ? "red" : "green") + "=change >=+" + percentDiffForMaxScale + "%", new Font("SansSerif", Font.PLAIN, 10)); |
| | |||||||||||
34 | chart.addSubtitle(subtitle); |
| | |||||||||||
35 | return chart; | 37 | return chart; |
Row | Violation |
---|---|
1 | Unmatched statement plot.setURLGenerator(new StandardPieURLGenerator()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement subtitle=new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-"+ percentDiffForMaxScale+ "%, Bright "+ (!greenForIncrease ? "red" : "green")+ "=change >=+"+ percentDiffForMaxScale+ "%",new Font("SansSerif",Font.PLAIN,10)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched statement subtitle=new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-"+ percentDiffForMaxScale+ "%, Bright "+ (!greenForIncrease ? "red" : "green")+ "=change >=+"+ percentDiffForMaxScale+ "%",new Font("SansSerif",Font.PLAIN,10)); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
4 | Unmatched statement chart.addSubtitle(subtitle); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Unmatched statement chart.addSubtitle(subtitle); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
6 | Clone fragment #1 returns variables , while Clone fragment #2 returns variables chart |