186-2-4

DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); dataset0.addValue(21.0, "R1", "C1"); dataset0.addValue(22.0, "R2", "C1"); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset1.addValue(23.0, "R3", "C1"); dataset1.addValue(24.0, "R4", "C1"); dataset1.addValue(25.0, "R5", "C1"); BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, dataset1); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("R5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex());
DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); dataset0.addValue(21.0, "R1", "C1"); dataset0.addValue(22.0, "R2", "C1"); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset1.addValue(23.0, "R3", "C1"); dataset1.addValue(24.0, "R4", "C1"); dataset1.addValue(25.0, "R5", "C1"); BarRenderer r = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, dataset1); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("R5", 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/category/junit/BoxAndWhiskerRendererTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java
Method name: `void testGetLegendItemSeriesIndex()` |  | Method name: `void testGetLegendItemSeriesIndex()`
Number of AST nodes: 15 |  | Number of AST nodes: 15

1

    DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();↵

1

    DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();↵

2

            dataset0.addValue(21.0, "R1", "C1");↵

2

            dataset0.addValue(21.0, "R1", "C1");↵

3

            dataset0.addValue(22.0, "R2", "C1");↵

3

            dataset0.addValue(22.0, "R2", "C1");↵

4

            DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();↵

4

            DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();↵

5

            dataset1.addValue(23.0, "R3", "C1");↵

5

            dataset1.addValue(23.0, "R3", "C1");↵

6

            dataset1.addValue(24.0, "R4", "C1");↵

6

            dataset1.addValue(24.0, "R4", "C1");↵

7

            dataset1.addValue(25.0, "R5", "C1");↵

7

            dataset1.addValue(25.0, "R5", "C1");↵

8

            BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer();↵

8

            BarRenderer r = new BarRenderer();↵

9

            CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),↵

9

            CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),↵

10

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

10

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

11

            plot.setDataset(1, dataset1);↵

11

            plot.setDataset(1, dataset1);↵

12

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

12

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

13

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

13

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

14

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

14

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

15

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

15

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

16

            assertEquals(2, li.getSeriesIndex());

16

            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 | 90

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 15
   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 2

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

   1

       DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();

   1

       DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();

   2

       dataset0.addValue(21.0, "R1", "C1");

   2

       dataset0.addValue(21.0, "R1", "C1");

   3

       dataset0.addValue(22.0, "R2", "C1");

   3

       dataset0.addValue(22.0, "R2", "C1");

   4

       DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();

   4

       DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();

   5

       dataset1.addValue(23.0, "R3", "C1");

   5

       dataset1.addValue(23.0, "R3", "C1");

   6

       dataset1.addValue(24.0, "R4", "C1");

   6

       dataset1.addValue(24.0, "R4", "C1");

   7

       dataset1.addValue(25.0, "R5", "C1");

   7

       dataset1.addValue(25.0, "R5", "C1");

   8

       BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer();

   8 | BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer();
   8 | BarRenderer r = new BarRenderer();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.renderer.category.BoxAndWhiskerRenderer | org.jfree.chart.renderer.category.BarRenderer | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.renderer.category.BoxAndWhiskerRenderer | org.jfree.chart.renderer.category.BarRenderer | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.renderer.category.BoxAndWhiskerRenderer | org.jfree.chart.renderer.category.BarRenderer | SUBCLASS_TYPE_MISMATCH

   8

       BarRenderer r = new BarRenderer();

   9

       CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r);

   9 | CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r);
   9 | CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.renderer.category.BoxAndWhiskerRenderer | org.jfree.chart.renderer.category.BarRenderer | SUBCLASS_TYPE_MISMATCH

   9

       CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r);

   10

       plot.setDataset(1, dataset1);

   10

       plot.setDataset(1, dataset1);

   11

       new JFreeChart(plot);

   11

       new JFreeChart(plot);

   12

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

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

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.renderer.category.BoxAndWhiskerRenderer | org.jfree.chart.renderer.category.BarRenderer | SUBCLASS_TYPE_MISMATCH

   12

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

   13

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

   13

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

   14

       assertEquals(1, li.getDatasetIndex());

   14

       assertEquals(1, li.getDatasetIndex());

   15

       assertEquals(2, li.getSeriesIndex());

   15

       assertEquals(2, li.getSeriesIndex());

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