DefaultXYDataset dataset = new DefaultXYDataset();
JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(1, new XYLineAndShapeRenderer());
boolean success = false;
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
e.printStackTrace();
success = false;
}
assertTrue(success);
DefaultXYDataset dataset = new DefaultXYDataset();
JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(null);
boolean success = false;
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
e.printStackTrace();
success = false;
}
assertTrue(success);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/XYPlotTests.java
|
|
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/XYPlotTests.java
|
Method name: void test1654215()
|
|
Method name: void testDrawRangeGridlines()
|
Number of AST nodes: 12
|
|
Number of AST nodes: 12
|
|
1 | DefaultXYDataset dataset = new DefaultXYDataset();↵ | | 1 | DefaultXYDataset dataset = new DefaultXYDataset();↵
|
2 | JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",↵ | | 2 | JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",↵
|
3 | dataset, PlotOrientation.VERTICAL, true, false, false);↵ | | 3 | dataset, PlotOrientation.VERTICAL, true, false, false);↵
|
4 | XYPlot plot = (XYPlot) chart.getPlot();↵ | | 4 | XYPlot plot = (XYPlot) chart.getPlot();↵
|
5 | plot.setRenderer(1, new XYLineAndShapeRenderer());↵ | | 5 | plot.setRenderer(null);↵
|
6 | boolean success = false;↵ | | 6 | boolean success = false;↵
|
7 | try {↵ | | 7 | try {↵
|
8 | BufferedImage image = new BufferedImage(200 , 100, ↵ | | 8 | BufferedImage image = new BufferedImage(200 , 100, ↵
|
9 | BufferedImage.TYPE_INT_RGB);↵ | | 9 | BufferedImage.TYPE_INT_RGB);↵
|
10 | Graphics2D g2 = image.createGraphics();↵ | | 10 | Graphics2D g2 = image.createGraphics();↵
|
11 | chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);↵ | | 11 | chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);↵
|
12 | g2.dispose();↵ | | 12 | g2.dispose();↵
|
13 | success = true;↵ | | 13 | success = true;↵
|
14 | }↵ | | 14 | }↵
|
15 | catch (Exception e) {↵ | | 15 | catch (Exception e) {↵
|
16 | e.printStackTrace();↵ | | 16 | e.printStackTrace();↵
|
17 | success = false;↵ | | 17 | success = false;↵
|
18 | }↵ | | 18 | }↵
|
19 | assertTrue(success); | | 19 | assertTrue(success);
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 52 |
-
{Refactorable}
Mapping Summary
Number of mapped statements | 12 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 61.0 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
1 | DefaultXYDataset dataset = new DefaultXYDataset(); | | 1 | DefaultXYDataset dataset = new DefaultXYDataset(); |
2 | JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); | | 2 | JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); |
3 | XYPlot plot = (XYPlot)chart.getPlot(); | | 3 | XYPlot plot = (XYPlot)chart.getPlot(); |
4 | plot.setRenderer(1, new XYLineAndShapeRenderer()); | | 4 | plot.setRenderer(null); |
5 | boolean success = false; | | 5 | boolean success = false; |
6 | try | | 6 | try |
7 | BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); | | 7 | BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); |
8 | Graphics2D g2 = image.createGraphics(); | | 8 | Graphics2D g2 = image.createGraphics(); |
9 | chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); | | 9 | chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); |
10 | | | 10 | |
11 | | | 11 | |
12 | assertTrue(success); | | 12 | assertTrue(success); |
Precondition Violations (4)
Row |
Violation |
1 | Expression plot.setRenderer(1,new XYLineAndShapeRenderer()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression plot.setRenderer(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression plot.setRenderer(1,new XYLineAndShapeRenderer()) is a void method call, and thus it cannot be parameterized |
4 | Expression plot.setRenderer(null) is a void method call, and thus it cannot be parameterized |