if(position.equals(DockableWindowManager.TOP) || position.equals(DockableWindowManager.BOTTOM)) { 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; } else { 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; }
if(position.equals(DockableWindowManager.TOP) || position.equals(DockableWindowManager.BOTTOM)) { 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; } else { 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: int getWrappedDimension(JComponent, int) Method name: Dimension preferredLayoutSize(Container)
Number of AST nodes: 23 Number of AST nodes: 23
1
if(position.equals(DockableWindowManager.TOP)
1
if(position.equals(DockableWindowManager.TOP)
2
				|| position.equals(DockableWindowManager.BOTTOM))
2
				|| position.equals(DockableWindowManager.BOTTOM))
3
			{
3
			{
4
				int width = dimension - insets.right;
4
				int width = parent.getWidth() - insets.right;
5
				int rowHeight = Math.max(dim.height,closeBox.getPreferredSize().width);
5
				int rowHeight = Math.max(dim.height,closeBox.getPreferredSize().width);
6
				int x = rowHeight * 2 + insets.left;
6
				int x = rowHeight * 2 + insets.left;
7
				Dimension returnValue = new Dimension(0,rowHeight
7
				Dimension returnValue = new Dimension(0,rowHeight
8
					+ insets.top + insets.bottom);
8
					+ insets.top + insets.bottom);
9
				for(int i = 2; i < comp.length; i++)
9
				for(int i = 2; i < comp.length; i++)
10
				{
10
				{
11
					int btnWidth = comp[i].getPreferredSize().width;
11
					int btnWidth = comp[i].getPreferredSize().width;
12
					if(btnWidth + x > width)
12
					if(btnWidth + x > width)
13
					{
13
					{
14
						returnValue.height += rowHeight;
14
						returnValue.height += rowHeight;
15
						x = insets.left;
15
						x = insets.left;
16
					}
16
					}
17
					x += btnWidth;
17
					x += btnWidth;
18
				}
18
				}
19
				return returnValue.height;
19
				return returnValue;
20
			}
20
			}
21
			else
21
			else
22
			{
22
			{
23
				int height = dimension - insets.bottom;
23
				int height = parent.getHeight() - insets.bottom;
24
				int colWidth = Math.max(dim.width,closeBox.getPreferredSize().height);
24
				int colWidth = Math.max(dim.width,closeBox.getPreferredSize().height);
25
				int y = colWidth * 2 + insets.top;
25
				int y = colWidth * 2 + insets.top;
26
				Dimension returnValue = new Dimension(colWidth
26
				Dimension returnValue = new Dimension(colWidth
27
					+ insets.left + insets.right,0);
27
					+ insets.left + insets.right,0);
28
				for(int i = 2; i < comp.length; i++)
28
				for(int i = 2; i < comp.length; i++)
29
				{
29
				{
30
					int btnHeight = comp[i].getPreferredSize().height;
30
					int btnHeight = comp[i].getPreferredSize().height;
31
					if(btnHeight + y > height)
31
					if(btnHeight + y > height)
32
					{
32
					{
33
						returnValue.width += colWidth;
33
						returnValue.width += colWidth;
34
						y = insets.top;
34
						y = insets.top;
35
					}
35
					}
36
					y += btnHeight;
36
					y += btnHeight;
37
				}
37
				}
38
				return returnValue.width;
38
				return returnValue;
39
			}
39
			}
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)1.6
Clones locationClones are declared in the same class
Number of node comparisons168
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements21
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)13.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    if (position.equals(DockableWindowManager.TOP) || position.equals(DockableWindowManager.BOTTOM))
    6
    if (position.equals(DockableWindowManager.TOP) || position.equals(DockableWindowManager.BOTTOM))
    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;
                                                                
    else
    else
    18
    int height = dimension - insets.bottom;
    18
    int height = dimension - insets.bottom;
    18
    int height = parent.getHeight() - insets.bottom;
    Differences
    Expression1Expression2Difference
    dimensionparent.getHeight()TYPE_COMPATIBLE_REPLACEMENT
    18
    int height = parent.getHeight() - insets.bottom;
    19
    int colWidth = Math.max(dim.width, closeBox.getPreferredSize().height);
    19
    int colWidth = Math.max(dim.width, closeBox.getPreferredSize().height);
    20
    int y = colWidth * 2 + insets.top;
    20
    int y = colWidth * 2 + insets.top;
    21
    Dimension returnValue = new Dimension(colWidth + insets.left + insets.right, 0);
    21
    Dimension returnValue = new Dimension(colWidth + insets.left + insets.right, 0);
    22
    for (int i = 2; i < comp.length; i++)
    22
    for (int i = 2; i < comp.length; i++)
    23
    int btnHeight = comp[i].getPreferredSize().height;
    23
    int btnHeight = comp[i].getPreferredSize().height;
    24
    if (btnHeight + y > height)
    24
    if (btnHeight + y > height)
    25
    returnValue.width += colWidth;
    25
    returnValue.width += colWidth;
    26
    y = insets.top;
    26
    y = insets.top;
    27
    y += btnHeight;
    27
    y += btnHeight;
                                                  
    28
    return returnValue;
    28
    return returnValue.width;
                                                              
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables returnValue, returnValue , while Clone fragment #2 returns variables returnValue, returnValue