299-1-2

CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null) { Font labelFont = getItemLabelFont(row, column); Paint paint = getItemLabelPaint(row, column); g2.setFont(labelFont); g2.setPaint(paint); String label = generator.generateLabel(dataset, row, column); ItemLabelPosition position = null; if (!negative) { position = getPositiveItemLabelPosition(row, column); } else { position = getNegativeItemLabelPosition(row, column); } Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), x, y, orientation); TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); }
XYItemLabelGenerator generator = getItemLabelGenerator(series, item); if (generator != null) { Font labelFont = getItemLabelFont(series, item); Paint paint = getItemLabelPaint(series, item); g2.setFont(labelFont); g2.setPaint(paint); String label = generator.generateLabel(dataset, series, item); // get the label position.. ItemLabelPosition position = null; if (!negative) { position = getPositiveItemLabelPosition(series, item); } else { position = getNegativeItemLabelPosition(series, item); } // work out the label anchor point... Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), x, y, orientation); TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); }

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java |  | File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java
Method name: `void drawItemLabel(Graphics2D, PlotOrientation, CategoryDataset, int, int, double, double, boolean)` |  | Method name: `void drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int, double, double, boolean)`
Number of AST nodes: 13 |  | Number of AST nodes: 13

1

    CategoryItemLabelGenerator generator↵

1

    XYItemLabelGenerator generator↵

2

                = getItemLabelGenerator(row, column);↵

2

     = getItemLabelGenerator(series, item);↵

3

            if (generator != null) {↵

3

            if (generator != null) {↵

4

                Font labelFont = getItemLabelFont(row, column);↵

4

                Font labelFont = getItemLabelFont(series, item);↵

5

                Paint paint = getItemLabelPaint(row, column);↵

5

                Paint paint = getItemLabelPaint(series, item);↵

6

                g2.setFont(labelFont);↵

6

                g2.setFont(labelFont);↵

7

                g2.setPaint(paint);↵

7

                g2.setPaint(paint);↵

8

                String label = generator.generateLabel(dataset, row, column);↵

8

                String label = generator.generateLabel(dataset, series, item);↵

9

                // get the label position..↵

9

                ItemLabelPosition position = null;↵

10

                ItemLabelPosition position = null;↵

10

                if (!negative) {↵

11

                if (!negative) {↵

11

                    position = getPositiveItemLabelPosition(row, column);↵

12

                    position = getPositiveItemLabelPosition(series, item);↵

12

                }↵

13

                }↵

13

                else {↵

14

                else {↵

14

                    position = getNegativeItemLabelPosition(row, column);↵

15

                    position = getNegativeItemLabelPosition(series, item);↵

15

                }
    ↵

16

                }
    ↵

17

                // work out the label anchor point...
    ↵

16

                Point2D anchorPoint = calculateLabelAnchorPoint(↵

18

                Point2D anchorPoint = calculateLabelAnchorPoint(↵

17

                        position.getItemLabelAnchor(), x, y, orientation);↵

19

                        position.getItemLabelAnchor(), x, y, orientation);↵

18

                TextUtilities.drawRotatedString(label, g2,↵

20

                TextUtilities.drawRotatedString(label, g2,↵

19

                        (float) anchorPoint.getX(), (float) anchorPoint.getY(),↵

21

                        (float) anchorPoint.getX(), (float) anchorPoint.getY(),↵

20

                        position.getTextAnchor(),↵

22

                        position.getTextAnchor(),↵

21

                        position.getAngle(),↵

23

     position.getAngle(),↵

22

     position.getRotationAnchor());↵

24

                        position.getRotationAnchor());↵

23

            }

25

            }

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

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 12
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 1
   Time elapsed for statement mapping (ms) | 4.3
   Clone type | Type 2

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

   1

       XYItemLabelGenerator generator = getItemLabelGenerator(series, item);

   1

       CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column);

   2

       if (generator != null)

   2 | if (generator != null)
   2 | if (generator != null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.labels.CategoryItemLabelGenerator | org.jfree.chart.labels.XYItemLabelGenerator | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.labels.CategoryItemLabelGenerator of variable generator does not match with type org.jfree.chart.labels.XYItemLabelGenerator of variable generator
   - Make classes org.jfree.chart.labels.CategoryItemLabelGenerator and org.jfree.chart.labels.XYItemLabelGenerator extend a common superclass

   2

       if (generator != null)

   3

       Font labelFont = getItemLabelFont(row, column);

   3 | Font labelFont = getItemLabelFont(row, column);
   3 | Font labelFont = getItemLabelFont(series, item);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   row | series | VARIABLE_NAME_MISMATCH
   column | item | VARIABLE_NAME_MISMATCH

   3

       Font labelFont = getItemLabelFont(series, item);

   4

       Paint paint = getItemLabelPaint(row, column);

   4 | Paint paint = getItemLabelPaint(row, column);
   4 | Paint paint = getItemLabelPaint(series, item);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   row | series | VARIABLE_NAME_MISMATCH
   column | item | VARIABLE_NAME_MISMATCH

   4

       Paint paint = getItemLabelPaint(series, item);

   5

       g2.setFont(labelFont);

   5

       g2.setFont(labelFont);

   6

       g2.setPaint(paint);

   6

       g2.setPaint(paint);

   7

       String label = generator.generateLabel(dataset, row, column);

   7 | String label = generator.generateLabel(dataset, row, column);
   7 | String label = generator.generateLabel(dataset, series, item);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.category.CategoryDataset | org.jfree.data.xy.XYDataset | VARIABLE_TYPE_MISMATCH
   org.jfree.chart.labels.CategoryItemLabelGenerator | org.jfree.chart.labels.XYItemLabelGenerator | 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.CategoryItemLabelGenerator of variable generator does not match with type org.jfree.chart.labels.XYItemLabelGenerator of variable generator
   - Make classes org.jfree.chart.labels.CategoryItemLabelGenerator and org.jfree.chart.labels.XYItemLabelGenerator extend a common superclass

   7

       String label = generator.generateLabel(dataset, series, item);

   8

       ItemLabelPosition position = null;

   8

       ItemLabelPosition position = null;

   9

       if (!negative)

   9

       if (!negative)

   10

       position = getPositiveItemLabelPosition(row, column);

   10 | position = getPositiveItemLabelPosition(row, column);
   10 | position = getPositiveItemLabelPosition(series, item);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   row | series | VARIABLE_NAME_MISMATCH
   column | item | VARIABLE_NAME_MISMATCH

   10

       position = getPositiveItemLabelPosition(series, item);

       else

       else

   11

       position = getNegativeItemLabelPosition(row, column);

   11 | position = getNegativeItemLabelPosition(row, column);
   11 | position = getNegativeItemLabelPosition(series, item);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   row | series | VARIABLE_NAME_MISMATCH
   column | item | VARIABLE_NAME_MISMATCH

   11

       position = getNegativeItemLabelPosition(series, item);

   12

       Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), x, y, orientation);

   12

       Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), x, y, orientation);

   13

       TextUtilities.drawRotatedString(label, g2, (float)anchorPoint.getX(), (float)anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());

   13

       TextUtilities.drawRotatedString(label, g2, (float)anchorPoint.getX(), (float)anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());

   Precondition Violations (3)
   Row | Violation
   --- | ---
   1 | Type org.jfree.chart.labels.CategoryItemLabelGenerator of variable generator does not match with type org.jfree.chart.labels.XYItemLabelGenerator of variable generator
   2 | Type org.jfree.data.category.CategoryDataset of variable dataset does not match with type org.jfree.data.xy.XYDataset of variable dataset
   3 | Type org.jfree.chart.labels.CategoryItemLabelGenerator of variable generator does not match with type org.jfree.chart.labels.XYItemLabelGenerator of variable generator