if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { 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); } }
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()) { 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: 24 Number of AST nodes: 25
1
if (count <= ValueAxis.MAXIMUM_TICK_COUNT) {
2
            for (int i = 0; i < count; i++) {
1
for (int i = 0; i < count; i++) {
3
                double currentTickValue = lowestTickValue + (i * size);
2
                double currentTickValue = lowestTickValue + (i * size);
4
                String tickLabel;
3
                String tickLabel;
5
                NumberFormat formatter = getNumberFormatOverride();
4
                NumberFormat formatter = getNumberFormatOverride();
6
                if (formatter != null) {
5
                if (formatter != null) {
7
                    tickLabel = formatter.format(currentTickValue);
6
                    tickLabel = formatter.format(currentTickValue);
8
                }
7
                }
9
                else {
8
                else {
10
                    tickLabel = getTickUnit().valueToString(currentTickValue);
9
                    tickLabel = getTickUnit().valueToString(currentTickValue);
11
                }
10
                }
12
                TextAnchor anchor = null;
11
                TextAnchor anchor = null;
13
                TextAnchor rotationAnchor = null;
12
                TextAnchor rotationAnchor = null;
14
                double angle = 0.0;
13
                double angle = 0.0;
15
                if (isVerticalTickLabels()) {
14
                if (isVerticalTickLabels()) {
16
                    anchor = TextAnchor.CENTER_RIGHT;
15
                    
16
if (edge == RectangleEdge.LEFT) {
17
                        anchor = TextAnchor.BOTTOM_CENTER;
17
                    rotationAnchor = TextAnchor.CENTER_RIGHT;
18
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
18
                    if (edge == RectangleEdge.TOP) {
19
                        angle = -Math.PI / 2.0;
19
                    
20
                    }
20
    angle = Math.PI / 2.0;
21
    
21
                    }
22
                    else {
22
                else {
23
                        anchor = TextAnchor.BOTTOM_CENTER;
24
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
23
                        angle = -Math.PI / 2.0;
25
                        angle = Math.PI / 2.0;
24
                    }
26
                    }
25
                }
27
                }
26
                else {
28
                else {
27
                    if (edge == RectangleEdge.TOP) {
29
                    if (edge == RectangleEdge.LEFT) {
28
                        anchor = TextAnchor.BOTTOM_CENTER;
30
                        anchor = TextAnchor.CENTER_RIGHT;
29
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
31
                        rotationAnchor = TextAnchor.CENTER_RIGHT;
30
                    }
32
                    }
31
                    else {
33
                    else {
32
                        anchor = TextAnchor.TOP_CENTER;
34
                        anchor = TextAnchor.CENTER_LEFT;
33
                        rotationAnchor = TextAnchor.TOP_CENTER;
35
                        rotationAnchor = TextAnchor.CENTER_LEFT;
34
                    }
36
                    }
35
                }
37
                }
36
                Tick tick = new NumberTick(new Double(currentTickValue),
38
                Tick tick = new NumberTick(new Double(currentTickValue),
37
                		tickLabel, anchor, rotationAnchor, angle);
39
                		tickLabel, anchor, rotationAnchor, angle);
38
                result.add(tick);
40
                result.add(tick);
39
            }
41
            }
40
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.8
Clones locationClones are declared in the same class
Number of node comparisons156
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements21
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)44.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    10
    for (int i = 0; i < count; i++)
    11
    for (int i = 0; i < count; i++)
    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
    Expression1Expression2Difference
    TOPLEFTVARIABLE_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
    Expression1Expression2Difference
    Math.PI-Math.PITYPE_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
    Expression1Expression2Difference
    -Math.PIMath.PITYPE_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
    Expression1Expression2Difference
    TOPLEFTVARIABLE_NAME_MISMATCH
    29
    if (edge == RectangleEdge.LEFT)
    27
    anchor = TextAnchor.BOTTOM_CENTER;
    27
    anchor = TextAnchor.BOTTOM_CENTER;
    30
    anchor = TextAnchor.CENTER_RIGHT;
    Differences
    Expression1Expression2Difference
    BOTTOM_CENTERCENTER_RIGHTVARIABLE_NAME_MISMATCH
    30
    anchor = TextAnchor.CENTER_RIGHT;
    28
    rotationAnchor = TextAnchor.BOTTOM_CENTER;
    28
    rotationAnchor = TextAnchor.BOTTOM_CENTER;
    31
    rotationAnchor = TextAnchor.CENTER_RIGHT;
    Differences
    Expression1Expression2Difference
    BOTTOM_CENTERCENTER_RIGHTVARIABLE_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
    Expression1Expression2Difference
    TOP_CENTERCENTER_LEFTVARIABLE_NAME_MISMATCH
    32
    anchor = TextAnchor.CENTER_LEFT;
    30
    rotationAnchor = TextAnchor.TOP_CENTER;
    30
    rotationAnchor = TextAnchor.TOP_CENTER;
    33
    rotationAnchor = TextAnchor.CENTER_LEFT;
    Differences
    Expression1Expression2Difference
    TOP_CENTERCENTER_LEFTVARIABLE_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
    1Unmatched 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
    2Unmatched 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
    3Unmatched 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
    4Unmatched 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
    5Unmatched 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
    6Unmatched 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
    7Clone fragment #1 returns variables anchor, rotationAnchor , while Clone fragment #2 returns variables anchor, rotationAnchor