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;
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;
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: Dimension preferredLayoutSize(Container)
Number of AST nodes: 11 Number of AST nodes: 11
1
int width = dimension - insets.right;
1
int width = parent.getWidth() - insets.right;
2
				int rowHeight = Math.max(dim.height,closeBox.getPreferredSize().width);
2
				int rowHeight = Math.max(dim.height,closeBox.getPreferredSize().width);
3
				int x = rowHeight * 2 + insets.left;
3
				int x = rowHeight * 2 + insets.left;
4
				Dimension returnValue = new Dimension(0,rowHeight
4
				Dimension returnValue = new Dimension(0,rowHeight
5
					+ insets.top + insets.bottom);
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 btnWidth = comp[i].getPreferredSize().width;
8
					int btnWidth = comp[i].getPreferredSize().width;
9
					if(btnWidth + x > width)
9
					if(btnWidth + x > width)
10
					{
10
					{
11
						returnValue.height += rowHeight;
11
						returnValue.height += rowHeight;
12
						x = insets.left;
12
						x = insets.left;
13
					}
13
					}
14
					x += btnWidth;
14
					x += btnWidth;
15
				}
15
				}
16
				return returnValue.height;
16
				return returnValue;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.8
Clones locationClones are declared in the same class
Number of node comparisons36
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)3.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    7
    int width = dimension - insets.right;
    7
    int width = dimension - insets.right;
    7
    int width = parent.getWidth() - insets.right;
    Differences
    Expression1Expression2Difference
    dimensionparent.getWidth()TYPE_COMPATIBLE_REPLACEMENT
    7
    int width = parent.getWidth() - insets.right;
    8
    int rowHeight = Math.max(dim.height, closeBox.getPreferredSize().width);
    8
    int rowHeight = Math.max(dim.height, closeBox.getPreferredSize().width);
    9
    int x = rowHeight * 2 + insets.left;
    9
    int x = rowHeight * 2 + insets.left;
    10
    Dimension returnValue = new Dimension(0, rowHeight + insets.top + insets.bottom);
    10
    Dimension returnValue = new Dimension(0, rowHeight + insets.top + insets.bottom);
    11
    for (int i = 2; i < comp.length; i++)
    11
    for (int i = 2; i < comp.length; i++)
    12
    int btnWidth = comp[i].getPreferredSize().width;
    12
    int btnWidth = comp[i].getPreferredSize().width;
    13
    if (btnWidth + x > width)
    13
    if (btnWidth + x > width)
    14
    returnValue.height += rowHeight;
    14
    returnValue.height += rowHeight;
    15
    x = insets.left;
    15
    x = insets.left;
    16
    x += btnWidth;
    16
    x += btnWidth;
                                                  
    17
    return returnValue;
    17
    return returnValue.height;
                                                                
    Precondition Violations (0)
    Row Violation