140-1-2

RectangleConstraint contentConstraint = toContentConstraint(constraint); LengthConstraintType w = contentConstraint.getWidthConstraintType(); LengthConstraintType h = contentConstraint.getHeightConstraintType(); Size2D contentSize = null; if (w == LengthConstraintType.NONE) { if (h == LengthConstraintType.NONE) { contentSize = arrangeNN(g2); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.RANGE) { if (h == LengthConstraintType.NONE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.FIXED) { if (h == LengthConstraintType.NONE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { contentSize = new Size2D( contentConstraint.getWidth(), contentConstraint.getHeight() ); } } return new Size2D( calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight()) );
RectangleConstraint cc = toContentConstraint(constraint); LengthConstraintType w = cc.getWidthConstraintType(); LengthConstraintType h = cc.getHeightConstraintType(); Size2D contentSize = null; if (w == LengthConstraintType.NONE) { if (h == LengthConstraintType.NONE) { contentSize = new Size2D(getWidth(), getHeight()); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.RANGE) { if (h == LengthConstraintType.NONE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.RANGE) { contentSize = arrangeRR(g2, cc.getWidthRange(), cc.getHeightRange()); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.FIXED) { if (h == LengthConstraintType.NONE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } return new Size2D(calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight()));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/title/LegendGraphic.java |  | File path: /jfreechart-1.0.10/src/org/jfree/chart/title/PaintScaleLegend.java
Method name: `Size2D arrange(Graphics2D, RectangleConstraint)` |  | Method name: `Size2D arrange(Graphics2D, RectangleConstraint)`
Number of AST nodes: 26 |  | Number of AST nodes: 26

1

    RectangleConstraint contentConstraint = toContentConstraint(constraint);↵

1

    RectangleConstraint cc = toContentConstraint(constraint);↵

2

            LengthConstraintType w = contentConstraint.getWidthConstraintType();↵

2

            LengthConstraintType w = cc.getWidthConstraintType();↵

3

            LengthConstraintType h = contentConstraint.getHeightConstraintType();↵

3

            LengthConstraintType h = cc.getHeightConstraintType();↵

4

            Size2D contentSize = null;↵

4

            Size2D contentSize = null;↵

5

            if (w == LengthConstraintType.NONE) {↵

5

            if (w == LengthConstraintType.NONE) {↵

6

                if (h == LengthConstraintType.NONE) {↵

6

                if (h == LengthConstraintType.NONE) {↵

7

                    contentSize = arrangeNN(g2);↵

7

                    contentSize = new Size2D(getWidth(), getHeight()); ↵

8

                }↵

8

                }↵

9

                else if (h == LengthConstraintType.RANGE) {↵

9

                else if (h == LengthConstraintType.RANGE) {↵

10

                    throw new RuntimeException("Not yet implemented.");↵

10

                    throw new RuntimeException("Not yet implemented."); ↵

11

                }↵

11

                }↵

12

                else if (h == LengthConstraintType.FIXED) {↵

12

                else if (h == LengthConstraintType.FIXED) {↵

13

                    throw new RuntimeException("Not yet implemented.");↵

13

                    throw new RuntimeException("Not yet implemented.");↵

14

                }↵

14

                }            ↵

15

            }↵

15

            }↵

16

            else if (w == LengthConstraintType.RANGE) {↵

16

            else if (w == LengthConstraintType.RANGE) {↵

17

                if (h == LengthConstraintType.NONE) {↵

17

                if (h == LengthConstraintType.NONE) {↵

18

                    throw new RuntimeException("Not yet implemented.");↵

18

                    throw new RuntimeException("Not yet implemented."); ↵

19

                }↵

19

                }↵

20

                else if (h == LengthConstraintType.RANGE) {↵

20

                else if (h == LengthConstraintType.RANGE) {↵

21

                    throw new RuntimeException("Not yet implemented."↵

21

                    contentSize = arrangeRR(g2, cc.getWidthRange(), ↵

22

    );↵

22

                            cc.getHeightRange()); ↵

23

                }↵

23

                }↵

24

                else if (h == LengthConstraintType.FIXED) {↵

24

                else if (h == LengthConstraintType.FIXED) {↵

25

                    throw new RuntimeException("Not yet implemented.");↵

25

                    throw new RuntimeException("Not yet implemented.");↵

26

                }↵

26

                }↵

27

            }↵

27

            }↵

28

            else if (w == LengthConstraintType.FIXED) {↵

28

            else if (w == LengthConstraintType.FIXED) {↵

29

                if (h == LengthConstraintType.NONE) {↵

29

                if (h == LengthConstraintType.NONE) {↵

30

                    throw new RuntimeException("Not yet implemented.");↵

30

                    throw new RuntimeException("Not yet implemented."); ↵

31

                }↵

31

                }↵

32

                else if (h == LengthConstraintType.RANGE) {↵

32

                else if (h == LengthConstraintType.RANGE) {↵

33

                    throw new RuntimeException("Not yet implemented.");↵

33

                    throw new RuntimeException("Not yet implemented."); ↵

34

                }↵

34

                }↵

35

                else if (h == LengthConstraintType.FIXED) {   ↵

35

                else if (h == LengthConstraintType.FIXED) {↵

36

                    contentSize = new Size2D(↵

36

                    ↵

37

                        contentConstraint.getWidth(),↵

38

                        contentConstraint.getHeight()↵

39

                    );↵

37

    throw new RuntimeException("Not yet implemented.");↵

40

                }            ↵

38

                }↵

41

            }↵

39

            }↵

42

            return new Size2D(↵

40

            return new Size2D(↵

43

                calculateTotalWidth(contentSize.getWidth()), ↵

41

    calculateTotalWidth(contentSize.getWidth()),↵

44

                calculateTotalHeight(contentSize.getHeight())↵

42

                    calculateTotalHeight(contentSize.getHeight())↵

45

            );

43

    );

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

1. {Non-refactorable}

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

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

   1

       RectangleConstraint contentConstraint = toContentConstraint(constraint);

   1 | RectangleConstraint contentConstraint = toContentConstraint(constraint);
   1 | RectangleConstraint cc = toContentConstraint(constraint);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   contentConstraint | cc | VARIABLE_NAME_MISMATCH

   1

       RectangleConstraint cc = toContentConstraint(constraint);

   2

       LengthConstraintType w = contentConstraint.getWidthConstraintType();

   2 | LengthConstraintType w = contentConstraint.getWidthConstraintType();
   2 | LengthConstraintType w = cc.getWidthConstraintType();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   contentConstraint | cc | VARIABLE_NAME_MISMATCH

   2

       LengthConstraintType w = cc.getWidthConstraintType();

   3

       LengthConstraintType h = contentConstraint.getHeightConstraintType();

   3 | LengthConstraintType h = contentConstraint.getHeightConstraintType();
   3 | LengthConstraintType h = cc.getHeightConstraintType();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   contentConstraint | cc | VARIABLE_NAME_MISMATCH

   3

       LengthConstraintType h = cc.getHeightConstraintType();

   4

       Size2D contentSize = null;

   4

       Size2D contentSize = null;

   5

       if (w == LengthConstraintType.NONE)

   5

       if (w == LengthConstraintType.NONE)

   6

       if (h == LengthConstraintType.NONE)

   6

       if (h == LengthConstraintType.NONE)

   7

       contentSize = arrangeNN(g2);

   7 | contentSize = arrangeNN(g2);
   7 | contentSize = new Size2D(getWidth(), getHeight());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   arrangeNN(g2) | new Size2D(getWidth(),getHeight()) | TYPE_COMPATIBLE_REPLACEMENT

   7

       contentSize = new Size2D(getWidth(), getHeight());

   8

       else if (h == LengthConstraintType.RANGE)

   8

       else if (h == LengthConstraintType.RANGE)

   9

       throw new RuntimeException("Not yet implemented.");

   9

       throw new RuntimeException("Not yet implemented.");

   10

       else if (h == LengthConstraintType.FIXED)

   10

       else if (h == LengthConstraintType.FIXED)

   11

       throw new RuntimeException("Not yet implemented.");

   11

       throw new RuntimeException("Not yet implemented.");

   12

       else if (w == LengthConstraintType.RANGE)

   12

       else if (w == LengthConstraintType.RANGE)

   13

       if (h == LengthConstraintType.NONE)

   13

       if (h == LengthConstraintType.NONE)

   14

       throw new RuntimeException("Not yet implemented.");

   14

       throw new RuntimeException("Not yet implemented.");

   15

       else if (h == LengthConstraintType.RANGE)

   15 | else if (h == LengthConstraintType.RANGE)
   17 | else if (h == LengthConstraintType.FIXED)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   RANGE | FIXED | VARIABLE_NAME_MISMATCH

   17

       else if (h == LengthConstraintType.FIXED)

   16

       throw new RuntimeException("Not yet implemented.");

   18

       throw new RuntimeException("Not yet implemented.");

   17

       else if (h == LengthConstraintType.FIXED)

   17 | else if (h == LengthConstraintType.FIXED)
   15 | else if (h == LengthConstraintType.RANGE)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   FIXED | RANGE | VARIABLE_NAME_MISMATCH

   15

       else if (h == LengthConstraintType.RANGE)

   16 | contentSize = arrangeRR(g2, cc.getWidthRange(), cc.getHeightRange());

   Preondition Violations
   Unmatched statement contentSize=arrangeRR(g2,cc.getWidthRange(),cc.getHeightRange()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   16

       contentSize = arrangeRR(g2, cc.getWidthRange(), cc.getHeightRange());

   18

       throw new RuntimeException("Not yet implemented.");

   18 | throw new RuntimeException("Not yet implemented.");

   Preondition Violations
   Unmatched throw new RuntimeException("Not yet implemented.");

   19

       else if (w == LengthConstraintType.FIXED)

   19

       else if (w == LengthConstraintType.FIXED)

   20

       if (h == LengthConstraintType.NONE)

   20

       if (h == LengthConstraintType.NONE)

   21

       throw new RuntimeException("Not yet implemented.");

   21

       throw new RuntimeException("Not yet implemented.");

   22

       else if (h == LengthConstraintType.RANGE)

   22

       else if (h == LengthConstraintType.RANGE)

   23

       throw new RuntimeException("Not yet implemented.");

   23

       throw new RuntimeException("Not yet implemented.");

   24

       else if (h == LengthConstraintType.FIXED)

   24

       else if (h == LengthConstraintType.FIXED)

   25 | throw new RuntimeException("Not yet implemented.");

   Preondition Violations
   Unmatched throw new RuntimeException("Not yet implemented.");

   25

       throw new RuntimeException("Not yet implemented.");

   25

       contentSize = new Size2D(contentConstraint.getWidth(), contentConstraint.getHeight());

   25 | contentSize = new Size2D(contentConstraint.getWidth(), contentConstraint.getHeight());

   Preondition Violations
   Unmatched statement contentSize=new Size2D(contentConstraint.getWidth(),contentConstraint.getHeight()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   26

       return new Size2D(calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight()));

   26

       return new Size2D(calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight()));

   Precondition Violations (5)
   Row | Violation
   --- | ---
   1 | Unmatched statement contentSize=arrangeRR(g2,cc.getWidthRange(),cc.getHeightRange()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Unmatched throw new RuntimeException("Not yet implemented.");
   3 | Unmatched throw new RuntimeException("Not yet implemented.");
   4 | Unmatched statement contentSize=new Size2D(contentConstraint.getWidth(),contentConstraint.getHeight()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   5 | Clone fragment #1 returns variables contentConstraint, contentSize , while Clone fragment #2 returns variables cc, contentSize