247-1-6

boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new StackedXYAreaRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success);
boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYStepRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/xy/junit/StackedXYAreaRendererTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/xy/junit/XYStepRendererTests.java
Method name: `void testDrawWithNullInfo()` |  | Method name: `void testDrawWithNullInfo()`
Number of AST nodes: 20 |  | Number of AST nodes: 20

1

    boolean success = false;↵

1

    boolean success = false;↵

2

            try {↵

2

            try {↵

3

                DefaultTableXYDataset dataset = new DefaultTableXYDataset();↵

3

                DefaultTableXYDataset dataset = new DefaultTableXYDataset();↵

4

                XYSeries s1 = new XYSeries("Series 1", true, false);↵

4

                XYSeries s1 = new XYSeries("Series 1", true, false);↵

5

                s1.add(5.0, 5.0);↵

5

                s1.add(5.0, 5.0);↵

6

                s1.add(10.0, 15.5);↵

6

                s1.add(10.0, 15.5);↵

7

                s1.add(15.0, 9.5);↵

7

                s1.add(15.0, 9.5);↵

8

                s1.add(20.0, 7.5);↵

8

                s1.add(20.0, 7.5);↵

9

                dataset.addSeries(s1);↵

9

                dataset.addSeries(s1);↵

10

                XYSeries s2 = new XYSeries("Series 2", true, false);↵

10

                XYSeries s2 = new XYSeries("Series 2", true, false);↵

11

                s2.add(5.0, 5.0);↵

11

                s2.add(5.0, 5.0);↵

12

                s2.add(10.0, 15.5);↵

12

                s2.add(10.0, 15.5);↵

13

                s2.add(15.0, 9.5);↵

13

                s2.add(15.0, 9.5);↵

14

                s2.add(20.0, 3.5);↵

14

                s2.add(20.0, 3.5);↵

15

                dataset.addSeries(s2);↵

15

                dataset.addSeries(s2);↵

16

                XYPlot plot = new XYPlot(dataset,↵

16

                XYPlot plot = new XYPlot(dataset,↵

17

                        new NumberAxis("X"), new NumberAxis("Y"),↵

17

                        new NumberAxis("X"), new NumberAxis("Y"),↵

18

                        new StackedXYAreaRenderer());↵

18

                        new XYStepRenderer());↵

19

                JFreeChart chart = new JFreeChart(plot);↵

19

                JFreeChart chart = new JFreeChart(plot);↵

20

                /* BufferedImage image = */ chart.createBufferedImage(300, 200,↵

20

                /* BufferedImage image = */ chart.createBufferedImage(300, 200,↵

21

                        null);↵

21

                        null);↵

22

                success = true;↵

22

                success = true;↵

23

            }↵

23

            }↵

24

            catch (NullPointerException e) {↵

24

            catch (NullPointerException e) {↵

25

                e.printStackTrace();↵

25

                e.printStackTrace();↵

26

                success = false;↵

26

                success = false;↵

27

            }↵

27

            }↵

28

            assertTrue(success);

28

            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 in different classes having the same super class
Number of node comparisons | 328

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 20
   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) | 80.7
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       boolean success = false;

   1

       boolean success = false;

   2

       try

   2

       try

   3

       DefaultTableXYDataset dataset = new DefaultTableXYDataset();

   3

       DefaultTableXYDataset dataset = new DefaultTableXYDataset();

   4

       XYSeries s1 = new XYSeries("Series 1", true, false);

   4

       XYSeries s1 = new XYSeries("Series 1", true, false);

   5

       s1.add(5.0, 5.0);

   5

       s1.add(5.0, 5.0);

   6

       s1.add(10.0, 15.5);

   6

       s1.add(10.0, 15.5);

   7

       s1.add(15.0, 9.5);

   7

       s1.add(15.0, 9.5);

   8

       s1.add(20.0, 7.5);

   8

       s1.add(20.0, 7.5);

   9

       dataset.addSeries(s1);

   9

       dataset.addSeries(s1);

   10

       XYSeries s2 = new XYSeries("Series 2", true, false);

   10

       XYSeries s2 = new XYSeries("Series 2", true, false);

   11

       s2.add(5.0, 5.0);

   11

       s2.add(5.0, 5.0);

   12

       s2.add(10.0, 15.5);

   12

       s2.add(10.0, 15.5);

   13

       s2.add(15.0, 9.5);

   13

       s2.add(15.0, 9.5);

   14

       s2.add(20.0, 3.5);

   14

       s2.add(20.0, 3.5);

   15

       dataset.addSeries(s2);

   15

       dataset.addSeries(s2);

   16

       XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new StackedXYAreaRenderer());

   16 | XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new StackedXYAreaRenderer());
   16 | XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYStepRenderer());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.renderer.xy.StackedXYAreaRenderer | org.jfree.chart.renderer.xy.XYStepRenderer | SUBCLASS_TYPE_MISMATCH

   16

       XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYStepRenderer());

   17

       JFreeChart chart = new JFreeChart(plot);

   17

       JFreeChart chart = new JFreeChart(plot);

   18

       chart.createBufferedImage(300, 200, null);

   18

       chart.createBufferedImage(300, 200, null);

   19

       success = true;

   19

       success = true;

   20

       assertTrue(success);

   20

       assertTrue(success);

   Precondition Violations (0)
   Row | Violation
   --- | ---