int height = dimension - 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.width;
int width = dimension - 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.height;
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: int getWrappedDimension(JComponent, int) Method name: int getWrappedDimension(JComponent, int)
Number of AST nodes: 11 Number of AST nodes: 11
1
int height = dimension - insets.bottom;
1
int width = dimension - insets.right;
2
				int colWidth = Math.max(dim.width,closeBox.getPreferredSize().height);
2
				int rowHeight = Math.max(dim.height,closeBox.getPreferredSize().width);
3
				int y = colWidth * 2 + insets.top;
3
				int x = rowHeight * 2 + insets.left;
4
				Dimension returnValue = new Dimension(colWidth
4
				Dimension returnValue = new Dimension(0,rowHeight
5
					+ insets.left + insets.right,0);
5
					+ insets.top + insets.bottom);
6
				for(int i = 2; i < comp.length; i++)
6
				for(int i = 2; i < comp.length; i++)
7
				{
7
				{
8
					int btnHeight = comp[i].getPreferredSize().height;
8
					int btnWidth = comp[i].getPreferredSize().width;
9
					if(btnHeight + y > height)
9
					if(btnWidth + x > width)
10
					{
10
					{
11
						returnValue.width += colWidth;
11
						returnValue.height += rowHeight;
12
						y = insets.top;
12
						x = insets.left;
13
					}
13
					}
14
					y += btnHeight;
14
					x += btnWidth;
15
				}
15
				}
16
				return returnValue.width;
16
				return returnValue.height;
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)12.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    18
    int height = dimension - insets.bottom;
    18
    int height = dimension - insets.bottom;
    7
    int width = dimension - insets.right;
    Differences
    Expression1Expression2Difference
    heightwidthVARIABLE_NAME_MISMATCH
    bottomrightVARIABLE_NAME_MISMATCH
    7
    int width = dimension - insets.right;
    19
    int colWidth = Math.max(dim.width, closeBox.getPreferredSize().height);
    19
    int colWidth = Math.max(dim.width, closeBox.getPreferredSize().height);
    8
    int rowHeight = Math.max(dim.height, closeBox.getPreferredSize().width);
    Differences
    Expression1Expression2Difference
    colWidthrowHeightVARIABLE_NAME_MISMATCH
    widthheightVARIABLE_NAME_MISMATCH
    heightwidthVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression closeBox.getPreferredSize().height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression closeBox.getPreferredSize().width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    int rowHeight = Math.max(dim.height, closeBox.getPreferredSize().width);
    20
    int y = colWidth * 2 + insets.top;
    20
    int y = colWidth * 2 + insets.top;
    9
    int x = rowHeight * 2 + insets.left;
    Differences
    Expression1Expression2Difference
    yxVARIABLE_NAME_MISMATCH
    colWidthrowHeightVARIABLE_NAME_MISMATCH
    topleftVARIABLE_NAME_MISMATCH
    9
    int x = rowHeight * 2 + insets.left;
    21
    Dimension returnValue = new Dimension(colWidth + insets.left + insets.right, 0);
    21
    Dimension returnValue = new Dimension(colWidth + insets.left + insets.right, 0);
    10
    Dimension returnValue = new Dimension(0, rowHeight + insets.top + insets.bottom);
    Differences
    Expression1Expression2Difference
    colWidth + insets.left + insets.right0TYPE_COMPATIBLE_REPLACEMENT
    0rowHeight + insets.top + insets.bottomTYPE_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
    10
    Dimension returnValue = new Dimension(0, rowHeight + insets.top + insets.bottom);
    22
    for (int i = 2; i < comp.length; i++)
    11
    for (int i = 2; i < comp.length; i++)
    23
    int btnHeight = comp[i].getPreferredSize().height;
    23
    int btnHeight = comp[i].getPreferredSize().height;
    12
    int btnWidth = comp[i].getPreferredSize().width;
    Differences
    Expression1Expression2Difference
    btnHeightbtnWidthVARIABLE_NAME_MISMATCH
    heightwidthVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression comp[i].getPreferredSize().height 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
    12
    int btnWidth = comp[i].getPreferredSize().width;
    24
    if (btnHeight + y > height)
    24
    if (btnHeight + y > height)
    13
    if (btnWidth + x > width)
    Differences
    Expression1Expression2Difference
    btnHeightbtnWidthVARIABLE_NAME_MISMATCH
    yxVARIABLE_NAME_MISMATCH
    heightwidthVARIABLE_NAME_MISMATCH
    13
    if (btnWidth + x > width)
    25
    returnValue.width += colWidth;
    25
    returnValue.width += colWidth;
    14
    returnValue.height += rowHeight;
    Differences
    Expression1Expression2Difference
    widthheightVARIABLE_NAME_MISMATCH
    colWidthrowHeightVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression returnValue.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression returnValue.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression returnValue.width is a field being modified, and thus it cannot be parameterized
    Expression returnValue.height is a field being modified, and thus it cannot be parameterized
    14
    returnValue.height += rowHeight;
    26
    y = insets.top;
    26
    y = insets.top;
    15
    x = insets.left;
    Differences
    Expression1Expression2Difference
    yxVARIABLE_NAME_MISMATCH
    topleftVARIABLE_NAME_MISMATCH
    15
    x = insets.left;
    27
    y += btnHeight;
    27
    y += btnHeight;
    16
    x += btnWidth;
    Differences
    Expression1Expression2Difference
    yxVARIABLE_NAME_MISMATCH
    btnHeightbtnWidthVARIABLE_NAME_MISMATCH
    16
    x += btnWidth;
    28
    return returnValue.width;
    28
    return returnValue.width;
    17
    return returnValue.height;
    Differences
    Expression1Expression2Difference
    widthheightVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression returnValue.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression returnValue.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17
    return returnValue.height;
    Precondition Violations (13)
    Row Violation
    1Expression closeBox.getPreferredSize().height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression closeBox.getPreferredSize().width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression colWidth + insets.left + insets.right cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression rowHeight + insets.top + insets.bottom cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression comp[i].getPreferredSize().height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression comp[i].getPreferredSize().width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression returnValue.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression returnValue.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression returnValue.width is a field being modified, and thus it cannot be parameterized
    10Expression returnValue.height is a field being modified, and thus it cannot be parameterized
    11Expression returnValue.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression returnValue.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Not all possible execution flows end in a return statement