163-2-3

CategoryPlot cp = getPlot(); if (cp == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel(dataset, series); } Shape shape = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); return result;
LegendItem result = null; XYPlot plot = getPlot(); if (plot == null) { return null; } XYDataset dataset = plot.getDataset(datasetIndex); if (dataset != null) { if (getItemVisible(series, 0)) { String label = getLegendItemLabelGenerator().generateLabel( dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } Shape shape = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); result = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); } } return result;

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java |  | File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/xy/XYBubbleRenderer.java
Method name: `LegendItem getLegendItem(int, int)` |  | Method name: `LegendItem getLegendItem(int, int)`
Number of AST nodes: 24 |  | Number of AST nodes: 25

1

    Category↵

1

    LegendItem result = null;↵

2

    Plot cp = getPlot();↵

2

            XYPlot plot = getPlot();↵

3

            if (cp == null) {↵

3

            if (plot == null) {↵

4

                return null;↵

4

                return null;↵

5

            }↵

5

            }↵

6

            // check that a legend item needs to be displayed...↵

6

            ↵

7

            if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) {↵

8

                return↵

7

       ↵

8

            XYDataset dataset = plot.getDataset(datasetIndex);↵

9

     null;↵

9

            if (dataset != null) {↵

10

            }↵

10

            ↵

11

            CategoryDataset dataset = cp.getDataset(datasetIndex);↵

11

        if (getItemVisible(series, 0)) {↵

12

            String label = getLegendItemLabelGenerator().generateLabel(dataset,↵

12

                    String label = getLegendItemLabelGenerator().generateLabel(↵

13

                    series);↵

13

                            dataset, series);↵

14

            String description = label;↵

14

                    String description = label;↵

15

            String toolTipText = null;↵

15

                    String toolTipText = null;↵

16

            if (getLegendItemToolTipGenerator() != null) {↵

16

                    if (getLegendItemToolTipGenerator() != null) {↵

17

                toolTipText = getLegendItemToolTipGenerator().generateLabel(↵

17

                        toolTipText = getLegendItemToolTipGenerator().generateLabel(↵

18

                        dataset, series);↵

18

                                dataset, series);↵

19

            }↵

19

            ↵

20

            }↵

20

            String urlText = null;↵

21

                    String urlText = null;↵

21

            if (getLegendItemURLGenerator() != null) {↵

22

                    if (getLegendItemURLGenerator() != null) {↵

22

                urlText = getLegendItemURLGenerator().generateLabel(dataset,↵

23

                        urlText = getLegendItemURLGenerator().generateLabel(↵

23

                        series);↵

24

                                dataset, series);↵

24

            }↵

25

                    }↵

25

            Shape shape = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0);↵

26

                    Shape shape = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0);↵

26

            Paint paint = lookupSeriesPaint(series);↵

27

                    Paint paint = lookupSeriesPaint(series);↵

27

            Paint outlinePaint = lookupSeriesOutlinePaint(series);↵

28

                    Paint outlinePaint = lookupSeriesOutlinePaint(series);↵

28

            Stroke outlineStroke = lookupSeriesOutlineStroke(series);↵

29

                    Stroke outlineStroke = lookupSeriesOutlineStroke(series);↵

29

            LegendItem result = new LegendItem(label, description, toolTipText,↵

30

                    result = new LegendItem(label, description, toolTipText, ↵

30

                    urlText, shape, paint, outlineStroke, outlinePaint);↵

31

                            urlText, shape, paint, outlineStroke, outlinePaint);↵

31

            result.setDataset(dataset);↵

32

                    result.setDataset(dataset);↵

32

            result.setDatasetIndex(datasetIndex);↵

33

                    result.setDatasetIndex(datasetIndex);↵

33

            result.setSeriesKey(dataset.getRowKey(series));↵

34

                    result.setSeriesKey(dataset.getSeriesKey(series));↵

34

            result.setSeriesIndex(series);↵

35

                    result.setSeriesIndex(series);↵

36

                }↵

37

            }↵

35

            return result;

38

            return result;

See real code fragment |  | See real code fragment

Summary
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) | 0.6
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 41

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 8
   Number of unmapped statements in the first code fragment | 6
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 2.9
   Clone type | Type 3

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

   1

       CategoryPlot cp = getPlot();

   2

       if (cp == null)

   3

       return null;

   3 | return null;

   Preondition Violations
   Unmatched return null;

   4

       if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series))

   5

       return null;

   5 | return null;

   Preondition Violations
   Unmatched return null;

   6

       CategoryDataset dataset = cp.getDataset(datasetIndex);

   7

       String label = getLegendItemLabelGenerator().generateLabel(dataset, series);

   7 | String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
   8 | String label = getLegendItemLabelGenerator().generateLabel(dataset, series);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.category.CategoryDataset | org.jfree.data.xy.XYDataset | VARIABLE_TYPE_MISMATCH
   org.jfree.chart.labels.CategorySeriesLabelGenerator | org.jfree.chart.labels.XYSeriesLabelGenerator | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.data.category.CategoryDataset of variable dataset does not match with type org.jfree.data.xy.XYDataset of variable dataset
   - Make classes org.jfree.data.category.CategoryDataset and org.jfree.data.xy.XYDataset extend a common superclass

   Type org.jfree.chart.labels.CategorySeriesLabelGenerator of variable getLegendItemLabelGenerator() does not match with type org.jfree.chart.labels.XYSeriesLabelGenerator of variable getLegendItemLabelGenerator()
   - Make classes org.jfree.chart.labels.CategorySeriesLabelGenerator and org.jfree.chart.labels.XYSeriesLabelGenerator extend a common superclass

   8

       String label = getLegendItemLabelGenerator().generateLabel(dataset, series);

   8

       String description = label;

   9

       String description = label;

   9

       String toolTipText = null;

   10

       String toolTipText = null;

   10

       if (getLegendItemToolTipGenerator() != null)

   10 | if (getLegendItemToolTipGenerator() != null)
   11 | if (getLegendItemToolTipGenerator() != null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.labels.CategorySeriesLabelGenerator | org.jfree.chart.labels.XYSeriesLabelGenerator | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.labels.CategorySeriesLabelGenerator of variable getLegendItemToolTipGenerator() does not match with type org.jfree.chart.labels.XYSeriesLabelGenerator of variable getLegendItemToolTipGenerator()
   - Make classes org.jfree.chart.labels.CategorySeriesLabelGenerator and org.jfree.chart.labels.XYSeriesLabelGenerator extend a common superclass

   11

       if (getLegendItemToolTipGenerator() != null)

   11

       toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);

   11 | toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
   12 | toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.category.CategoryDataset | org.jfree.data.xy.XYDataset | VARIABLE_TYPE_MISMATCH
   org.jfree.chart.labels.CategorySeriesLabelGenerator | org.jfree.chart.labels.XYSeriesLabelGenerator | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.data.category.CategoryDataset of variable dataset does not match with type org.jfree.data.xy.XYDataset of variable dataset
   - Make classes org.jfree.data.category.CategoryDataset and org.jfree.data.xy.XYDataset extend a common superclass

   Type org.jfree.chart.labels.CategorySeriesLabelGenerator of variable getLegendItemToolTipGenerator() does not match with type org.jfree.chart.labels.XYSeriesLabelGenerator of variable getLegendItemToolTipGenerator()
   - Make classes org.jfree.chart.labels.CategorySeriesLabelGenerator and org.jfree.chart.labels.XYSeriesLabelGenerator extend a common superclass

   12

       toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);

   12

       String urlText = null;

   13

       String urlText = null;

   13

       if (getLegendItemURLGenerator() != null)

   13 | if (getLegendItemURLGenerator() != null)
   14 | if (getLegendItemURLGenerator() != null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.labels.CategorySeriesLabelGenerator | org.jfree.chart.labels.XYSeriesLabelGenerator | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.labels.CategorySeriesLabelGenerator of variable getLegendItemURLGenerator() does not match with type org.jfree.chart.labels.XYSeriesLabelGenerator of variable getLegendItemURLGenerator()
   - Make classes org.jfree.chart.labels.CategorySeriesLabelGenerator and org.jfree.chart.labels.XYSeriesLabelGenerator extend a common superclass

   14

       if (getLegendItemURLGenerator() != null)

   14

       urlText = getLegendItemURLGenerator().generateLabel(dataset, series);

   14 | urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
   15 | urlText = getLegendItemURLGenerator().generateLabel(dataset, series);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.category.CategoryDataset | org.jfree.data.xy.XYDataset | VARIABLE_TYPE_MISMATCH
   org.jfree.chart.labels.CategorySeriesLabelGenerator | org.jfree.chart.labels.XYSeriesLabelGenerator | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.data.category.CategoryDataset of variable dataset does not match with type org.jfree.data.xy.XYDataset of variable dataset
   - Make classes org.jfree.data.category.CategoryDataset and org.jfree.data.xy.XYDataset extend a common superclass

   Type org.jfree.chart.labels.CategorySeriesLabelGenerator of variable getLegendItemURLGenerator() does not match with type org.jfree.chart.labels.XYSeriesLabelGenerator of variable getLegendItemURLGenerator()
   - Make classes org.jfree.chart.labels.CategorySeriesLabelGenerator and org.jfree.chart.labels.XYSeriesLabelGenerator extend a common superclass

   15

       urlText = getLegendItemURLGenerator().generateLabel(dataset, series);

   Precondition Violations (11)
   Row | Violation
   --- | ---
   1 | Unmatched return null;
   2 | Unmatched return null;
   3 | Type org.jfree.data.category.CategoryDataset of variable dataset does not match with type org.jfree.data.xy.XYDataset of variable dataset
   4 | Type org.jfree.chart.labels.CategorySeriesLabelGenerator of variable getLegendItemLabelGenerator() does not match with type org.jfree.chart.labels.XYSeriesLabelGenerator of variable getLegendItemLabelGenerator()
   5 | Type org.jfree.chart.labels.CategorySeriesLabelGenerator of variable getLegendItemToolTipGenerator() does not match with type org.jfree.chart.labels.XYSeriesLabelGenerator of variable getLegendItemToolTipGenerator()
   6 | Type org.jfree.data.category.CategoryDataset of variable dataset does not match with type org.jfree.data.xy.XYDataset of variable dataset
   7 | Type org.jfree.chart.labels.CategorySeriesLabelGenerator of variable getLegendItemToolTipGenerator() does not match with type org.jfree.chart.labels.XYSeriesLabelGenerator of variable getLegendItemToolTipGenerator()
   8 | Type org.jfree.chart.labels.CategorySeriesLabelGenerator of variable getLegendItemURLGenerator() does not match with type org.jfree.chart.labels.XYSeriesLabelGenerator of variable getLegendItemURLGenerator()
   9 | Type org.jfree.data.category.CategoryDataset of variable dataset does not match with type org.jfree.data.xy.XYDataset of variable dataset
   10 | Type org.jfree.chart.labels.CategorySeriesLabelGenerator of variable getLegendItemURLGenerator() does not match with type org.jfree.chart.labels.XYSeriesLabelGenerator of variable getLegendItemURLGenerator()
   11 | Clone fragment #1 returns variables label, description, toolTipText, urlText , while Clone fragment #2 returns variables label, description, toolTipText, urlText