if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { float maxWidth = (float) w; g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2)); this.content.setLineAlignment(this.textAlignment); Size2D contentSize = this.content.calculateDimensions(g2); if (this.expandToFitSpace) { return new Size2D(maxWidth, contentSize.getHeight()); } else { return contentSize; } } else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) { float maxWidth = Float.MAX_VALUE; g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2)); this.content.setLineAlignment(this.textAlignment); Size2D contentSize = this.content.calculateDimensions(g2); // transpose the dimensions, because the title is rotated if (this.expandToFitSpace) { return new Size2D(contentSize.getHeight(), maxWidth); } else { return new Size2D(contentSize.height, contentSize.width); } } else { throw new RuntimeException("Unrecognised exception."); }
if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { float maxWidth = (float) widthRange.getUpperBound(); g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2)); this.content.setLineAlignment(this.textAlignment); Size2D contentSize = this.content.calculateDimensions(g2); if (this.expandToFitSpace) { return new Size2D(maxWidth, contentSize.getHeight()); } else { return contentSize; } } else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) { float maxWidth = (float) heightRange.getUpperBound(); g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2)); this.content.setLineAlignment(this.textAlignment); Size2D contentSize = this.content.calculateDimensions(g2); // transpose the dimensions, because the title is rotated if (this.expandToFitSpace) { return new Size2D(contentSize.getHeight(), maxWidth); } else { return new Size2D(contentSize.height, contentSize.width); } } else { throw new RuntimeException("Unrecognised exception."); }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/title/TextTitle.java File path: /jfreechart-1.0.10/src/org/jfree/chart/title/TextTitle.java
Method name: Size2D arrangeFN(Graphics2D, double) Method name: Size2D arrangeRR(Graphics2D, Range, Range)
Number of AST nodes: 19 Number of AST nodes: 19
1
if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) {
1
if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) {
2
            float maxWidth = (float) w;
2
            float maxWidth = (float) widthRange.getUpperBound();
3
            g2.setFont(this.font);
3
            g2.setFont(this.font);
4
            this.content = TextUtilities.createTextBlock(this.text, this.font,
4
            this.content = TextUtilities.createTextBlock(this.text, this.font,
5
                    this.paint, maxWidth, this.maximumLinesToDisplay,
5
                    this.paint, maxWidth, this.maximumLinesToDisplay,
6
                    new G2TextMeasurer(g2));
6
                    new G2TextMeasurer(g2));
7
            this.content.setLineAlignment(this.textAlignment);
7
            this.content.setLineAlignment(this.textAlignment);
8
            Size2D contentSize = this.content.calculateDimensions(g2);
8
            Size2D contentSize = this.content.calculateDimensions(g2);
9
            if (this.expandToFitSpace) {
9
            if (this.expandToFitSpace) {
10
                return new Size2D(maxWidth, contentSize.getHeight());
10
                return new Size2D(maxWidth, contentSize.getHeight());
11
            }
11
            }
12
            else {
12
            else {
13
                return contentSize;
13
                return contentSize;
14
            }
14
            }
15
        }
15
        }
16
        else if (position == RectangleEdge.LEFT || position
16
        else if (position == RectangleEdge.LEFT || position
17
                == RectangleEdge.RIGHT) {
17
                == RectangleEdge.RIGHT) {
18
            float maxWidth = Float.MAX_VALUE;
18
            float maxWidth = (float) heightRange.getUpperBound();
19
            g2.setFont(this.font);
19
            g2.setFont(this.font);
20
            this.content = TextUtilities.createTextBlock(this.text, this.font,
20
            this.content = TextUtilities.createTextBlock(this.text, this.font,
21
                    this.paint, maxWidth, this.maximumLinesToDisplay,
21
                    this.paint, maxWidth, this.maximumLinesToDisplay,
22
                    new G2TextMeasurer(g2));
22
                    new G2TextMeasurer(g2));
23
            this.content.setLineAlignment(this.textAlignment);
23
            this.content.setLineAlignment(this.textAlignment);
24
            Size2D contentSize = this.content.calculateDimensions(g2);
24
            Size2D contentSize = this.content.calculateDimensions(g2);
25
            // transpose the dimensions, because the title is rotated
25
            // transpose the dimensions, because the title is rotated
26
            if (this.expandToFitSpace) {
26
            if (this.expandToFitSpace) {
27
                return new Size2D(contentSize.getHeight(), maxWidth);
27
                return new Size2D(contentSize.getHeight(), maxWidth);
28
            }
28
            }
29
            else {
29
            else {
30
                return new Size2D(contentSize.height, contentSize.width);
30
                return new Size2D(contentSize.height, contentSize.width);
31
            }
31
            }
32
        }
32
        }
33
        else {
33
        else {
34
            throw new RuntimeException("Unrecognised exception.");
34
            throw new RuntimeException("Unrecognised exception.");
35
        }
35
        }
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)1.0
Clones locationClones are declared in the same class
Number of node comparisons115
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements19
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)12.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM)
    2
    if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM)
    3
    float maxWidth = (float)w;
    3
    float maxWidth = (float)w;
    3
    float maxWidth = (float)widthRange.getUpperBound();
    Differences
    Expression1Expression2Difference
    wwidthRange.getUpperBound()TYPE_COMPATIBLE_REPLACEMENT
    3
    float maxWidth = (float)widthRange.getUpperBound();
    4
    g2.setFont(this.font);
    4
    g2.setFont(this.font);
    5
    this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2));
    5
    this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2));
    6
    this.content.setLineAlignment(this.textAlignment);
    6
    this.content.setLineAlignment(this.textAlignment);
    7
    Size2D contentSize = this.content.calculateDimensions(g2);
    7
    Size2D contentSize = this.content.calculateDimensions(g2);
    8
    if (this.expandToFitSpace)
    8
    if (this.expandToFitSpace)
    9
    return new Size2D(maxWidth, contentSize.getHeight());
    9
    return new Size2D(maxWidth, contentSize.getHeight());
    else
    else
    10
    return contentSize;
    10
    return contentSize;
    11
    else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT)
    11
    else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT)
    12
    float maxWidth = Float.MAX_VALUE;
    12
    float maxWidth = Float.MAX_VALUE;
    12
    float maxWidth = (float)heightRange.getUpperBound();
    Differences
    Expression1Expression2Difference
    Float.MAX_VALUE(float)heightRange.getUpperBound()TYPE_COMPATIBLE_REPLACEMENT
    12
    float maxWidth = (float)heightRange.getUpperBound();
    13
    g2.setFont(this.font);
    13
    g2.setFont(this.font);
    14
    this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2));
    14
    this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2));
    15
    this.content.setLineAlignment(this.textAlignment);
    15
    this.content.setLineAlignment(this.textAlignment);
    16
    Size2D contentSize = this.content.calculateDimensions(g2);
    16
    Size2D contentSize = this.content.calculateDimensions(g2);
    17
    if (this.expandToFitSpace)
    17
    if (this.expandToFitSpace)
    18
    return new Size2D(contentSize.getHeight(), maxWidth);
    18
    return new Size2D(contentSize.getHeight(), maxWidth);
    else
    else
    19
    return new Size2D(contentSize.height, contentSize.width);
    19
    return new Size2D(contentSize.height, contentSize.width);
    else
    else
    20
    throw new RuntimeException("Unrecognised exception.");
    20
    throw new RuntimeException("Unrecognised exception.");
    Precondition Violations (0)
    Row Violation