121-1-3

if (extent > -180.0) { // the segment is entirely at the // front of the chart if (drawFront) { Area side = new Area(new Rectangle2D.Double( arc.getEndPoint().getX(), plotArea.getY(), arc.getStartPoint().getX() - arc.getEndPoint().getX(), plotArea.getHeight())); side.intersect(front); g2.setPaint(paint); g2.fill(side); g2.setPaint(outlinePaint); g2.draw(side); } } else { // the segment starts at the front, and wraps all // the way around // the back and finishes at the front again Area side1 = new Area(new Rectangle2D.Double( plotArea.getX(), plotArea.getY(), arc.getStartPoint().getX() - plotArea.getX(), plotArea.getHeight())); side1.intersect(front); Area side2 = new Area(new Rectangle2D.Double( arc.getEndPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getEndPoint().getX(), plotArea.getHeight())); side2.intersect(front); g2.setPaint(paint); if (drawFront) { g2.fill(side1); g2.fill(side2); } if (drawBack) { g2.fill(back); } g2.setPaint(outlinePaint); if (drawFront) { g2.draw(side1); g2.draw(side2); } if (drawBack) { g2.draw(back); } }
if (extent < 180.0) { // segment only occupies the front if (drawFront) { Area side = new Area(new Rectangle2D.Double( arc.getStartPoint().getX(), plotArea.getY(), arc.getEndPoint().getX() - arc.getStartPoint().getX(), plotArea.getHeight())); side.intersect(front); g2.setPaint(paint); g2.fill(side); g2.setPaint(outlinePaint); g2.draw(side); } } else { // segments wraps right around the back... Area side1 = new Area(new Rectangle2D.Double( arc.getStartPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getStartPoint().getX(), plotArea.getHeight())); side1.intersect(front); Area side2 = new Area(new Rectangle2D.Double( plotArea.getX(), plotArea.getY(), arc.getEndPoint().getX() - plotArea.getX(), plotArea.getHeight())); side2.intersect(front); g2.setPaint(paint); if (drawFront) { g2.fill(side1); g2.fill(side2); } if (drawBack) { g2.fill(back); } g2.setPaint(outlinePaint); if (drawFront) { g2.draw(side1); g2.draw(side2); } if (drawBack) { g2.draw(back); } }

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/plot/PiePlot3D.java |  | File path: /jfreechart-1.0.10/src/org/jfree/chart/plot/PiePlot3D.java
Method name: `void drawSide(Graphics2D, Rectangle2D, Arc2D, Area, Area, Paint, Paint, Stroke, boolean, boolean)` |  | Method name: `void drawSide(Graphics2D, Rectangle2D, Arc2D, Area, Area, Paint, Paint, Stroke, boolean, boolean)`
Number of AST nodes: 24 |  | Number of AST nodes: 24

1

    if (extent &gt; -180.0) {  // the segment is entirely at the ↵

1

    if (extent &lt; 180.0) {  // segment ↵

2

                                                // front of the chart↵

2

    only occupies the front↵

3

                            if (drawFront) {↵

3

                            if (drawFront) {↵

4

                                Area side = new Area(new Rectangle2D.Double(↵

4

                                Area side = new Area(new Rectangle2D.Double(↵

5

                                        arc.getEndPoint().getX(), plotArea.getY(), ↵

5

                                        arc.getStartPoint().getX(), plotArea.getY(),↵

6

                                        arc.getStartPoint().getX() ↵

6

                                        arc.getEndPoint().getX() ↵

7

                                        - arc.getEndPoint().getX(),↵

7

                                        - arc.getStartPoint().getX(),↵

8

                                        plotArea.getHeight()));↵

8

                                        plotArea.getHeight()));↵

9

                                side.intersect(front);↵

9

                                side.intersect(front);↵

10

                                g2.setPaint(paint);↵

10

                                g2.setPaint(paint);↵

11

                                g2.fill(side);↵

11

                                g2.fill(side);↵

12

                                g2.setPaint(outlinePaint);↵

12

                                g2.setPaint(outlinePaint);↵

13

                                g2.draw(side);↵

13

                                g2.draw(side);↵

14

                            }↵

14

                            }↵

15

                        }↵

15

                        }↵

16

                        else {  // the segment starts at the front, and wraps all ↵

16

                        else {  // segment↵

17

                                // the way around↵

18

                                // the back and finishes at the front again↵

17

    s wraps right around the back...↵

19

                            Area side1 = new Area(new Rectangle2D.Double(↵

18

                            Area side1 = new Area(new Rectangle2D.Double(↵

20

                                    plotArea.getX(), plotArea.getY(),↵

19

                                    arc.getStartPoint().getX(), plotArea.getY(),↵

21

                                    arc.getStartPoint().getX() - plotArea.getX(), ↵

20

                                    plotArea.getMaxX() - arc.getStartPoint().getX(),↵

22

                                    plotArea.getHeight()));↵

21

                                    plotArea.getHeight()));↵

23

                            side1.intersect(front);↵

22

                            side1.intersect(front);↵

24

                            Area side2 = new Area(new Rectangle2D.Double(↵

23

                            Area side2 = new Area(new Rectangle2D.Double(↵

25

                                    arc.getEndPoint().getX(), plotArea.getY(),↵

24

                                    plotArea.getX(), plotArea.getY(),↵

26

                                    plotArea.getMaxX() - arc.getEndPoint().getX(),↵

25

                                    arc.getEndPoint().getX() - plotArea.getX(),↵

27

                                    plotArea.getHeight()));↵

26

                                    plotArea.getHeight()));↵

28

                            side2.intersect(front);↵

27

                            side2.intersect(front);↵

29

                            g2.setPaint(paint);↵

28

                            g2.setPaint(paint);↵

30

                            if (drawFront) {↵

29

                            if (drawFront) {↵

31

                                g2.fill(side1);↵

30

                                g2.fill(side1);↵

32

                                g2.fill(side2);↵

31

                                g2.fill(side2);↵

33

                            }↵

32

                            }↵

34

                            if (drawBack) {↵

33

                            if (drawBack) {↵

35

                                g2.fill(back);↵

34

                                g2.fill(back);↵

36

                            }↵

35

                            }↵

37

                            g2.setPaint(outlinePaint);↵

36

                            g2.setPaint(outlinePaint);↵

38

                            if (drawFront) {↵

37

                            if (drawFront) {↵

39

                                g2.draw(side1);↵

38

                                g2.draw(side1);↵

40

                                g2.draw(side2);↵

39

                                g2.draw(side2);↵

41

                            }↵

40

                            }↵

42

                            if (drawBack) {↵

41

                            if (drawBack) {↵

43

                                g2.draw(back);↵

42

                                g2.draw(back);↵

44

                            }↵

43

                            }↵

45

                        }

44

                        }

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 3
Number of refactorable cases | 1
Number of non-refactorable cases | 2
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.5
Clones location | Clones are in the same method
Number of node comparisons | 136

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 7
   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) | 4.4
   Clone type | Type 2

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

   14

       if (drawFront)

   94

       if (drawFront)

   15

       Area side = new Area(new Rectangle2D.Double(arc.getEndPoint().getX(), plotArea.getY(), arc.getStartPoint().getX() - arc.getEndPoint().getX(), plotArea.getHeight()));

   15 | Area side = new Area(new Rectangle2D.Double(arc.getEndPoint().getX(), plotArea.getY(), arc.getStartPoint().getX() - arc.getEndPoint().getX(), plotArea.getHeight()));
   95 | Area side = new Area(new Rectangle2D.Double(arc.getStartPoint().getX(), plotArea.getY(), arc.getEndPoint().getX() - arc.getStartPoint().getX(), plotArea.getHeight()));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getEndPoint | getStartPoint | METHOD_INVOCATION_NAME_MISMATCH
   getStartPoint | getEndPoint | METHOD_INVOCATION_NAME_MISMATCH
   getEndPoint | getStartPoint | METHOD_INVOCATION_NAME_MISMATCH

   95

       Area side = new Area(new Rectangle2D.Double(arc.getStartPoint().getX(), plotArea.getY(), arc.getEndPoint().getX() - arc.getStartPoint().getX(), plotArea.getHeight()));

   16

       side.intersect(front);

   96

       side.intersect(front);

   17

       g2.setPaint(paint);

   97

       g2.setPaint(paint);

   18

       g2.fill(side);

   98

       g2.fill(side);

   19

       g2.setPaint(outlinePaint);

   99

       g2.setPaint(outlinePaint);

   20

       g2.draw(side);

   100

       g2.draw(side);

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

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 3
   Number of unmapped statements in the first code fragment | 5
   Number of unmapped statements in the second code fragment | 4
   Time elapsed for statement mapping (ms) | 2.2
   Clone type | Type 3

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

   21

       Area side1 = new Area(new Rectangle2D.Double(plotArea.getX(), plotArea.getY(), arc.getStartPoint().getX() - plotArea.getX(), plotArea.getHeight()));

   22

       side1.intersect(front);

   23

       Area side2 = new Area(new Rectangle2D.Double(arc.getEndPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getEndPoint().getX(), plotArea.getHeight()));

   24

       side2.intersect(front);

   25

       g2.setPaint(paint);

   26

       if (drawFront)

   94

       if (drawFront)

   95

       Area side = new Area(new Rectangle2D.Double(arc.getStartPoint().getX(), plotArea.getY(), arc.getEndPoint().getX() - arc.getStartPoint().getX(), plotArea.getHeight()));

   96

       side.intersect(front);

   97

       g2.setPaint(paint);

   99

       g2.setPaint(outlinePaint);

   27

       g2.fill(side1);

   27 | g2.fill(side1);
   100 | g2.draw(side);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   fill | draw | METHOD_INVOCATION_NAME_MISMATCH
   side1 | side | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression g2.fill(side1) is a void method call, and thus it cannot be parameterized
   Expression g2.draw(side) is a void method call, and thus it cannot be parameterized

   100

       g2.draw(side);

   28

       g2.fill(side2);

   28 | g2.fill(side2);
   98 | g2.fill(side);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   side2 | side | VARIABLE_NAME_MISMATCH

   98

       g2.fill(side);

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Expression g2.fill(side1) is a void method call, and thus it cannot be parameterized
   2 | Expression g2.draw(side) is a void method call, and thus it cannot be parameterized

2. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 9
   Number of unmapped statements in the first code fragment | 7
   Number of unmapped statements in the second code fragment | 7
   Time elapsed for statement mapping (ms) | 5.2
   Clone type | Type 3

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

   21

       Area side1 = new Area(new Rectangle2D.Double(plotArea.getX(), plotArea.getY(), arc.getStartPoint().getX() - plotArea.getX(), plotArea.getHeight()));

   21 | Area side1 = new Area(new Rectangle2D.Double(plotArea.getX(), plotArea.getY(), arc.getStartPoint().getX() - plotArea.getX(), plotArea.getHeight()));
   103 | Area side2 = new Area(new Rectangle2D.Double(plotArea.getX(), plotArea.getY(), arc.getEndPoint().getX() - plotArea.getX(), plotArea.getHeight()));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   side1 | side2 | VARIABLE_NAME_MISMATCH
   getStartPoint | getEndPoint | METHOD_INVOCATION_NAME_MISMATCH

   103

       Area side2 = new Area(new Rectangle2D.Double(plotArea.getX(), plotArea.getY(), arc.getEndPoint().getX() - plotArea.getX(), plotArea.getHeight()));

   22

       side1.intersect(front);

   22 | side1.intersect(front);
   104 | side2.intersect(front);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   side1 | side2 | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression side1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression side2 cannot be parameterized, because it has dependencies to/from statements that will be extracted

   104

       side2.intersect(front);

   23

       Area side2 = new Area(new Rectangle2D.Double(arc.getEndPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getEndPoint().getX(), plotArea.getHeight()));

   23 | Area side2 = new Area(new Rectangle2D.Double(arc.getEndPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getEndPoint().getX(), plotArea.getHeight()));
   101 | Area side1 = new Area(new Rectangle2D.Double(arc.getStartPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getStartPoint().getX(), plotArea.getHeight()));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   side2 | side1 | VARIABLE_NAME_MISMATCH
   getEndPoint | getStartPoint | METHOD_INVOCATION_NAME_MISMATCH
   getEndPoint | getStartPoint | METHOD_INVOCATION_NAME_MISMATCH

   101

       Area side1 = new Area(new Rectangle2D.Double(arc.getStartPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getStartPoint().getX(), plotArea.getHeight()));

   24

       side2.intersect(front);

   24 | side2.intersect(front);
   102 | side1.intersect(front);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   side2 | side1 | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression side2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression side1 cannot be parameterized, because it has dependencies to/from statements that will be extracted

   102

       side1.intersect(front);

   25

       g2.setPaint(paint);

   105

       g2.setPaint(paint);

   26

       if (drawFront)

   106

       if (drawFront)

   27

       g2.fill(side1);

   107

       g2.fill(side1);

   28

       g2.fill(side2);

   108

       g2.fill(side2);

   29

       if (drawBack)

   30

       g2.fill(back);

   109

       if (drawBack)

   110

       g2.fill(back);

   31

       g2.setPaint(outlinePaint);

   111

       g2.setPaint(outlinePaint);

   32

       if (drawFront)

   33

       g2.draw(side1);

   34

       g2.draw(side2);

   35

       if (drawBack)

   36

       g2.draw(back);

   112

       if (drawFront)

   113

       g2.draw(side1);

   114

       g2.draw(side2);

   115

       if (drawBack)

   116

       g2.draw(back);

   Precondition Violations (5)
   Row | Violation
   --- | ---
   1 | Expression side1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression side2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression side2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression side1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
   5 | Clone fragment #1 returns variables side1, side2 , while Clone fragment #2 returns variables side1, side2