if (y + size.height <= height) { itemsInColumn.add(block); block.setBounds( new Rectangle2D.Double(x, y, size.width, size.height) ); y = y + size.height + this.verticalGap; maxWidth = Math.max(maxWidth, size.width); } else { if (itemsInColumn.isEmpty()) { // place in this column (truncated) anyway block.setBounds( new Rectangle2D.Double( x, y, size.width, Math.min(size.height, height - y) ) ); y = 0.0; x = x + size.width + this.horizontalGap; } else { // start new column itemsInColumn.clear(); x = x + maxWidth + this.horizontalGap; y = 0.0; maxWidth = size.width; block.setBounds( new Rectangle2D.Double( x, y, size.width, Math.min(size.height, height) ) ); y = size.height + this.verticalGap; itemsInColumn.add(block); } }
if (x + size.width <= width) { itemsInRow.add(block); block.setBounds( new Rectangle2D.Double(x, y, size.width, size.height) ); x = x + size.width + this.horizontalGap; maxHeight = Math.max(maxHeight, size.height); } else { if (itemsInRow.isEmpty()) { // place in this row (truncated) anyway block.setBounds( new Rectangle2D.Double( x, y, Math.min(size.width, width - x), size.height ) ); x = 0.0; y = y + size.height + this.verticalGap; } else { // start new row itemsInRow.clear(); x = 0.0; y = y + maxHeight + this.verticalGap; maxHeight = size.height; block.setBounds( new Rectangle2D.Double( x, y, Math.min(size.width, width), size.height ) ); x = size.width + this.horizontalGap; itemsInRow.add(block); } }
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 arrangeNF(BlockContainer, Graphics2D, RectangleConstraint) Method name: Size2D arrangeFN(BlockContainer, Graphics2D, RectangleConstraint)
Number of AST nodes: 16 Number of AST nodes: 16
1
if (y + size.height <= height) {
1
if (x + size.width <= width) {
2
                itemsInColumn.add(block);
2
                itemsInRow.add(block);
3
                block.setBounds(
3
                block.setBounds(
4
                    new Rectangle2D.Double(x, y, size.width, size.height)
4
                    new Rectangle2D.Double(x, y, size.width, size.height)
5
                );
5
                );
6
                y = y + size.height + this.verticalGap;
6
                x = x + size.width + this.horizontalGap;
7
                maxWidth = Math.max(maxWidth, size.width);
7
                maxHeight = Math.max(maxHeight, size.height);
8
            }
8
            }
9
            else {
9
            else {
10
                if (itemsInColumn.isEmpty()) {
10
                if (itemsInRow.isEmpty()) {
11
                    // place in this column (truncated) anyway
11
                    // place in this row (truncated) anyway
12
                    block.setBounds(
12
                    block.setBounds(
13
                        new Rectangle2D.Double(
13
                        new Rectangle2D.Double(
14
                            x, y, size.width, Math.min(size.height, height - y)
14
                            x, y, Math.min(size.width, width - x), size.height
15
                        )
15
                        )
16
                    );
16
                    );
17
                    y = 0.0;
17
                    x = 0.0;
18
                    x = x + size.width + this.horizontalGap;
18
                    y = y + size.height + this.verticalGap;
19
                }
19
                }
20
                else {
20
                else {
21
                    // start new column
21
                    // start new row
22
                    itemsInColumn.clear();
22
                    itemsInRow.clear();
23
                    x = x + maxWidth + this.horizontalGap;
23
                    x = 
24
                    y = 0.0
24
0.0;
25
;
25
                    y = y + maxHeight + this.verticalGap;
26
                    maxWidth = size.width;
26
                    maxHeight = size.height;
27
                    block.setBounds(
27
                    block.setBounds(
28
                        new Rectangle2D.Double(
28
                        new Rectangle2D.Double(
29
                            x, y, size.width, Math.min(size.height, height)
29
                            x, y, Math.min(size.width, width), size.height
30
                        )
30
                        )
31
                    );
31
                    );
32
                    y = size.height + this.verticalGap;
32
                    x = size.width + this.horizontalGap;
33
                    itemsInColumn.add(block);
33
                    itemsInRow.add(block);
34
                }
34
                }
35
            }
35
            }
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.5
Clones locationClones are in different classes
Number of node comparisons147
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)71.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    12
    if (y + size.height <= height)
    12
    if (y + size.height <= height)
    10
    if (x + size.width <= width)
    Differences
    Expression1Expression2Difference
    yxVARIABLE_NAME_MISMATCH
    heightwidthVARIABLE_NAME_MISMATCH
    heightwidthVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    if (x + size.width <= width)
    13
    itemsInColumn.add(block);
    13
    itemsInColumn.add(block);
    11
    itemsInRow.add(block);
    Differences
    Expression1Expression2Difference
    itemsInColumnitemsInRowVARIABLE_NAME_MISMATCH
    11
    itemsInRow.add(block);
    14
    block.setBounds(new Rectangle2D.Double(x, y, size.width, size.height));
    12
    block.setBounds(new Rectangle2D.Double(x, y, size.width, size.height));
    15
    y = y + size.height + this.verticalGap;
    15
    y = y + size.height + this.verticalGap;
    13
    x = x + size.width + this.horizontalGap;
    Differences
    Expression1Expression2Difference
    yxVARIABLE_NAME_MISMATCH
    verticalGaphorizontalGapVARIABLE_NAME_MISMATCH
    yxVARIABLE_NAME_MISMATCH
    heightwidthVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    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
    Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13
    x = x + size.width + this.horizontalGap;
    16
    maxWidth = Math.max(maxWidth, size.width);
    16
    maxWidth = Math.max(maxWidth, size.width);
    14
    maxHeight = Math.max(maxHeight, size.height);
    Differences
    Expression1Expression2Difference
    maxWidthmaxHeightVARIABLE_NAME_MISMATCH
    maxWidthmaxHeightVARIABLE_NAME_MISMATCH
    widthheightVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    maxHeight = Math.max(maxHeight, size.height);
    else
    else
    17
    if (itemsInColumn.isEmpty())
    17
    if (itemsInColumn.isEmpty())
    15
    if (itemsInRow.isEmpty())
    Differences
    Expression1Expression2Difference
    itemsInColumnitemsInRowVARIABLE_NAME_MISMATCH
    15
    if (itemsInRow.isEmpty())
    18
    block.setBounds(new Rectangle2D.Double(x, y, size.width, Math.min(size.height, height - y)));
    18
    block.setBounds(new Rectangle2D.Double(x, y, size.width, Math.min(size.height, height - y)));
    16
    block.setBounds(new Rectangle2D.Double(x, y, Math.min(size.width, width - x), size.height));
    Differences
    Expression1Expression2Difference
    size.widthMath.min(size.width,width - x)TYPE_COMPATIBLE_REPLACEMENT
    Math.min(size.height,height - y)size.heightTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Math.min(size.width,width - x) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Math.min(size.height,height - y) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16
    block.setBounds(new Rectangle2D.Double(x, y, Math.min(size.width, width - x), size.height));
    19
    y = 0.0;
    19
    y = 0.0;
    18
    y = y + size.height + this.verticalGap;
    Differences
    Expression1Expression2Difference
    0.0y + size.height + this.verticalGapTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression y + size.height + this.verticalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18
    y = y + size.height + this.verticalGap;
    20
    x = x + size.width + this.horizontalGap;
    20
    x = x + size.width + this.horizontalGap;
    17
    x = 0.0;
    Differences
    Expression1Expression2Difference
    x + size.width + this.horizontalGap0.0TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression x + size.width + this.horizontalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17
    x = 0.0;
    else
    else
    21
    itemsInColumn.clear();
    21
    itemsInColumn.clear();
    19
    itemsInRow.clear();
    Differences
    Expression1Expression2Difference
    itemsInColumnitemsInRowVARIABLE_NAME_MISMATCH
    19
    itemsInRow.clear();
    22
    x = x + maxWidth + this.horizontalGap;
    22
    x = x + maxWidth + this.horizontalGap;
    20
    x = 0.0;
    Differences
    Expression1Expression2Difference
    x + maxWidth + this.horizontalGap0.0TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression x + maxWidth + this.horizontalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20
    x = 0.0;
    23
    y = 0.0;
    23
    y = 0.0;
    21
    y = y + maxHeight + this.verticalGap;
    Differences
    Expression1Expression2Difference
    0.0y + maxHeight + this.verticalGapTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression y + maxHeight + this.verticalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21
    y = y + maxHeight + this.verticalGap;
                                                        
    22
    maxHeight = size.height;
    Preondition Violations
    Unmatched statement maxHeight=size.height; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22
    maxHeight = size.height;
    24
    maxWidth = size.width;
    24
    maxWidth = size.width;
    Preondition Violations
    Unmatched statement maxWidth=size.width; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
    25
    block.setBounds(new Rectangle2D.Double(x, y, size.width, Math.min(size.height, height)));
    25
    block.setBounds(new Rectangle2D.Double(x, y, size.width, Math.min(size.height, height)));
    23
    block.setBounds(new Rectangle2D.Double(x, y, Math.min(size.width, width), size.height));
    Differences
    Expression1Expression2Difference
    size.widthMath.min(size.width,width)TYPE_COMPATIBLE_REPLACEMENT
    Math.min(size.height,height)size.heightTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Math.min(size.width,width) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Math.min(size.height,height) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23
    block.setBounds(new Rectangle2D.Double(x, y, Math.min(size.width, width), size.height));
    26
    y = size.height + this.verticalGap;
    26
    y = size.height + this.verticalGap;
    24
    x = size.width + this.horizontalGap;
    Differences
    Expression1Expression2Difference
    yxVARIABLE_NAME_MISMATCH
    heightwidthVARIABLE_NAME_MISMATCH
    verticalGaphorizontalGapVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24
    x = size.width + this.horizontalGap;
    27
    itemsInColumn.add(block);
    27
    itemsInColumn.add(block);
    25
    itemsInRow.add(block);
    Differences
    Expression1Expression2Difference
    itemsInColumnitemsInRowVARIABLE_NAME_MISMATCH
    25
    itemsInRow.add(block);
    Precondition Violations (27)
    Row Violation
    1Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression Math.min(size.width,width - x) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression Math.min(size.height,height - y) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression y + size.height + this.verticalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression x + size.width + this.horizontalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression x + maxWidth + this.horizontalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression y + maxHeight + this.verticalGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Unmatched statement maxHeight=size.height; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Unmatched statement maxWidth=size.width; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    21Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression Math.min(size.width,width) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression Math.min(size.height,height) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25Expression size.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression size.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27Clone fragment #1 returns variables maxWidth, x, y , while Clone fragment #2 returns variables maxHeight, y, x