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); }
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); } }
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 refreshTicksVertical(Graphics2D, Rectangle2D, RectangleEdge) Method name: List refreshTicksHorizontal(Graphics2D, Rectangle2D, RectangleEdge)
Number of AST nodes: 25 Number of AST nodes: 24
1
if (count <= ValueAxis.MAXIMUM_TICK_COUNT) {
1
for (int i = 0; i < count; i++) {
2
            for (int i = 0; i < count; i++) {
2
                double currentTickValue = lowestTickValue + (i * size);
3
                double currentTickValue = lowestTickValue + (i * size);
3
                String tickLabel;
4
                String tickLabel;
4
                NumberFormat formatter = getNumberFormatOverride();
5
                NumberFormat formatter = getNumberFormatOverride();
5
                if (formatter != null) {
6
                if (formatter != null) {
6
                    tickLabel = formatter.format(currentTickValue);
7
                    tickLabel = formatter.format(currentTickValue);
7
                }
8
                }
8
                else {
9
                else {
9
                    tickLabel = getTickUnit().valueToString(currentTickValue);
10
                    tickLabel = getTickUnit().valueToString(currentTickValue);
10
                }
11
                }
11
                TextAnchor anchor = null;
12
                TextAnchor anchor = null;
12
                TextAnchor rotationAnchor = null;
13
                TextAnchor rotationAnchor = null;
13
                double angle = 0.0;
14
                double angle = 0.0;
14
                if (isVerticalTickLabels()) {
15
                if (isVerticalTickLabels()) {
15
                    if (edge == RectangleEdge.LEFT) {
16
                    
16
                        anchor = TextAnchor.BOTTOM_CENTER;
17
    
17
anchor = TextAnchor.CENTER_RIGHT;
18
                    rotationAnchor = TextAnchor.BOTTOM_CENTER;
18
                    rotationAnchor = TextAnchor.CENTER_RIGHT;
19
                        angle = -Math.PI / 2.0;
19
                    
20
                    }
21
                    else {
22
                        anchor = TextAnchor.BOTTOM_CENTER;
23
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
20
if (edge == RectangleEdge.TOP) {
21
                        angle = Math.PI / 2.0;
22
                    }
23
                    else {
24
                        angle = Math.PI / 2.0;
24
                        angle = -Math.PI / 2.0;
25
                    }
25
                    }
26
                }
26
                }
27
                else {
27
                else {
28
                    if (edge == RectangleEdge.LEFT) {
28
                    if (edge == RectangleEdge.TOP) {
29
                        anchor = TextAnchor.CENTER_RIGHT;
29
                        anchor = TextAnchor.BOTTOM_CENTER;
30
                        rotationAnchor = TextAnchor.CENTER_RIGHT;
30
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
31
                    }
31
                    }
32
                    else {
32
                    else {
33
                        anchor = TextAnchor.CENTER_LEFT;
33
                        anchor = TextAnchor.TOP_CENTER;
34
                        rotationAnchor = TextAnchor.CENTER_LEFT;
34
                        rotationAnchor = TextAnchor.TOP_CENTER;
35
                    }
35
                    }
36
                }
36
                }
37
                Tick tick = new NumberTick(new Double(currentTickValue),
37
                Tick tick = new NumberTick(new Double(currentTickValue),
38
                		tickLabel, anchor, rotationAnchor, angle);
38
                		tickLabel, anchor, rotationAnchor, angle);
39
                result.add(tick);
39
                result.add(tick);
40
            }
40
            }
41
        }
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.9
Clones locationClones are declared in the same class
Number of node comparisons164
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements18
    Number of unmapped statements in the first code fragment7
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)12.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    11
    for (int i = 0; i < count; i++)
    10
    for (int i = 0; i < count; i++)
    12
    double currentTickValue = lowestTickValue + (i * size);
    11
    double currentTickValue = lowestTickValue + (i * size);
    13
    String tickLabel;
    12
    String tickLabel;
    14
    NumberFormat formatter = getNumberFormatOverride();
    13
    NumberFormat formatter = getNumberFormatOverride();
    15
    if (formatter != null)
    14
    if (formatter != null)
    16
    tickLabel = formatter.format(currentTickValue);
    15
    tickLabel = formatter.format(currentTickValue);
    else
    else
    17
    tickLabel = getTickUnit().valueToString(currentTickValue);
    16
    tickLabel = getTickUnit().valueToString(currentTickValue);
    18
    TextAnchor anchor = null;
    17
    TextAnchor anchor = null;
    19
    TextAnchor rotationAnchor = null;
    18
    TextAnchor rotationAnchor = null;
    20
    double angle = 0.0;
    19
    double angle = 0.0;
                                                                
    20
    if (isVerticalTickLabels())
                                                                          
    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
    21
    anchor = 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
    22
    rotationAnchor = TextAnchor.CENTER_RIGHT;
    21
    if (isVerticalTickLabels())
                                                                
    34
    Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle);
    31
    Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle);
    35
    result.add(tick);
    32
    result.add(tick);
    22
    if (edge == RectangleEdge.LEFT)
    22
    if (edge == RectangleEdge.LEFT)
    26
    if (edge == RectangleEdge.TOP)
    Differences
    Expression1Expression2Difference
    LEFTTOPVARIABLE_NAME_MISMATCH
    26
    if (edge == RectangleEdge.TOP)
    23
    anchor = TextAnchor.BOTTOM_CENTER;
    27
    anchor = TextAnchor.BOTTOM_CENTER;
    24
    rotationAnchor = TextAnchor.BOTTOM_CENTER;
    28
    rotationAnchor = TextAnchor.BOTTOM_CENTER;
    25
    angle = -Math.PI / 2.0;
    25
    angle = -Math.PI / 2.0;
    Preondition Violations
    Unmatched statement angle=-Math.PI / 2.0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                      
    else
    else
    26
    anchor = TextAnchor.BOTTOM_CENTER;
    26
    anchor = TextAnchor.BOTTOM_CENTER;
    29
    anchor = TextAnchor.TOP_CENTER;
    Differences
    Expression1Expression2Difference
    BOTTOM_CENTERTOP_CENTERVARIABLE_NAME_MISMATCH
    29
    anchor = TextAnchor.TOP_CENTER;
    27
    rotationAnchor = TextAnchor.BOTTOM_CENTER;
    27
    rotationAnchor = TextAnchor.BOTTOM_CENTER;
    30
    rotationAnchor = TextAnchor.TOP_CENTER;
    Differences
    Expression1Expression2Difference
    BOTTOM_CENTERTOP_CENTERVARIABLE_NAME_MISMATCH
    30
    rotationAnchor = TextAnchor.TOP_CENTER;
    28
    angle = Math.PI / 2.0;
    28
    angle = Math.PI / 2.0;
    Preondition Violations
    Unmatched statement angle=Math.PI / 2.0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
    29
    if (edge == RectangleEdge.LEFT)
    29
    if (edge == RectangleEdge.LEFT)
    23
    if (edge == RectangleEdge.TOP)
    Differences
    Expression1Expression2Difference
    LEFTTOPVARIABLE_NAME_MISMATCH
    23
    if (edge == RectangleEdge.TOP)
                                                    
    24
    angle = Math.PI / 2.0;
    Preondition Violations
    Unmatched statement angle=Math.PI / 2.0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    24
    angle = Math.PI / 2.0;
    30
    anchor = TextAnchor.CENTER_RIGHT;
    30
    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
                                                                          
    31
    rotationAnchor = TextAnchor.CENTER_RIGHT;
    31
    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
                                                                                          
    else
            
                                                      
    25
    angle = -Math.PI / 2.0;
    Preondition Violations
    Unmatched statement angle=-Math.PI / 2.0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    25
    angle = -Math.PI / 2.0;
    32
    anchor = TextAnchor.CENTER_LEFT;
    32
    anchor = TextAnchor.CENTER_LEFT;
    Preondition Violations
    Unmatched statement anchor=TextAnchor.CENTER_LEFT; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                        
    33
    rotationAnchor = TextAnchor.CENTER_LEFT;
    33
    rotationAnchor = TextAnchor.CENTER_LEFT;
    Preondition Violations
    Unmatched statement rotationAnchor=TextAnchor.CENTER_LEFT; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                        
    Precondition Violations (11)
    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 angle=-Math.PI / 2.0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement angle=Math.PI / 2.0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement angle=Math.PI / 2.0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched 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
    7Unmatched 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
    8Unmatched statement angle=-Math.PI / 2.0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement anchor=TextAnchor.CENTER_LEFT; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement rotationAnchor=TextAnchor.CENTER_LEFT; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Clone fragment #1 returns variables angle, anchor, rotationAnchor , while Clone fragment #2 returns variables anchor, rotationAnchor, angle