int width = parent.getWidth() - insets.right; int rowHeight = Math.max(dim.height,closeBox.getPreferredSize().width); int x = rowHeight * 2 + insets.left; Dimension returnValue = new Dimension(0,rowHeight + insets.top + insets.bottom); for(int i = 2; i < comp.length; i++) { int btnWidth = comp[i].getPreferredSize().width; if(btnWidth + x > width) { returnValue.height += rowHeight; x = insets.left; } x += btnWidth; } return returnValue;
int height = parent.getHeight() - insets.bottom; int colWidth = Math.max(dim.width,closeBox.getPreferredSize().height); int y = colWidth * 2 + insets.top; Dimension returnValue = new Dimension(colWidth + insets.left + insets.right,0); for(int i = 2; i < comp.length; i++) { int btnHeight = comp[i].getPreferredSize().height; if(btnHeight + y > height) { returnValue.width += colWidth; y = insets.top; } y += btnHeight; } return returnValue;
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: Dimension preferredLayoutSize(Container) Method name: Dimension preferredLayoutSize(Container)
Number of AST nodes: 11 Number of AST nodes: 11
1
int width = parent.getWidth() - insets.right;
1
int height = parent.getHeight() - insets.bottom;
2
				int rowHeight = Math.max(dim.height,closeBox.getPreferredSize().width);
2
				int colWidth = Math.max(dim.width,closeBox.getPreferredSize().height);
3
				int x = rowHeight * 2 + insets.left;
3
				int y = colWidth * 2 + insets.top;
4
				Dimension returnValue = new Dimension(0,rowHeight
4
				Dimension returnValue = new Dimension(colWidth
5
					+ insets.top + insets.bottom);
5
					+ insets.left + insets.right,0);
6
				for(int i = 2; i < comp.length; i++)
6
				for(int i = 2; i < comp.length; i++)
7
				{
7
				{
8
					int btnWidth = comp[i].getPreferredSize().width;
8
					int btnHeight = comp[i].getPreferredSize().height;
9
					if(btnWidth + x > width)
9
					if(btnHeight + y > height)
10
					{
10
					{
11
						returnValue.height += rowHeight;
11
						returnValue.width += colWidth;
12
						x = insets.left;
12
						y = insets.top;
13
					}
13
					}
14
					x += btnWidth;
14
					y += btnHeight;
15
				}
15
				}
16
				return returnValue;
16
				return returnValue;
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.4
Clones locationClones are in the same method
Number of node comparisons35
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)10.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    7
    int width = parent.getWidth() - insets.right;
    7
    int width = parent.getWidth() - insets.right;
    20
    int y = colWidth * 2 + insets.top;
    Differences
    Expression1Expression2Difference
    widthyVARIABLE_NAME_MISMATCH
    righttopVARIABLE_NAME_MISMATCH
    parent.getWidth()colWidth * 2INFIX_LEFT_OPERAND_MISMATCH
    -+OPERATOR_MISMATCH
    Preondition Violations
    Expression colWidth * 2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression colWidth * 2 + insets.top cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20
    int y = colWidth * 2 + insets.top;
    8
    int rowHeight = Math.max(dim.height, closeBox.getPreferredSize().width);
    8
    int rowHeight = Math.max(dim.height, closeBox.getPreferredSize().width);
    19
    int colWidth = Math.max(dim.width, closeBox.getPreferredSize().height);
    Differences
    Expression1Expression2Difference
    rowHeightcolWidthVARIABLE_NAME_MISMATCH
    heightwidthVARIABLE_NAME_MISMATCH
    widthheightVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression closeBox.getPreferredSize().width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression closeBox.getPreferredSize().height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19
    int colWidth = Math.max(dim.width, closeBox.getPreferredSize().height);
    9
    int x = rowHeight * 2 + insets.left;
    9
    int x = rowHeight * 2 + insets.left;
    18
    int height = parent.getHeight() - insets.bottom;
    Differences
    Expression1Expression2Difference
    xheightVARIABLE_NAME_MISMATCH
    leftbottomVARIABLE_NAME_MISMATCH
    rowHeight * 2parent.getHeight()INFIX_LEFT_OPERAND_MISMATCH
    +-OPERATOR_MISMATCH
    Preondition Violations
    Expression rowHeight * 2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression rowHeight * 2 + insets.left cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18
    int height = parent.getHeight() - insets.bottom;
    10
    Dimension returnValue = new Dimension(0, rowHeight + insets.top + insets.bottom);
    10
    Dimension returnValue = new Dimension(0, rowHeight + insets.top + insets.bottom);
    21
    Dimension returnValue = new Dimension(colWidth + insets.left + insets.right, 0);
    Differences
    Expression1Expression2Difference
    0colWidth + insets.left + insets.rightTYPE_COMPATIBLE_REPLACEMENT
    rowHeight + insets.top + insets.bottom0TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression colWidth + insets.left + insets.right cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression rowHeight + insets.top + insets.bottom cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21
    Dimension returnValue = new Dimension(colWidth + insets.left + insets.right, 0);
    11
    for (int i = 2; i < comp.length; i++)
    22
    for (int i = 2; i < comp.length; i++)
    12
    int btnWidth = comp[i].getPreferredSize().width;
    12
    int btnWidth = comp[i].getPreferredSize().width;
    23
    int btnHeight = comp[i].getPreferredSize().height;
    Differences
    Expression1Expression2Difference
    btnWidthbtnHeightVARIABLE_NAME_MISMATCH
    widthheightVARIABLE_NAME_MISMATCH
    Preondition Violations
    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
    23
    int btnHeight = comp[i].getPreferredSize().height;
    13
    if (btnWidth + x > width)
    13
    if (btnWidth + x > width)
    24
    if (btnHeight + y > height)
    Differences
    Expression1Expression2Difference
    btnWidthbtnHeightVARIABLE_NAME_MISMATCH
    xyVARIABLE_NAME_MISMATCH
    widthheightVARIABLE_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 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
    24
    if (btnHeight + y > height)
    14
    returnValue.height += rowHeight;
    14
    returnValue.height += rowHeight;
    25
    returnValue.width += colWidth;
    Differences
    Expression1Expression2Difference
    heightwidthVARIABLE_NAME_MISMATCH
    rowHeightcolWidthVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression returnValue.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression returnValue.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression returnValue.height is a field being modified, and thus it cannot be parameterized
    Expression returnValue.width is a field being modified, and thus it cannot be parameterized
    25
    returnValue.width += colWidth;
    15
    x = insets.left;
    15
    x = insets.left;
    26
    y = insets.top;
    Differences
    Expression1Expression2Difference
    xyVARIABLE_NAME_MISMATCH
    lefttopVARIABLE_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
    26
    y = insets.top;
    16
    x += btnWidth;
    16
    x += btnWidth;
    27
    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
    27
    y += btnHeight;
    17
    return returnValue;
    28
    return returnValue;
    Precondition Violations (23)
    Row Violation
    1Expression colWidth * 2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression colWidth * 2 + insets.top cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression closeBox.getPreferredSize().width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression closeBox.getPreferredSize().height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression rowHeight * 2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression rowHeight * 2 + insets.left cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression colWidth + insets.left + insets.right cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression rowHeight + insets.top + insets.bottom cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression comp[i].getPreferredSize().width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression comp[i].getPreferredSize().height 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 width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression returnValue.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression returnValue.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression returnValue.height is a field being modified, and thus it cannot be parameterized
    18Expression returnValue.width is a field being modified, and thus it cannot be parameterized
    19Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Not all possible execution flows end in a return statement