145-1-2

if (!isHiddenValue(tickDate.getTime())) { // work out the value, label and position String tickLabel; DateFormat formatter = getDateFormatOverride(); if (formatter != null) { tickLabel = formatter.format(tickDate); } else { tickLabel = this.tickUnit.dateToString(tickDate); } 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 DateTick(tickDate, tickLabel, anchor, rotationAnchor, angle); result.add(tick); tickDate = unit.addToDate(tickDate, this.timeZone); } else { tickDate = unit.rollDate(tickDate, this.timeZone); continue; }
if (!isHiddenValue(tickDate.getTime())) { // work out the value, label and position String tickLabel; DateFormat formatter = getDateFormatOverride(); if (formatter != null) { tickLabel = formatter.format(tickDate); } else { tickLabel = this.tickUnit.dateToString(tickDate); } TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; if (edge == RectangleEdge.LEFT) { angle = -Math.PI / 2.0; } else { 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 DateTick(tickDate, tickLabel, anchor, rotationAnchor, angle); result.add(tick); tickDate = unit.addToDate(tickDate, this.timeZone); } else { tickDate = unit.rollDate(tickDate, this.timeZone); }

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

1

    if (!isHiddenValue(tickDate.getTime())) {↵

1

    if (!isHiddenValue(tickDate.getTime())) {↵

2

                    // work out the value, label and position↵

2

                    // work out the value, label and position↵

3

                    String tickLabel;↵

3

                    String tickLabel;↵

4

                    DateFormat formatter = getDateFormatOverride();↵

4

                    DateFormat formatter = getDateFormatOverride();↵

5

                    if (formatter != null) {↵

5

                    if (formatter != null) {↵

6

                        tickLabel = formatter.format(tickDate);↵

6

                        tickLabel = formatter.format(tickDate);↵

7

                    }↵

7

                    }↵

8

                    else {↵

8

                    else {↵

9

                        tickLabel = this.tickUnit.dateToString(tickDate);↵

9

                        tickLabel = this.tickUnit.dateToString(tickDate);↵

10

                    }↵

10

                    }↵

11

                    TextAnchor anchor = null;↵

11

                    TextAnchor anchor = null;↵

12

                    TextAnchor rotationAnchor = null;↵

12

                    TextAnchor rotationAnchor = null;↵

13

                    double angle = 0.0;↵

13

                    double angle = 0.0;↵

14

                    if (isVerticalTickLabels()) {↵

14

                    if (isVerticalTickLabels()) {↵

15

                        anchor = TextAnchor.CENTER_RIGHT;↵

15

                        anchor = TextAnchor.BOTTOM_CENTER;↵

16

                        rotationAnchor = TextAnchor.CENTER_RIGHT;↵

16

                        rotationAnchor = TextAnchor.BOTTOM_CENTER;↵

17

                        if (edge == RectangleEdge.TOP) {↵

17

                        if (edge == RectangleEdge.LEFT) {↵

18

                            angle = Math.PI / 2.0;↵

18

                            angle = -Math.PI / 2.0;↵

19

                        }↵

19

                        }↵

20

                        else {↵

20

                        else {↵

21

                            angle = -Math.PI / 2.0;↵

21

                            angle = Math.PI / 2.0;↵

22

                        }↵

22

                        }↵

23

                    }↵

23

                    }↵

24

                    else {↵

24

                    else {↵

25

                        if (edge == RectangleEdge.TOP) {↵

25

                        if (edge == RectangleEdge.LEFT) {↵

26

                            anchor = TextAnchor.BOTTOM_CENTER;↵

26

                            anchor = TextAnchor.CENTER_RIGHT;↵

27

                            rotationAnchor = TextAnchor.BOTTOM_CENTER;↵

27

                            rotationAnchor = TextAnchor.CENTER_RIGHT;↵

28

                        }↵

28

                        }↵

29

                        else {↵

29

                        else {↵

30

                            anchor = TextAnchor.TOP_CENTER;↵

30

                            anchor = TextAnchor.CENTER_LEFT;↵

31

                            rotationAnchor = TextAnchor.TOP_CENTER;↵

31

                            rotationAnchor = TextAnchor.CENTER_LEFT;↵

32

                        }↵

32

                        }↵

33

                    }↵

33

                    }↵

34

                    Tick tick = new DateTick(tickDate, tickLabel, anchor,↵

34

                    Tick tick = new DateTick(tickDate, tickLabel, anchor,↵

35

                            rotationAnchor, angle);↵

35

                            rotationAnchor, angle);↵

36

                    result.add(tick);↵

36

                    result.add(tick);↵

37

                    tickDate = unit.addToDate(tickDate, this.timeZone);↵

37

                    tickDate = unit.addToDate(tickDate, this.timeZone);↵

38

                }↵

38

                }↵

39

                else {↵

39

                else {↵

40

                    tickDate = unit.rollDate(tickDate, this.timeZone);↵

40

                    tickDate = unit.rollDate(tickDate, this.timeZone);↵

41

                    continue;↵

42

                }

41

                }

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.8
Clones location | Clones are declared in the same class
Number of node comparisons | 179

1. {Non-refactorable}

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

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

   10

       if (!isHiddenValue(tickDate.getTime()))

   10

       if (!isHiddenValue(tickDate.getTime()))

   11

       String tickLabel;

   11

       String tickLabel;

   12

       DateFormat formatter = getDateFormatOverride();

   12

       DateFormat formatter = getDateFormatOverride();

   13

       if (formatter != null)

   13

       if (formatter != null)

   14

       tickLabel = formatter.format(tickDate);

   14

       tickLabel = formatter.format(tickDate);

       else

       else

   15

       tickLabel = this.tickUnit.dateToString(tickDate);

   15

       tickLabel = this.tickUnit.dateToString(tickDate);

   16

       TextAnchor anchor = null;

   16 | TextAnchor anchor = null;
   17 | TextAnchor rotationAnchor = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   anchor | rotationAnchor | VARIABLE_NAME_MISMATCH

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

   17

       TextAnchor rotationAnchor = null;

   17

       TextAnchor rotationAnchor = null;

   17 | TextAnchor rotationAnchor = null;
   16 | TextAnchor anchor = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   rotationAnchor | anchor | VARIABLE_NAME_MISMATCH

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

   16

       TextAnchor anchor = null;

   18

       double angle = 0.0;

   18

       double angle = 0.0;

   19

       if (isVerticalTickLabels())

   19

       if (isVerticalTickLabels())

   20

       anchor = TextAnchor.CENTER_RIGHT;

   20 | anchor = TextAnchor.CENTER_RIGHT;
   20 | anchor = TextAnchor.BOTTOM_CENTER;

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

   20

       anchor = TextAnchor.BOTTOM_CENTER;

   21

       rotationAnchor = TextAnchor.CENTER_RIGHT;

   21 | rotationAnchor = TextAnchor.CENTER_RIGHT;
   21 | rotationAnchor = TextAnchor.BOTTOM_CENTER;

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

   21

       rotationAnchor = TextAnchor.BOTTOM_CENTER;

   22

       if (edge == RectangleEdge.TOP)

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

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

   22

       if (edge == RectangleEdge.LEFT)

   23

       angle = Math.PI / 2.0;

   23 | angle = Math.PI / 2.0;
   23 | angle = -Math.PI / 2.0;

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

   23

       angle = -Math.PI / 2.0;

       else

       else

   24

       angle = -Math.PI / 2.0;

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

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

   24

       angle = Math.PI / 2.0;

       else

       else

   25

       if (edge == RectangleEdge.TOP)

   25 | if (edge == RectangleEdge.TOP)
   25 | if (edge == RectangleEdge.LEFT)

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

   25

       if (edge == RectangleEdge.LEFT)

   26

       anchor = TextAnchor.BOTTOM_CENTER;

   26 | anchor = TextAnchor.BOTTOM_CENTER;
   26 | anchor = TextAnchor.CENTER_RIGHT;

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

   26

       anchor = TextAnchor.CENTER_RIGHT;

   27

       rotationAnchor = TextAnchor.BOTTOM_CENTER;

   27 | rotationAnchor = TextAnchor.BOTTOM_CENTER;
   27 | rotationAnchor = TextAnchor.CENTER_RIGHT;

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

   27

       rotationAnchor = TextAnchor.CENTER_RIGHT;

       else

       else

   28

       anchor = TextAnchor.TOP_CENTER;

   28 | anchor = TextAnchor.TOP_CENTER;
   28 | anchor = TextAnchor.CENTER_LEFT;

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

   28

       anchor = TextAnchor.CENTER_LEFT;

   29

       rotationAnchor = TextAnchor.TOP_CENTER;

   29 | rotationAnchor = TextAnchor.TOP_CENTER;
   29 | rotationAnchor = TextAnchor.CENTER_LEFT;

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

   29

       rotationAnchor = TextAnchor.CENTER_LEFT;

   30

       Tick tick = new DateTick(tickDate, tickLabel, anchor, rotationAnchor, angle);

   30

       Tick tick = new DateTick(tickDate, tickLabel, anchor, rotationAnchor, angle);

   31

       result.add(tick);

   31

       result.add(tick);

   32

       tickDate = unit.addToDate(tickDate, this.timeZone);

   32

       tickDate = unit.addToDate(tickDate, this.timeZone);

       else

       else

   33

       tickDate = unit.rollDate(tickDate, this.timeZone);

   33

       tickDate = unit.rollDate(tickDate, this.timeZone);

   34

       continue;

   34 | continue;

   Preondition Violations
   Unmatched continue;

   Precondition Violations (5)
   Row | Violation
   --- | ---
   1 | Expression anchor cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression rotationAnchor cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression rotationAnchor cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression anchor cannot be parameterized, because it has dependencies to/from statements that will be extracted
   5 | Unmatched continue;