RectangleInsets insets = getTickLabelInsets(); Font font = getTickLabelFont(); double maxHeight = 0.0; if (vertical) { FontMetrics fm = g2.getFontMetrics(font); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { Tick tick = (Tick) iterator.next(); Rectangle2D labelBounds = TextUtilities.getTextBounds( tick.getText(), g2, fm); if (labelBounds.getWidth() + insets.getTop() + insets.getBottom() > maxHeight) { maxHeight = labelBounds.getWidth() + insets.getTop() + insets.getBottom(); } } } else { LineMetrics metrics = font.getLineMetrics("ABCxyz", g2.getFontRenderContext()); maxHeight = metrics.getHeight() + insets.getTop() + insets.getBottom(); } return maxHeight;
RectangleInsets insets = getTickLabelInsets(); Font font = getTickLabelFont(); double maxWidth = 0.0; if (!vertical) { FontMetrics fm = g2.getFontMetrics(font); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { Tick tick = (Tick) iterator.next(); Rectangle2D labelBounds = TextUtilities.getTextBounds( tick.getText(), g2, fm); if (labelBounds.getWidth() + insets.getLeft() + insets.getRight() > maxWidth) { maxWidth = labelBounds.getWidth() + insets.getLeft() + insets.getRight(); } } } else { LineMetrics metrics = font.getLineMetrics("ABCxyz", g2.getFontRenderContext()); maxWidth = metrics.getHeight() + insets.getTop() + insets.getBottom(); } return maxWidth;
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/axis/ValueAxis.java File path: /jfreechart-1.0.10/src/org/jfree/chart/axis/ValueAxis.java
Method name: double findMaximumTickLabelHeight(List, Graphics2D, Rectangle2D, boolean) Method name: double findMaximumTickLabelWidth(List, Graphics2D, Rectangle2D, boolean)
Number of AST nodes: 14 Number of AST nodes: 14
1
RectangleInsets insets = getTickLabelInsets();
1
RectangleInsets insets = getTickLabelInsets();
2
        Font font = getTickLabelFont();
2
        Font font = getTickLabelFont();
3
        double maxHeight = 0.0;
3
        double maxWidth = 0.0;
4
        if (vertical) {
4
        if (!vertical) {
5
            FontMetrics fm = g2.getFontMetrics(font);
5
            FontMetrics fm = g2.getFontMetrics(font);
6
            Iterator iterator = ticks.iterator();
6
            Iterator iterator = ticks.iterator();
7
            while (iterator.hasNext()) {
7
            while (iterator.hasNext()) {
8
                Tick tick = (Tick) iterator.next();
8
                Tick tick = (Tick) iterator.next();
9
                Rectangle2D labelBounds = TextUtilities.getTextBounds(
9
                Rectangle2D labelBounds = TextUtilities.getTextBounds(
10
                        tick.getText(), g2, fm);
10
                        tick.getText(), g2, fm);
11
                if (labelBounds.getWidth() + insets.getTop()
11
                if (labelBounds.getWidth() + insets.getLeft()
12
                        + insets.getBottom() > maxHeight) {
12
                        + insets.getRight() > maxWidth) {
13
                    maxHeight = labelBounds.getWidth()
13
                    maxWidth = labelBounds.getWidth()
14
                                + insets.getTop() + insets.getBottom();
14
                               + insets.getLeft() + insets.getRight();
15
                }
15
                }
16
            }
16
            }
17
        }
17
        }
18
        else {
18
        else {
19
            LineMetrics metrics = font.getLineMetrics("ABCxyz",
19
            LineMetrics metrics = font.getLineMetrics("ABCxyz",
20
                    g2.getFontRenderContext());
20
                    g2.getFontRenderContext());
21
            maxHeight = metrics.getHeight()
21
            maxWidth = metrics.getHeight()
22
                        + insets.getTop() + insets.getBottom();
22
                       + insets.getTop() + insets.getBottom();
23
        }
23
        }
24
        return maxHeight;
24
        return maxWidth;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.5
Clones locationClones are declared in the same class
Number of node comparisons54
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)40.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    RectangleInsets insets = getTickLabelInsets();
    1
    RectangleInsets insets = getTickLabelInsets();
    2
    Font font = getTickLabelFont();
    2
    Font font = getTickLabelFont();
    3
    double maxHeight = 0.0;
    3
    double maxHeight = 0.0;
    3
    double maxWidth = 0.0;
    Differences
    Expression1Expression2Difference
    maxHeightmaxWidthVARIABLE_NAME_MISMATCH
    3
    double maxWidth = 0.0;
    4
    if (vertical)
    4
    if (vertical)
    4
    if (!vertical)
    Differences
    Expression1Expression2Difference
    vertical!verticalTYPE_COMPATIBLE_REPLACEMENT
    4
    if (!vertical)
    5
    FontMetrics fm = g2.getFontMetrics(font);
    5
    FontMetrics fm = g2.getFontMetrics(font);
    6
    Iterator iterator = ticks.iterator();
    6
    Iterator iterator = ticks.iterator();
    7
    while (iterator.hasNext())
    7
    while (iterator.hasNext())
    8
    Tick tick = (Tick)iterator.next();
    8
    Tick tick = (Tick)iterator.next();
    9
    Rectangle2D labelBounds = TextUtilities.getTextBounds(tick.getText(), g2, fm);
    9
    Rectangle2D labelBounds = TextUtilities.getTextBounds(tick.getText(), g2, fm);
    10
    if (labelBounds.getWidth() + insets.getTop() + insets.getBottom() > maxHeight)
    10
    if (labelBounds.getWidth() + insets.getTop() + insets.getBottom() > maxHeight)
    10
    if (labelBounds.getWidth() + insets.getLeft() + insets.getRight() > maxWidth)
    Differences
    Expression1Expression2Difference
    getBottomgetRightMETHOD_INVOCATION_NAME_MISMATCH
    getTopgetLeftMETHOD_INVOCATION_NAME_MISMATCH
    maxHeightmaxWidthVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression insets.getBottom() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression insets.getRight() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression insets.getTop() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression insets.getLeft() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    if (labelBounds.getWidth() + insets.getLeft() + insets.getRight() > maxWidth)
    11
    maxHeight = labelBounds.getWidth() + insets.getTop() + insets.getBottom();
    11
    maxHeight = labelBounds.getWidth() + insets.getTop() + insets.getBottom();
    11
    maxWidth = labelBounds.getWidth() + insets.getLeft() + insets.getRight();
    Differences
    Expression1Expression2Difference
    maxHeightmaxWidthVARIABLE_NAME_MISMATCH
    getBottomgetRightMETHOD_INVOCATION_NAME_MISMATCH
    getTopgetLeftMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression insets.getBottom() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression insets.getRight() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression insets.getTop() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression insets.getLeft() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    maxWidth = labelBounds.getWidth() + insets.getLeft() + insets.getRight();
    else
    else
    12
    LineMetrics metrics = font.getLineMetrics("ABCxyz", g2.getFontRenderContext());
    12
    LineMetrics metrics = font.getLineMetrics("ABCxyz", g2.getFontRenderContext());
    13
    maxHeight = metrics.getHeight() + insets.getTop() + insets.getBottom();
    13
    maxHeight = metrics.getHeight() + insets.getTop() + insets.getBottom();
    13
    maxWidth = metrics.getHeight() + insets.getTop() + insets.getBottom();
    Differences
    Expression1Expression2Difference
    maxHeightmaxWidthVARIABLE_NAME_MISMATCH
    13
    maxWidth = metrics.getHeight() + insets.getTop() + insets.getBottom();
    14
    return maxHeight;
    14
    return maxHeight;
    14
    return maxWidth;
    Differences
    Expression1Expression2Difference
    maxHeightmaxWidthVARIABLE_NAME_MISMATCH
    14
    return maxWidth;
    Precondition Violations (8)
    Row Violation
    1Expression insets.getBottom() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression insets.getRight() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression insets.getTop() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression insets.getLeft() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression insets.getBottom() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression insets.getRight() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression insets.getTop() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression insets.getLeft() cannot be parameterized, because it has dependencies to/from statements that will be extracted