double y = 0.0; double height = 0.0; double maxWidth = 0.0; List blocks = container.getBlocks(); int blockCount = blocks.size(); if (blockCount > 0) { Size2D[] sizes = new Size2D[blocks.size()]; for (int i = 0; i < blocks.size(); i++) { Block block = (Block) blocks.get(i); sizes[i] = block.arrange(g2, RectangleConstraint.NONE); height = height + sizes[i].getHeight(); maxWidth = Math.max(sizes[i].width, maxWidth); block.setBounds( new Rectangle2D.Double( 0.0, y, sizes[i].width, sizes[i].height ) ); y = y + sizes[i].height + this.verticalGap; } if (blockCount > 1) { height = height + this.verticalGap * (blockCount - 1); } if (this.horizontalAlignment != HorizontalAlignment.LEFT) { for (int i = 0; i < blocks.size(); i++) { //Block b = (Block) blocks.get(i); if (this.horizontalAlignment == HorizontalAlignment.CENTER) { //TODO: shift block right by half } else if (this.horizontalAlignment == HorizontalAlignment.RIGHT) { //TODO: shift block over to right } } } } return new Size2D(maxWidth, height);
double x = 0.0; double width = 0.0; double maxHeight = 0.0; List blocks = container.getBlocks(); int blockCount = blocks.size(); if (blockCount > 0) { Size2D[] sizes = new Size2D[blocks.size()]; for (int i = 0; i < blocks.size(); i++) { Block block = (Block) blocks.get(i); sizes[i] = block.arrange(g2, RectangleConstraint.NONE); width = width + sizes[i].getWidth(); maxHeight = Math.max(sizes[i].height, maxHeight); block.setBounds( new Rectangle2D.Double( x, 0.0, sizes[i].width, sizes[i].height ) ); x = x + sizes[i].width + this.horizontalGap; } if (blockCount > 1) { width = width + this.horizontalGap * (blockCount - 1); } if (this.verticalAlignment != VerticalAlignment.TOP) { for (int i = 0; i < blocks.size(); i++) { //Block b = (Block) blocks.get(i); if (this.verticalAlignment == VerticalAlignment.CENTER) { //TODO: shift block down by half } else if (this.verticalAlignment == VerticalAlignment.BOTTOM) { //TODO: shift block down to bottom } } } } return new Size2D(width, maxHeight);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/block/ColumnArrangement.java File path: /jfreechart-1.0.10/src/org/jfree/chart/block/FlowArrangement.java
Method name: Size2D arrangeNN(BlockContainer, Graphics2D) Method name: Size2D arrangeNN(BlockContainer, Graphics2D)
Number of AST nodes: 21 Number of AST nodes: 21
1
double y = 0.0;
1
double x = 0.0;
2
        double height = 0.0;
2
        double width = 0.0;
3
        double maxWidth = 0.0;
3
        double maxHeight = 0.0;
4
        List blocks = container.getBlocks();
4
        List blocks = container.getBlocks();
5
        int blockCount = blocks.size();
5
        int blockCount = blocks.size();
6
        if (blockCount > 0) {
6
        if (blockCount > 0) {
7
            Size2D[] sizes = new Size2D[blocks.size()];
7
            Size2D[] sizes = new Size2D[blocks.size()];
8
            for (int i = 0; i < blocks.size(); i++) {
8
            for (int i = 0; i < blocks.size(); i++) {
9
                Block block = (Block) blocks.get(i);
9
                Block block = (Block) blocks.get(i);
10
                sizes[i] = block.arrange(g2, RectangleConstraint.NONE);
10
                sizes[i] = block.arrange(g2, RectangleConstraint.NONE);
11
                height = height + sizes[i].getHeight();
11
                width = width + sizes[i].getWidth();
12
                maxWidth = Math.max(sizes[i].width, maxWidth);
12
                maxHeight = Math.max(sizes[i].height, maxHeight);
13
                block.setBounds(
13
                block.setBounds(
14
                    new Rectangle2D.Double(
14
                    new Rectangle2D.Double(
15
                        0.0, y, sizes[i].width, sizes[i].height
15
                        x, 0.0, sizes[i].width, sizes[i].height
16
                    )
16
                    )
17
                );
17
                );
18
                y = y + sizes[i].height + this.verticalGap;
18
                x = x + sizes[i].width + this.horizontalGap;
19
            }
19
            }
20
            if (blockCount > 1) {
20
            if (blockCount > 1) {
21
                height = height + this.verticalGap * (blockCount - 1);   
21
                width = width + this.horizontalGap * (blockCount - 1);   
22
            }
22
            }
23
            if (this.horizontalAlignment != HorizontalAlignment.LEFT) {
23
            if (this.verticalAlignment != VerticalAlignment.TOP) {
24
                for (int i = 0; i < blocks.size(); i++) {
24
                for (int i = 0; i < blocks.size(); i++) {
25
                    //Block b = (Block) blocks.get(i);
25
                    //Block b = (Block) blocks.get(i);
26
                    if (this.horizontalAlignment 
26
                    if (this.verticalAlignment 
27
                            == HorizontalAlignment.CENTER) {
27
== VerticalAlignment.CENTER) {
28
                        //TODO: shift block right by half
28
                        //TODO: shift block down by half
29
                    }
29
                    }
30
                    else if (this.horizontalAlignment 
30
                    else if (this.verticalAlignment 
31
                            == HorizontalAlignment.RIGHT) {
31
                            == VerticalAlignment.BOTTOM) {
32
                        //TODO: shift block over to right
32
                        //TODO: shift block down to bottom
33
                    }
33
                    }
34
                }            
34
                }            
35
            }
35
            }
36
        }
36
        }
37
        return new Size2D(maxWidth, height);
37
        return new Size2D(width, maxHeight);
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.2
Clones locationClones are in different classes
Number of node comparisons101
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements21
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)27.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    double y = 0.0;
    1
    double y = 0.0;
    1
    double x = 0.0;
    Differences
    Expression1Expression2Difference
    yxVARIABLE_NAME_MISMATCH
    1
    double x = 0.0;
    2
    double height = 0.0;
    2
    double height = 0.0;
    3
    double maxHeight = 0.0;
    Differences
    Expression1Expression2Difference
    heightmaxHeightVARIABLE_NAME_MISMATCH
    3
    double maxHeight = 0.0;
    3
    double maxWidth = 0.0;
    3
    double maxWidth = 0.0;
    2
    double width = 0.0;
    Differences
    Expression1Expression2Difference
    maxWidthwidthVARIABLE_NAME_MISMATCH
    2
    double width = 0.0;
    4
    List blocks = container.getBlocks();
    4
    List blocks = container.getBlocks();
    5
    int blockCount = blocks.size();
    5
    int blockCount = blocks.size();
    6
    if (blockCount > 0)
    6
    if (blockCount > 0)
    7
    Size2D[] sizes = new Size2D[blocks.size()];
    7
    Size2D[] sizes = new Size2D[blocks.size()];
    8
    for (int i = 0; i < blocks.size(); i++)
    8
    for (int i = 0; i < blocks.size(); i++)
    9
    Block block = (Block)blocks.get(i);
    9
    Block block = (Block)blocks.get(i);
    10
    sizes[i] = block.arrange(g2, RectangleConstraint.NONE);
    10
    sizes[i] = block.arrange(g2, RectangleConstraint.NONE);
    11
    height = height + sizes[i].getHeight();
    11
    height = height + sizes[i].getHeight();
    11
    width = width + sizes[i].getWidth();
    Differences
    Expression1Expression2Difference
    heightwidthVARIABLE_NAME_MISMATCH
    heightwidthVARIABLE_NAME_MISMATCH
    getHeightgetWidthMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sizes[i].getHeight() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sizes[i].getWidth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    width = width + sizes[i].getWidth();
    12
    maxWidth = Math.max(sizes[i].width, maxWidth);
    12
    maxWidth = Math.max(sizes[i].width, maxWidth);
    12
    maxHeight = Math.max(sizes[i].height, maxHeight);
    Differences
    Expression1Expression2Difference
    maxWidthmaxHeightVARIABLE_NAME_MISMATCH
    widthheightVARIABLE_NAME_MISMATCH
    maxWidthmaxHeightVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression maxWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression maxHeight cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sizes[i].width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sizes[i].height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression maxWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression maxHeight cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    maxHeight = Math.max(sizes[i].height, maxHeight);
    13
    block.setBounds(new Rectangle2D.Double(0.0, y, sizes[i].width, sizes[i].height));
    13
    block.setBounds(new Rectangle2D.Double(0.0, y, sizes[i].width, sizes[i].height));
    13
    block.setBounds(new Rectangle2D.Double(x, 0.0, sizes[i].width, sizes[i].height));
    Differences
    Expression1Expression2Difference
    0.0xTYPE_COMPATIBLE_REPLACEMENT
    y0.0TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13
    block.setBounds(new Rectangle2D.Double(x, 0.0, sizes[i].width, sizes[i].height));
    14
    y = y + sizes[i].height + this.verticalGap;
    14
    y = y + sizes[i].height + this.verticalGap;
    14
    x = x + sizes[i].width + this.horizontalGap;
    Differences
    Expression1Expression2Difference
    yxVARIABLE_NAME_MISMATCH
    verticalGaphorizontalGapVARIABLE_NAME_MISMATCH
    yxVARIABLE_NAME_MISMATCH
    heightwidthVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression sizes[i].height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sizes[i].width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    x = x + sizes[i].width + this.horizontalGap;
    15
    if (blockCount > 1)
    15
    if (blockCount > 1)
    16
    height = height + this.verticalGap * (blockCount - 1);
    16
    height = height + this.verticalGap * (blockCount - 1);
    16
    width = width + this.horizontalGap * (blockCount - 1);
    Differences
    Expression1Expression2Difference
    heightwidthVARIABLE_NAME_MISMATCH
    heightwidthVARIABLE_NAME_MISMATCH
    verticalGaphorizontalGapVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16
    width = width + this.horizontalGap * (blockCount - 1);
    17
    if (this.horizontalAlignment != HorizontalAlignment.LEFT)
    17
    if (this.horizontalAlignment != HorizontalAlignment.LEFT)
    17
    if (this.verticalAlignment != VerticalAlignment.TOP)
    Differences
    Expression1Expression2Difference
    horizontalAlignmentverticalAlignmentVARIABLE_NAME_MISMATCH
    org.jfree.ui.HorizontalAlignmentorg.jfree.ui.VerticalAlignmentVARIABLE_TYPE_MISMATCH
    org.jfree.ui.HorizontalAlignmentorg.jfree.ui.VerticalAlignmentVARIABLE_TYPE_MISMATCH
    LEFTTOPVARIABLE_NAME_MISMATCH
    org.jfree.ui.HorizontalAlignmentorg.jfree.ui.VerticalAlignmentVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.ui.HorizontalAlignment of variable this.horizontalAlignment does not match with type org.jfree.ui.VerticalAlignment of variable this.verticalAlignment
    • Make classes org.jfree.ui.HorizontalAlignment and org.jfree.ui.VerticalAlignment extend a common superclass
    Type org.jfree.ui.HorizontalAlignment does not match with type org.jfree.ui.VerticalAlignment
    • Make classes org.jfree.ui.HorizontalAlignment and org.jfree.ui.VerticalAlignment extend a common superclass
    Type org.jfree.ui.HorizontalAlignment of variable HorizontalAlignment.LEFT does not match with type org.jfree.ui.VerticalAlignment of variable VerticalAlignment.TOP
    • Make classes org.jfree.ui.HorizontalAlignment and org.jfree.ui.VerticalAlignment extend a common superclass
    17
    if (this.verticalAlignment != VerticalAlignment.TOP)
    18
    for (int i = 0; i < blocks.size(); i++)
    18
    for (int i = 0; i < blocks.size(); i++)
    19
    if (this.horizontalAlignment == HorizontalAlignment.CENTER)
    19
    if (this.horizontalAlignment == HorizontalAlignment.CENTER)
    19
    if (this.verticalAlignment == VerticalAlignment.CENTER)
    Differences
    Expression1Expression2Difference
    horizontalAlignmentverticalAlignmentVARIABLE_NAME_MISMATCH
    org.jfree.ui.HorizontalAlignmentorg.jfree.ui.VerticalAlignmentVARIABLE_TYPE_MISMATCH
    org.jfree.ui.HorizontalAlignmentorg.jfree.ui.VerticalAlignmentVARIABLE_TYPE_MISMATCH
    org.jfree.ui.HorizontalAlignmentorg.jfree.ui.VerticalAlignmentVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.ui.HorizontalAlignment of variable this.horizontalAlignment does not match with type org.jfree.ui.VerticalAlignment of variable this.verticalAlignment
    • Make classes org.jfree.ui.HorizontalAlignment and org.jfree.ui.VerticalAlignment extend a common superclass
    Type org.jfree.ui.HorizontalAlignment does not match with type org.jfree.ui.VerticalAlignment
    • Make classes org.jfree.ui.HorizontalAlignment and org.jfree.ui.VerticalAlignment extend a common superclass
    Type org.jfree.ui.HorizontalAlignment of variable HorizontalAlignment.CENTER does not match with type org.jfree.ui.VerticalAlignment of variable VerticalAlignment.CENTER
    • Make classes org.jfree.ui.HorizontalAlignment and org.jfree.ui.VerticalAlignment extend a common superclass
    19
    if (this.verticalAlignment == VerticalAlignment.CENTER)
    20
    else if (this.horizontalAlignment == HorizontalAlignment.RIGHT)
    20
    else if (this.horizontalAlignment == HorizontalAlignment.RIGHT)
    20
    else if (this.verticalAlignment == VerticalAlignment.BOTTOM)
    Differences
    Expression1Expression2Difference
    horizontalAlignmentverticalAlignmentVARIABLE_NAME_MISMATCH
    org.jfree.ui.HorizontalAlignmentorg.jfree.ui.VerticalAlignmentVARIABLE_TYPE_MISMATCH
    org.jfree.ui.HorizontalAlignmentorg.jfree.ui.VerticalAlignmentVARIABLE_TYPE_MISMATCH
    RIGHTBOTTOMVARIABLE_NAME_MISMATCH
    org.jfree.ui.HorizontalAlignmentorg.jfree.ui.VerticalAlignmentVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.ui.HorizontalAlignment of variable this.horizontalAlignment does not match with type org.jfree.ui.VerticalAlignment of variable this.verticalAlignment
    • Make classes org.jfree.ui.HorizontalAlignment and org.jfree.ui.VerticalAlignment extend a common superclass
    Type org.jfree.ui.HorizontalAlignment does not match with type org.jfree.ui.VerticalAlignment
    • Make classes org.jfree.ui.HorizontalAlignment and org.jfree.ui.VerticalAlignment extend a common superclass
    Type org.jfree.ui.HorizontalAlignment of variable HorizontalAlignment.RIGHT does not match with type org.jfree.ui.VerticalAlignment of variable VerticalAlignment.BOTTOM
    • Make classes org.jfree.ui.HorizontalAlignment and org.jfree.ui.VerticalAlignment extend a common superclass
    20
    else if (this.verticalAlignment == VerticalAlignment.BOTTOM)
    21
    return new Size2D(maxWidth, height);
    21
    return new Size2D(maxWidth, height);
    21
    return new Size2D(width, maxHeight);
    Differences
    Expression1Expression2Difference
    maxWidthwidthVARIABLE_NAME_MISMATCH
    heightmaxHeightVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression maxWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression maxHeight cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21
    return new Size2D(width, maxHeight);
    Precondition Violations (33)
    Row Violation
    1Expression height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression sizes[i].getHeight() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression sizes[i].getWidth() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression maxWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression maxHeight cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression sizes[i].width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression sizes[i].height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression maxWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression maxHeight cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression sizes[i].height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression sizes[i].width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Type org.jfree.ui.HorizontalAlignment of variable this.horizontalAlignment does not match with type org.jfree.ui.VerticalAlignment of variable this.verticalAlignment
    22Type org.jfree.ui.HorizontalAlignment does not match with type org.jfree.ui.VerticalAlignment
    23Type org.jfree.ui.HorizontalAlignment of variable HorizontalAlignment.LEFT does not match with type org.jfree.ui.VerticalAlignment of variable VerticalAlignment.TOP
    24Type org.jfree.ui.HorizontalAlignment of variable this.horizontalAlignment does not match with type org.jfree.ui.VerticalAlignment of variable this.verticalAlignment
    25Type org.jfree.ui.HorizontalAlignment does not match with type org.jfree.ui.VerticalAlignment
    26Type org.jfree.ui.HorizontalAlignment of variable HorizontalAlignment.CENTER does not match with type org.jfree.ui.VerticalAlignment of variable VerticalAlignment.CENTER
    27Type org.jfree.ui.HorizontalAlignment of variable this.horizontalAlignment does not match with type org.jfree.ui.VerticalAlignment of variable this.verticalAlignment
    28Type org.jfree.ui.HorizontalAlignment does not match with type org.jfree.ui.VerticalAlignment
    29Type org.jfree.ui.HorizontalAlignment of variable HorizontalAlignment.RIGHT does not match with type org.jfree.ui.VerticalAlignment of variable VerticalAlignment.BOTTOM
    30Expression maxWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    31Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    32Expression height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    33Expression maxHeight cannot be parameterized, because it has dependencies to/from statements that will be extracted