double currentTickValue = lowestTickValue + (i * size); double xx = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = valueToString(currentTickValue); } // avoid to draw overlapping tick labels Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics()); double tickLabelLength = isVerticalTickLabels() ? bounds.getHeight() : bounds.getWidth(); boolean tickLabelsOverlapping = false; if (i > 0) { double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0; if (Math.abs(xx - previousDrawnTickLabelPos) < avgTickLabelLength) { tickLabelsOverlapping = true; } } if (tickLabelsOverlapping) { tickLabel = ""; // don't draw this tick label } else { // remember these values for next comparison previousDrawnTickLabelPos = xx; previousDrawnTickLabelLength = tickLabelLength; } 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); ticks.add(tick);
double currentTickValue = lowestTickValue + (i * size); double yy = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = valueToString(currentTickValue); } // avoid to draw overlapping tick labels Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics()); double tickLabelLength = isVerticalTickLabels() ? bounds.getWidth() : bounds.getHeight(); boolean tickLabelsOverlapping = false; if (i > 0) { double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0; if (Math.abs(yy - previousDrawnTickLabelPos) < avgTickLabelLength) { tickLabelsOverlapping = true; } } if (tickLabelsOverlapping) { tickLabel = ""; // don't draw this tick label } else { // remember these values for next comparison previousDrawnTickLabelPos = yy; previousDrawnTickLabelLength = tickLabelLength; } 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 NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); ticks.add(tick);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/axis/SymbolAxis.java File path: /jfreechart-1.0.10/src/org/jfree/chart/axis/SymbolAxis.java
Method name: List refreshTicksHorizontal(Graphics2D, Rectangle2D, RectangleEdge) Method name: List refreshTicksVertical(Graphics2D, Rectangle2D, RectangleEdge)
Number of AST nodes: 34 Number of AST nodes: 34
1
double currentTickValue = lowestTickValue + (i * size);
1
double currentTickValue = lowestTickValue + (i * size);
2
                double xx = valueToJava2D(currentTickValue, dataArea, edge);
2
                double yy = valueToJava2D(currentTickValue, dataArea, edge);
3
                String tickLabel;
3
                String tickLabel;
4
                NumberFormat formatter = getNumberFormatOverride();
4
                NumberFormat formatter = getNumberFormatOverride();
5
                if (formatter != null) {
5
                if (formatter != null) {
6
                    tickLabel = formatter.format(currentTickValue);
6
                    tickLabel = formatter.format(currentTickValue);
7
                }
7
                }
8
                else {
8
                else {
9
                    tickLabel = valueToString(currentTickValue);
9
                    tickLabel = valueToString(currentTickValue);
10
                }
10
                }
11
                
12
                // avoid to draw overlapping tick labels
11
                // avoid to draw overlapping tick labels
13
                Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, 
12
                Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2,
14
                        g2.getFontMetrics());
13
                        g2.getFontMetrics());
15
                double tickLabelLength = isVerticalTickLabels() 
14
                double tickLabelLength = isVerticalTickLabels() 
16
                        ? bounds.getHeight() : bounds.getWidth();
15
                    ? bounds.getWidth() : bounds.getHeight();
17
                boolean tickLabelsOverlapping = false;
16
                boolean tickLabelsOverlapping = false;
18
                if (i > 0) {
17
                if (i > 0) {
19
                    double avgTickLabelLength = (previousDrawnTickLabelLength 
18
                    double avgTickLabelLength = (previousDrawnTickLabelLength 
20
                            + tickLabelLength) / 2.0;
19
                            + tickLabelLength) / 2.0;
21
                    if (Math.abs(xx - previousDrawnTickLabelPos) 
20
                    if (Math.abs(yy - previousDrawnTickLabelPos) 
22
                            < avgTickLabelLength) {
21
                            < avgTickLabelLength) {
23
                        tickLabelsOverlapping = true;
22
                        tickLabelsOverlapping = true;    
24
                    }
23
                    }
25
                }
24
                }
26
                if (tickLabelsOverlapping) {
25
                if (tickLabelsOverlapping) {
27
                    tickLabel = ""; // don't draw this tick label
26
                    tickLabel = ""; // don't draw this tick label
28
                }
27
                }
29
                else {
28
                else {
30
                    // remember these values for next comparison
29
                    // remember these values for next comparison
31
                    previousDrawnTickLabelPos = xx;
30
                    previousDrawnTickLabelPos = yy;
32
                    previousDrawnTickLabelLength = tickLabelLength;         
31
                    previousDrawnTickLabelLength = tickLabelLength;         
33
                } 
32
                }
34
                
33
                
35
                TextAnchor anchor = null;
34
                TextAnchor anchor = null;
36
                TextAnchor rotationAnchor = null;
35
                TextAnchor rotationAnchor = null;
37
                double angle = 0.0;
36
                double angle = 0.0;
38
                if (isVerticalTickLabels()) {
37
                if (isVerticalTickLabels()) {
39
                    anchor = TextAnchor.CENTER_RIGHT;
38
                    anchor = TextAnchor.BOTTOM_CENTER;
40
                    rotationAnchor = TextAnchor.CENTER_RIGHT;
39
                    rotationAnchor = TextAnchor.BOTTOM_CENTER;
41
                    if (edge == RectangleEdge.TOP) {
40
                    if (edge == RectangleEdge.LEFT) {
42
                        angle = Math.PI / 2.0;
41
                        angle = -Math.PI / 2.0;
43
                    }
42
                    }
44
                    else {
43
                    else {
45
                        angle = -Math.PI / 2.0;
44
                        angle = Math.PI / 2.0;
46
                    }
45
                    }                    
47
                }
46
                }
48
                else {
47
                else {
49
                    if (edge == RectangleEdge.TOP) {
48
                    if (edge == RectangleEdge.LEFT) {
50
                        anchor = TextAnchor.BOTTOM_CENTER;
49
                        anchor = TextAnchor.CENTER_RIGHT;
51
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
50
                        rotationAnchor = TextAnchor.CENTER_RIGHT;
52
                    }
51
                    }
53
                    else {
52
                    else {
54
                        anchor = TextAnchor.TOP_CENTER;
53
                        anchor = TextAnchor.CENTER_LEFT;
55
                        rotationAnchor = TextAnchor.TOP_CENTER;
54
                        rotationAnchor = TextAnchor.CENTER_LEFT;
56
                    }
55
                    }
57
                }
56
                }
58
                Tick tick = new NumberTick(new Double(currentTickValue), 
57
                Tick tick = new NumberTick(new Double(currentTickValue), 
59
                        tickLabel, anchor, rotationAnchor, angle);
58
                        tickLabel, anchor, rotationAnchor, angle);
60
                ticks.add(tick);
59
                ticks.add(tick);
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)1.5
Clones locationClones are declared in the same class
Number of node comparisons236
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements34
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)72.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    11
    double currentTickValue = lowestTickValue + (i * size);
    11
    double currentTickValue = lowestTickValue + (i * size);
    12
    double xx = valueToJava2D(currentTickValue, dataArea, edge);
    12
    double xx = valueToJava2D(currentTickValue, dataArea, edge);
    12
    double yy = valueToJava2D(currentTickValue, dataArea, edge);
    Differences
    Expression1Expression2Difference
    xxyyVARIABLE_NAME_MISMATCH
    12
    double yy = valueToJava2D(currentTickValue, dataArea, edge);
    13
    String tickLabel;
    13
    String tickLabel;
    14
    NumberFormat formatter = getNumberFormatOverride();
    14
    NumberFormat formatter = getNumberFormatOverride();
    15
    if (formatter != null)
    15
    if (formatter != null)
    16
    tickLabel = formatter.format(currentTickValue);
    16
    tickLabel = formatter.format(currentTickValue);
    else
    else
    17
    tickLabel = valueToString(currentTickValue);
    17
    tickLabel = valueToString(currentTickValue);
    18
    Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics());
    18
    Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics());
    19
    double tickLabelLength = isVerticalTickLabels() ? bounds.getHeight() : bounds.getWidth();
    19
    double tickLabelLength = isVerticalTickLabels() ? bounds.getHeight() : bounds.getWidth();
    19
    double tickLabelLength = isVerticalTickLabels() ? bounds.getWidth() : bounds.getHeight();
    Differences
    Expression1Expression2Difference
    getHeightgetWidthMETHOD_INVOCATION_NAME_MISMATCH
    getWidthgetHeightMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression bounds.getHeight() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression bounds.getWidth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression bounds.getWidth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression bounds.getHeight() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19
    double tickLabelLength = isVerticalTickLabels() ? bounds.getWidth() : bounds.getHeight();
    20
    boolean tickLabelsOverlapping = false;
    20
    boolean tickLabelsOverlapping = false;
    21
    if (i > 0)
    21
    if (i > 0)
    22
    double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0;
    22
    double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0;
    23
    if (Math.abs(xx - previousDrawnTickLabelPos) < avgTickLabelLength)
    23
    if (Math.abs(xx - previousDrawnTickLabelPos) < avgTickLabelLength)
    23
    if (Math.abs(yy - previousDrawnTickLabelPos) < avgTickLabelLength)
    Differences
    Expression1Expression2Difference
    xxyyVARIABLE_NAME_MISMATCH
    23
    if (Math.abs(yy - previousDrawnTickLabelPos) < avgTickLabelLength)
    24
    tickLabelsOverlapping = true;
    24
    tickLabelsOverlapping = true;
    25
    if (tickLabelsOverlapping)
    25
    if (tickLabelsOverlapping)
    26
    tickLabel = "";
    26
    tickLabel = "";
    else
    else
    27
    previousDrawnTickLabelPos = xx;
    27
    previousDrawnTickLabelPos = xx;
    27
    previousDrawnTickLabelPos = yy;
    Differences
    Expression1Expression2Difference
    xxyyVARIABLE_NAME_MISMATCH
    27
    previousDrawnTickLabelPos = yy;
    28
    previousDrawnTickLabelLength = tickLabelLength;
    28
    previousDrawnTickLabelLength = tickLabelLength;
    29
    TextAnchor anchor = null;
    29
    TextAnchor anchor = null;
    30
    TextAnchor rotationAnchor = null;
    30
    TextAnchor rotationAnchor = null;
    31
    double angle = 0.0;
    31
    double angle = 0.0;
    32
    if (isVerticalTickLabels())
    32
    if (isVerticalTickLabels())
    33
    anchor = TextAnchor.CENTER_RIGHT;
    33
    anchor = TextAnchor.CENTER_RIGHT;
    33
    anchor = TextAnchor.BOTTOM_CENTER;
    Differences
    Expression1Expression2Difference
    CENTER_RIGHTBOTTOM_CENTERVARIABLE_NAME_MISMATCH
    33
    anchor = TextAnchor.BOTTOM_CENTER;
    34
    rotationAnchor = TextAnchor.CENTER_RIGHT;
    34
    rotationAnchor = TextAnchor.CENTER_RIGHT;
    34
    rotationAnchor = TextAnchor.BOTTOM_CENTER;
    Differences
    Expression1Expression2Difference
    CENTER_RIGHTBOTTOM_CENTERVARIABLE_NAME_MISMATCH
    34
    rotationAnchor = TextAnchor.BOTTOM_CENTER;
    35
    if (edge == RectangleEdge.TOP)
    35
    if (edge == RectangleEdge.TOP)
    35
    if (edge == RectangleEdge.LEFT)
    Differences
    Expression1Expression2Difference
    TOPLEFTVARIABLE_NAME_MISMATCH
    35
    if (edge == RectangleEdge.LEFT)
    36
    angle = Math.PI / 2.0;
    36
    angle = Math.PI / 2.0;
    36
    angle = -Math.PI / 2.0;
    Differences
    Expression1Expression2Difference
    Math.PI-Math.PITYPE_COMPATIBLE_REPLACEMENT
    36
    angle = -Math.PI / 2.0;
    else
    else
    37
    angle = -Math.PI / 2.0;
    37
    angle = -Math.PI / 2.0;
    37
    angle = Math.PI / 2.0;
    Differences
    Expression1Expression2Difference
    -Math.PIMath.PITYPE_COMPATIBLE_REPLACEMENT
    37
    angle = Math.PI / 2.0;
    else
    else
    38
    if (edge == RectangleEdge.TOP)
    38
    if (edge == RectangleEdge.TOP)
    38
    if (edge == RectangleEdge.LEFT)
    Differences
    Expression1Expression2Difference
    TOPLEFTVARIABLE_NAME_MISMATCH
    38
    if (edge == RectangleEdge.LEFT)
    39
    anchor = TextAnchor.BOTTOM_CENTER;
    39
    anchor = TextAnchor.BOTTOM_CENTER;
    39
    anchor = TextAnchor.CENTER_RIGHT;
    Differences
    Expression1Expression2Difference
    BOTTOM_CENTERCENTER_RIGHTVARIABLE_NAME_MISMATCH
    39
    anchor = TextAnchor.CENTER_RIGHT;
    40
    rotationAnchor = TextAnchor.BOTTOM_CENTER;
    40
    rotationAnchor = TextAnchor.BOTTOM_CENTER;
    40
    rotationAnchor = TextAnchor.CENTER_RIGHT;
    Differences
    Expression1Expression2Difference
    BOTTOM_CENTERCENTER_RIGHTVARIABLE_NAME_MISMATCH
    40
    rotationAnchor = TextAnchor.CENTER_RIGHT;
    else
    else
    41
    anchor = TextAnchor.TOP_CENTER;
    41
    anchor = TextAnchor.TOP_CENTER;
    41
    anchor = TextAnchor.CENTER_LEFT;
    Differences
    Expression1Expression2Difference
    TOP_CENTERCENTER_LEFTVARIABLE_NAME_MISMATCH
    41
    anchor = TextAnchor.CENTER_LEFT;
    42
    rotationAnchor = TextAnchor.TOP_CENTER;
    42
    rotationAnchor = TextAnchor.TOP_CENTER;
    42
    rotationAnchor = TextAnchor.CENTER_LEFT;
    Differences
    Expression1Expression2Difference
    TOP_CENTERCENTER_LEFTVARIABLE_NAME_MISMATCH
    42
    rotationAnchor = TextAnchor.CENTER_LEFT;
    43
    Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle);
    43
    Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle);
    44
    ticks.add(tick);
    44
    ticks.add(tick);
    Precondition Violations (5)
    Row Violation
    1Expression bounds.getHeight() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression bounds.getWidth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression bounds.getWidth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression bounds.getHeight() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variables previousDrawnTickLabelLength, previousDrawnTickLabelPos , while Clone fragment #2 returns variables previousDrawnTickLabelLength, previousDrawnTickLabelPos