289-2-4

XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYAreaRenderer2 r = new XYAreaRenderer2(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex());
XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYDifferenceRenderer r = new XYDifferenceRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex());

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

1

    XYSeriesCollection d1 = new XYSeriesCollection();↵

1

    XYSeriesCollection d1 = new XYSeriesCollection();↵

2

            XYSeries s1 = new XYSeries("S1");↵

2

            XYSeries s1 = new XYSeries("S1");↵

3

            s1.add(1.0, 1.1);↵

3

            s1.add(1.0, 1.1);↵

4

            XYSeries s2 = new XYSeries("S2");↵

4

            XYSeries s2 = new XYSeries("S2");↵

5

            s2.add(1.0, 1.1);↵

5

            s2.add(1.0, 1.1);↵

6

            d1.addSeries(s1);↵

6

            d1.addSeries(s1);↵

7

            d1.addSeries(s2);↵

7

            d1.addSeries(s2);↵

8

            XYSeriesCollection d2 = new XYSeriesCollection();↵

8

            XYSeriesCollection d2 = new XYSeriesCollection();↵

9

            XYSeries s3 = new XYSeries("S3");↵

9

            XYSeries s3 = new XYSeries("S3");↵

10

            s3.add(1.0, 1.1);↵

10

            s3.add(1.0, 1.1);↵

11

            XYSeries s4 = new XYSeries("S4");↵

11

            XYSeries s4 = new XYSeries("S4");↵

12

            s4.add(1.0, 1.1);↵

12

            s4.add(1.0, 1.1);↵

13

            XYSeries s5 = new XYSeries("S5");↵

13

            XYSeries s5 = new XYSeries("S5");↵

14

            s5.add(1.0, 1.1);↵

14

            s5.add(1.0, 1.1);↵

15

            d2.addSeries(s3);↵

15

            d2.addSeries(s3);↵

16

            d2.addSeries(s4);↵

16

            d2.addSeries(s4);↵

17

            d2.addSeries(s5);↵

17

            d2.addSeries(s5);↵

18

            XYAreaRenderer2 r = new XYAreaRenderer2();↵

18

            XYDifferenceRenderer r = new XYDifferenceRenderer();↵

19

            XYPlot plot = new XYPlot(d1, new NumberAxis("x"),↵

19

            XYPlot plot = new XYPlot(d1, new NumberAxis("x"),↵

20

                    new NumberAxis("y"), r);↵

20

                    new NumberAxis("y"), r);↵

21

            plot.setDataset(1, d2);↵

21

            plot.setDataset(1, d2);↵

22

            /*JFreeChart chart =*/ new JFreeChart(plot);↵

22

            /*JFreeChart chart =*/ new JFreeChart(plot);↵

23

            LegendItem li = r.getLegendItem(1, 2);↵

23

            LegendItem li = r.getLegendItem(1, 2);↵

24

            assertEquals("S5", li.getLabel());↵

24

            assertEquals("S5", li.getLabel());↵

25

            assertEquals(1, li.getDatasetIndex());↵

25

            assertEquals(1, li.getDatasetIndex());↵

26

            assertEquals(2, li.getSeriesIndex());

26

            assertEquals(2, li.getSeriesIndex());

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.0
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 240

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 25
   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) | 0.0
   Clone type | Type 1

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

   1

       XYSeriesCollection d1 = new XYSeriesCollection();

   1

       XYSeriesCollection d1 = new XYSeriesCollection();

   2

       XYSeries s1 = new XYSeries("S1");

   2

       XYSeries s1 = new XYSeries("S1");

   3

       s1.add(1.0, 1.1);

   3

       s1.add(1.0, 1.1);

   4

       XYSeries s2 = new XYSeries("S2");

   4

       XYSeries s2 = new XYSeries("S2");

   5

       s2.add(1.0, 1.1);

   5

       s2.add(1.0, 1.1);

   6

       d1.addSeries(s1);

   6

       d1.addSeries(s1);

   7

       d1.addSeries(s2);

   7

       d1.addSeries(s2);

   8

       XYSeriesCollection d2 = new XYSeriesCollection();

   8

       XYSeriesCollection d2 = new XYSeriesCollection();

   9

       XYSeries s3 = new XYSeries("S3");

   9

       XYSeries s3 = new XYSeries("S3");

   10

       s3.add(1.0, 1.1);

   10

       s3.add(1.0, 1.1);

   11

       XYSeries s4 = new XYSeries("S4");

   11

       XYSeries s4 = new XYSeries("S4");

   12

       s4.add(1.0, 1.1);

   12

       s4.add(1.0, 1.1);

   13

       XYSeries s5 = new XYSeries("S5");

   13

       XYSeries s5 = new XYSeries("S5");

   14

       s5.add(1.0, 1.1);

   14

       s5.add(1.0, 1.1);

   15

       d2.addSeries(s3);

   15

       d2.addSeries(s3);

   16

       d2.addSeries(s4);

   16

       d2.addSeries(s4);

   17

       d2.addSeries(s5);

   17

       d2.addSeries(s5);

   18

       XYAreaRenderer2 r = new XYAreaRenderer2();

   18

       XYDifferenceRenderer r = new XYDifferenceRenderer();

   19

       XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r);

   19

       XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r);

   20

       plot.setDataset(1, d2);

   20

       plot.setDataset(1, d2);

   21

       new JFreeChart(plot);

   21

       new JFreeChart(plot);

   22

       LegendItem li = r.getLegendItem(1, 2);

   22

       LegendItem li = r.getLegendItem(1, 2);

   23

       assertEquals("S5", li.getLabel());

   23

       assertEquals("S5", li.getLabel());

   24

       assertEquals(1, li.getDatasetIndex());

   24

       assertEquals(1, li.getDatasetIndex());

   25

       assertEquals(2, li.getSeriesIndex());

   25

       assertEquals(2, li.getSeriesIndex());

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