121-2-3

if (extent > -180.0) { // whole segment stays at the back if (drawBack) { Area side = new Area(new Rectangle2D.Double( arc.getStartPoint().getX(), plotArea.getY(), arc.getEndPoint().getX() - arc.getStartPoint().getX(), plotArea.getHeight())); side.intersect(back); g2.setPaint(paint); g2.fill(side); g2.setPaint(outlinePaint); g2.draw(side); } } else { // starts at the back, wraps around front, and // finishes at back again Area side1 = new Area(new Rectangle2D.Double( arc.getStartPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getStartPoint().getX(), plotArea.getHeight())); side1.intersect(back); Area side2 = new Area(new Rectangle2D.Double( plotArea.getX(), plotArea.getY(), arc.getEndPoint().getX() - plotArea.getX(), plotArea.getHeight())); side2.intersect(back); g2.setPaint(paint); if (drawBack) { g2.fill(side1); g2.fill(side2); } if (drawFront) { g2.fill(front); } g2.setPaint(outlinePaint); if (drawBack) { g2.draw(side1); g2.draw(side2); } if (drawFront) { g2.draw(front); } }
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) {  // whole segment stays at the back↵

1

    if (extent &lt; 180.0) {  // segment only occupies the front↵

2

                            if (drawBack) {↵

2

                            if (drawFront) {↵

3

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

3

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

4

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

4

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

5

                                        arc.getEndPoint().getX() ↵

5

                                        arc.getEndPoint().getX() ↵

6

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

6

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

7

                                        plotArea.getHeight()));↵

7

                                        plotArea.getHeight()));↵

8

                                side.intersect(back);↵

8

                                side.intersect(front);↵

9

                                g2.setPaint(paint);↵

9

                                g2.setPaint(paint);↵

10

                                g2.fill(side);↵

10

                                g2.fill(side);↵

11

                                g2.setPaint(outlinePaint);↵

11

                                g2.setPaint(outlinePaint);↵

12

                                g2.draw(side);↵

12

                                g2.draw(side);↵

13

                            }↵

13

                            }↵

14

                        }↵

14

                        }↵

15

                        else {  // starts at the back, wraps around front, and ↵

15

                        else {  // s↵

16

                                // finishes at back again↵

16

    egments wraps right around the back...↵

17

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

17

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

18

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

18

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

19

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

19

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

20

                                    plotArea.getHeight()));↵

20

                                    plotArea.getHeight()));↵

21

                            side1.intersect(back);↵

21

                            side1.intersect(front);↵

22

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

22

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

23

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

23

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

24

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

24

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

25

                                    plotArea.getHeight()));↵

25

                                    plotArea.getHeight()));↵

26

                            side2.intersect(back);↵

26

                            side2.intersect(front);↵

27

                            g2.setPaint(paint);↵

27

                            g2.setPaint(paint);↵

28

                            if (drawBack) {↵

28

                            if (drawFront) {↵

29

                                g2.fill(side1);↵

29

                                g2.fill(side1);↵

30

                                g2.fill(side2);↵

30

                                g2.fill(side2);↵

31

                            }↵

31

                            }↵

32

                            if (drawFront) {↵

32

                            if (drawBack) {↵

33

                                g2.fill(front);↵

33

                                g2.fill(back);↵

34

                            }↵

34

                            }↵

35

                            g2.setPaint(outlinePaint);↵

35

                            g2.setPaint(outlinePaint);↵

36

                            if (drawBack) {↵

36

                            if (drawFront) {↵

37

                                g2.draw(side1);↵

37

                                g2.draw(side1);↵

38

                                g2.draw(side2);↵

38

                                g2.draw(side2);↵

39

                            }↵

39

                            }↵

40

                            if (drawFront) {↵

40

                            if (drawBack) {↵

41

                                g2.draw(front);↵

41

                                g2.draw(back);↵

42

                            }↵

42

                            }↵

43

                        }

43

                        }

See real code fragment |  | See real code fragment

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

1. {Refactorable}

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

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

   101

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

   102

       side1.intersect(front);

   103

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

   104

       side2.intersect(front);

   105

       g2.setPaint(paint);

   106

       if (drawFront)

   107

       g2.fill(side1);

   108

       g2.fill(side2);

   53

       if (drawBack)

   109

       if (drawBack)

   54

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

   55

       side.intersect(back);

   56

       g2.setPaint(paint);

   57

       g2.fill(side);

   57 | g2.fill(side);
   110 | g2.fill(back);

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

   110

       g2.fill(back);

   58

       g2.setPaint(outlinePaint);

   59

       g2.draw(side);

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

2. {Refactorable}

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

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

   60

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

   61

       side1.intersect(back);

   62

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

   63

       side2.intersect(back);

   64

       g2.setPaint(paint);

   65

       if (drawBack)

   66

       g2.fill(side1);

   67

       g2.fill(side2);

   68

       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);

   69

       g2.fill(front);

   69 | g2.fill(front);
   98 | g2.fill(side);

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

   98

       g2.fill(side);

   99

       g2.setPaint(outlinePaint);

   100

       g2.draw(side);

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

1. {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) | 4.3
   Clone type | Type 3

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

   60

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

   101

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

   61

       side1.intersect(back);

   61 | side1.intersect(back);
   102 | side1.intersect(front);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   back | front | VARIABLE_NAME_MISMATCH

   102

       side1.intersect(front);

   62

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

   103

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

   63

       side2.intersect(back);

   63 | side2.intersect(back);
   104 | side2.intersect(front);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   back | front | VARIABLE_NAME_MISMATCH

   104

       side2.intersect(front);

   64

       g2.setPaint(paint);

   105

       g2.setPaint(paint);

   65

       if (drawBack)

   65 | if (drawBack)
   106 | if (drawFront)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   drawBack | drawFront | VARIABLE_NAME_MISMATCH

   106

       if (drawFront)

   66

       g2.fill(side1);

   107

       g2.fill(side1);

   67

       g2.fill(side2);

   108

       g2.fill(side2);

   68

       if (drawFront)

   69

       g2.fill(front);

   109

       if (drawBack)

   110

       g2.fill(back);

   70

       g2.setPaint(outlinePaint);

   111

       g2.setPaint(outlinePaint);

   71

       if (drawBack)

   72

       g2.draw(side1);

   73

       g2.draw(side2);

   74

       if (drawFront)

   75

       g2.draw(front);

   112

       if (drawFront)

   113

       g2.draw(side1);

   114

       g2.draw(side2);

   115

       if (drawBack)

   116

       g2.draw(back);

   Precondition Violations (1)
   Row | Violation
   --- | ---
   1 | Clone fragment #1 returns variables side1, side2 , while Clone fragment #2 returns variables side1, side2