162-1-2

for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = getTickUnit().valueToString(currentTickValue); } TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; if (edge == RectangleEdge.TOP) { angle = Math.PI / 2.0; } else { angle = -Math.PI / 2.0; } } else { if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; } else { anchor = TextAnchor.TOP_CENTER; rotationAnchor = TextAnchor.TOP_CENTER; } } Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); result.add(tick); }
double currentTickValue = lowestTickValue + (i * size); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = getTickUnit().valueToString(currentTickValue); } TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; angle = -Math.PI / 2.0; } else { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; angle = Math.PI / 2.0; } } else { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; } else { anchor = TextAnchor.CENTER_LEFT; rotationAnchor = TextAnchor.CENTER_LEFT; } } Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); result.add(tick);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/axis/NumberAxis.java |  | File path: /jfreechart-1.0.10/src/org/jfree/chart/axis/NumberAxis.java
Method name: `List refreshTicksHorizontal(Graphics2D, Rectangle2D, RectangleEdge)` |  | Method name: `List refreshTicksVertical(Graphics2D, Rectangle2D, RectangleEdge)`
Number of AST nodes: 23 |  | Number of AST nodes: 24

1

    for (int i = 0; i < count; i++) {↵

2

                    double currentTickValue = lowestTickValue + (i * size);↵

1

    double currentTickValue = lowestTickValue + (i * size);↵

3

                    String tickLabel;↵

2

                    String tickLabel;↵

4

                    NumberFormat formatter = getNumberFormatOverride();↵

3

                    NumberFormat formatter = getNumberFormatOverride();↵

5

                    if (formatter != null) {↵

4

                    if (formatter != null) {↵

6

                        tickLabel = formatter.format(currentTickValue);↵

5

                        tickLabel = formatter.format(currentTickValue);↵

7

                    }↵

6

                    }↵

8

                    else {↵

7

                    else {↵

9

                        tickLabel = getTickUnit().valueToString(currentTickValue);↵

8

                        tickLabel = getTickUnit().valueToString(currentTickValue);↵

10

                    }↵

9

                    }↵

11

                    TextAnchor anchor = null;↵

10

                    TextAnchor anchor = null;↵

12

                    TextAnchor rotationAnchor = null;↵

11

                    TextAnchor rotationAnchor = null;↵

13

                    double angle = 0.0;↵

12

                    double angle = 0.0;↵

14

                    if (isVerticalTickLabels()) {↵

13

                    if (isVerticalTickLabels()) {↵

15

                        anchor = TextAnchor.CENTER_RIGHT;↵

14

                        ↵

15

    if (edge == RectangleEdge.LEFT) {↵

16

                            anchor = TextAnchor.BOTTOM_CENTER;↵

16

                        rotationAnchor = TextAnchor.CENTER_RIGHT;↵

17

                            rotationAnchor = TextAnchor.BOTTOM_CENTER;↵

17

                        if (edge == RectangleEdge.TOP) {↵

18

                            angle = -Math.PI / 2.0;↵

18

                     ↵

19

                        }↵

19

           angle = Math.PI / 2.0;↵

20

           ↵

20

                        }↵

21

                        else {↵

21

                 else {↵

22

                            anchor = TextAnchor.BOTTOM_CENTER;↵

23

                            rotationAnchor = TextAnchor.BOTTOM_CENTER;↵

22

                            angle = -Math.PI / 2.0;↵

24

                            angle = Math.PI / 2.0;↵

23

                        }↵

25

                        }↵

24

                    }↵

26

                    }↵

25

                    else {↵

27

                    else {↵

26

                        if (edge == RectangleEdge.TOP) {↵

28

                        if (edge == RectangleEdge.LEFT) {↵

27

                            anchor = TextAnchor.BOTTOM_CENTER;↵

29

                            anchor = TextAnchor.CENTER_RIGHT;↵

28

                            rotationAnchor = TextAnchor.BOTTOM_CENTER;↵

30

                            rotationAnchor = TextAnchor.CENTER_RIGHT;↵

29

                        }↵

31

                        }↵

30

                        else {↵

32

                        else {↵

31

                            anchor = TextAnchor.TOP_CENTER;↵

33

                            anchor = TextAnchor.CENTER_LEFT;↵

32

                            rotationAnchor = TextAnchor.TOP_CENTER;↵

34

                            rotationAnchor = TextAnchor.CENTER_LEFT;↵

33

                        }↵

35

                        }↵

34

                    }↵

36

                    }↵

35

                    Tick tick = new NumberTick(new Double(currentTickValue),↵

37

                    Tick tick = new NumberTick(new Double(currentTickValue),↵

36

                    		tickLabel, anchor, rotationAnchor, angle);↵

38

                    		tickLabel, anchor, rotationAnchor, angle);↵

37

                    result.add(tick);↵

39

                    result.add(tick);

38

                }

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 declared in the same class
Number of node comparisons | 139

1. {Non-refactorable}

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

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

   11

       double currentTickValue = lowestTickValue + (i * size);

   12

       double currentTickValue = lowestTickValue + (i * size);

   12

       String tickLabel;

   13

       String tickLabel;

   13

       NumberFormat formatter = getNumberFormatOverride();

   14

       NumberFormat formatter = getNumberFormatOverride();

   14

       if (formatter != null)

   15

       if (formatter != null)

   15

       tickLabel = formatter.format(currentTickValue);

   16

       tickLabel = formatter.format(currentTickValue);

       else

       else

   16

       tickLabel = getTickUnit().valueToString(currentTickValue);

   17

       tickLabel = getTickUnit().valueToString(currentTickValue);

   17

       TextAnchor anchor = null;

   18

       TextAnchor anchor = null;

   18

       TextAnchor rotationAnchor = null;

   19

       TextAnchor rotationAnchor = null;

   19

       double angle = 0.0;

   20

       double angle = 0.0;

   20

       if (isVerticalTickLabels())

   21

       if (isVerticalTickLabels())

   21

       anchor = TextAnchor.CENTER_RIGHT;

   21 | anchor = TextAnchor.CENTER_RIGHT;

   Preondition Violations
   Unmatched statement anchor=TextAnchor.CENTER_RIGHT; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   22

       rotationAnchor = TextAnchor.CENTER_RIGHT;

   22 | rotationAnchor = TextAnchor.CENTER_RIGHT;

   Preondition Violations
   Unmatched statement rotationAnchor=TextAnchor.CENTER_RIGHT; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   23

       if (edge == RectangleEdge.TOP)

   23 | if (edge == RectangleEdge.TOP)
   22 | if (edge == RectangleEdge.LEFT)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   TOP | LEFT | VARIABLE_NAME_MISMATCH

   22

       if (edge == RectangleEdge.LEFT)

   23 | anchor = TextAnchor.BOTTOM_CENTER;

   Preondition Violations
   Unmatched statement anchor=TextAnchor.BOTTOM_CENTER; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   23

       anchor = TextAnchor.BOTTOM_CENTER;

   24 | rotationAnchor = TextAnchor.BOTTOM_CENTER;

   Preondition Violations
   Unmatched statement rotationAnchor=TextAnchor.BOTTOM_CENTER; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   24

       rotationAnchor = TextAnchor.BOTTOM_CENTER;

   24

       angle = Math.PI / 2.0;

   24 | angle = Math.PI / 2.0;
   25 | angle = -Math.PI / 2.0;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   Math.PI | -Math.PI | TYPE_COMPATIBLE_REPLACEMENT

   25

       angle = -Math.PI / 2.0;

       else

       else

   26 | anchor = TextAnchor.BOTTOM_CENTER;

   Preondition Violations
   Unmatched statement anchor=TextAnchor.BOTTOM_CENTER; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   26

       anchor = TextAnchor.BOTTOM_CENTER;

   27 | rotationAnchor = TextAnchor.BOTTOM_CENTER;

   Preondition Violations
   Unmatched statement rotationAnchor=TextAnchor.BOTTOM_CENTER; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   27

       rotationAnchor = TextAnchor.BOTTOM_CENTER;

   25

       angle = -Math.PI / 2.0;

   25 | angle = -Math.PI / 2.0;
   28 | angle = Math.PI / 2.0;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   -Math.PI | Math.PI | TYPE_COMPATIBLE_REPLACEMENT

   28

       angle = Math.PI / 2.0;

       else

       else

   26

       if (edge == RectangleEdge.TOP)

   26 | if (edge == RectangleEdge.TOP)
   29 | if (edge == RectangleEdge.LEFT)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   TOP | LEFT | VARIABLE_NAME_MISMATCH

   29

       if (edge == RectangleEdge.LEFT)

   27

       anchor = TextAnchor.BOTTOM_CENTER;

   27 | anchor = TextAnchor.BOTTOM_CENTER;
   30 | anchor = TextAnchor.CENTER_RIGHT;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   BOTTOM_CENTER | CENTER_RIGHT | VARIABLE_NAME_MISMATCH

   30

       anchor = TextAnchor.CENTER_RIGHT;

   28

       rotationAnchor = TextAnchor.BOTTOM_CENTER;

   28 | rotationAnchor = TextAnchor.BOTTOM_CENTER;
   31 | rotationAnchor = TextAnchor.CENTER_RIGHT;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   BOTTOM_CENTER | CENTER_RIGHT | VARIABLE_NAME_MISMATCH

   31

       rotationAnchor = TextAnchor.CENTER_RIGHT;

       else

       else

   29

       anchor = TextAnchor.TOP_CENTER;

   29 | anchor = TextAnchor.TOP_CENTER;
   32 | anchor = TextAnchor.CENTER_LEFT;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   TOP_CENTER | CENTER_LEFT | VARIABLE_NAME_MISMATCH

   32

       anchor = TextAnchor.CENTER_LEFT;

   30

       rotationAnchor = TextAnchor.TOP_CENTER;

   30 | rotationAnchor = TextAnchor.TOP_CENTER;
   33 | rotationAnchor = TextAnchor.CENTER_LEFT;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   TOP_CENTER | CENTER_LEFT | VARIABLE_NAME_MISMATCH

   33

       rotationAnchor = TextAnchor.CENTER_LEFT;

   31

       Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle);

   34

       Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle);

   32

       result.add(tick);

   35

       result.add(tick);

   Precondition Violations (7)
   Row | Violation
   --- | ---
   1 | Unmatched statement anchor=TextAnchor.CENTER_RIGHT; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Unmatched statement rotationAnchor=TextAnchor.CENTER_RIGHT; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   3 | Unmatched statement anchor=TextAnchor.BOTTOM_CENTER; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   4 | Unmatched statement rotationAnchor=TextAnchor.BOTTOM_CENTER; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   5 | Unmatched statement anchor=TextAnchor.BOTTOM_CENTER; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   6 | Unmatched statement rotationAnchor=TextAnchor.BOTTOM_CENTER; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   7 | Clone fragment #1 returns variables anchor, rotationAnchor , while Clone fragment #2 returns variables anchor, rotationAnchor