for(int i = 2; i < comp.length; i++) { int btnWidth = comp[i].getPreferredSize().width; if(btnWidth + x > width) { x = insets.left; y += rowHeight; } comp[i].setBounds(x,y,btnWidth,rowHeight); x += btnWidth; }
for(int i = 2; i < comp.length; i++) { int btnHeight = comp[i].getPreferredSize().height; if(btnHeight + y > height) { x += colWidth; y = insets.top; } comp[i].setBounds(x,y,colWidth,btnHeight); y += btnHeight; }
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/org/gjt/sp/jedit/gui/PanelWindowContainer.java File path: /jEdit-4.2/src/org/gjt/sp/jedit/gui/PanelWindowContainer.java
Method name: void layoutContainer(Container) Method name: void layoutContainer(Container)
Number of AST nodes: 7 Number of AST nodes: 7
1
for(int i = 2; i < comp.length; i++)
1
for(int i = 2; i < comp.length; i++)
2
				{
2
				{
3
					int btnWidth = comp[i].getPreferredSize().width;
3
					int btnHeight = comp[i].getPreferredSize().height;
4
					if(btnWidth + x > width)
4
					if(btnHeight + y > height)
5
					{
5
					{
6
						x = insets.left;
6
						x += colWidth;
7
						y += rowHeight;
7
						y = insets.top;
8
					}
8
					}
9
					comp[i].setBounds(x,y,btnWidth,rowHeight);
9
					comp[i].setBounds(x,y,colWidth,btnHeight);
10
					x += btnWidth;
10
					y += btnHeight;
11
				}
11
				}
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.3
Clones locationClones are in the same method
Number of node comparisons25
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    17
    for (int i = 2; i < comp.length; i++)
    30
    for (int i = 2; i < comp.length; i++)
    18
    int btnWidth = comp[i].getPreferredSize().width;
    18
    int btnWidth = comp[i].getPreferredSize().width;
    31
    int btnHeight = comp[i].getPreferredSize().height;
    Differences
    Expression1Expression2Difference
    btnWidthbtnHeightVARIABLE_NAME_MISMATCH
    widthheightVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression btnWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression btnHeight cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression comp[i].getPreferredSize().width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression comp[i].getPreferredSize().height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    31
    int btnHeight = comp[i].getPreferredSize().height;
    19
    if (btnWidth + x > width)
    19
    if (btnWidth + x > width)
    32
    if (btnHeight + y > height)
    Differences
    Expression1Expression2Difference
    btnWidthbtnHeightVARIABLE_NAME_MISMATCH
    xyVARIABLE_NAME_MISMATCH
    widthheightVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression btnWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression btnHeight 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
    32
    if (btnHeight + y > height)
    20
    x = insets.left;
    20
    x = insets.left;
    34
    y = insets.top;
    Differences
    Expression1Expression2Difference
    xyVARIABLE_NAME_MISMATCH
    lefttopVARIABLE_NAME_MISMATCH
    34
    y = insets.top;
    21
    y += rowHeight;
    21
    y += rowHeight;
    33
    x += colWidth;
    Differences
    Expression1Expression2Difference
    yxVARIABLE_NAME_MISMATCH
    rowHeightcolWidthVARIABLE_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
    33
    x += colWidth;
    22
    comp[i].setBounds(x, y, btnWidth, rowHeight);
    22
    comp[i].setBounds(x, y, btnWidth, rowHeight);
    35
    comp[i].setBounds(x, y, colWidth, btnHeight);
    Differences
    Expression1Expression2Difference
    btnWidthcolWidthVARIABLE_NAME_MISMATCH
    rowHeightbtnHeightVARIABLE_NAME_MISMATCH
    35
    comp[i].setBounds(x, y, colWidth, btnHeight);
    23
    x += btnWidth;
    23
    x += btnWidth;
    36
    y += btnHeight;
    Differences
    Expression1Expression2Difference
    xyVARIABLE_NAME_MISMATCH
    btnWidthbtnHeightVARIABLE_NAME_MISMATCH
    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
    Expression btnWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression btnHeight cannot be parameterized, because it has dependencies to/from statements that will be extracted
    36
    y += btnHeight;
    Precondition Violations (14)
    Row Violation
    1Expression btnWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression btnHeight cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression comp[i].getPreferredSize().width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression comp[i].getPreferredSize().height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression btnWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression btnHeight cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression btnWidth cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression btnHeight cannot be parameterized, because it has dependencies to/from statements that will be extracted