Insets insets = ((JComponent)parent).getBorder() .getBorderInsets((JComponent)parent); Component[] comp = parent.getComponents(); if(comp.length <= 2) return 0; Dimension dim = comp[2].getPreferredSize(); 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; }
Insets insets = ((JComponent)parent).getBorder() .getBorderInsets((JComponent)parent); Component[] comp = parent.getComponents(); if(comp.length <= 2) { // nothing 'cept close box return new Dimension(0,0); } Dimension dim = comp[2].getPreferredSize(); 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: 28 Number of AST nodes: 28
1
Insets insets = ((JComponent)parent).getBorder()
1
Insets insets = ((JComponent)parent).getBorder()
2
				.getBorderInsets((JComponent)parent);
2
				.getBorderInsets((JComponent)parent);
3
			Component[] comp = parent.getComponents();
3
			Component[] comp = parent.getComponents();
4
			if(comp.length <= 2)
4
			if(comp.length <= 2)
5
				return 0;
5
			{
6
				// nothing 'cept close box
7
				return new Dimension(0,0);
8
			}
6
			Dimension dim = comp[2].getPreferredSize();
9
			Dimension dim = comp[2].getPreferredSize();
7
			if(position.equals(DockableWindowManager.TOP)
10
			if(position.equals(DockableWindowManager.TOP)
8
				|| position.equals(DockableWindowManager.BOTTOM))
11
				|| position.equals(DockableWindowManager.BOTTOM))
9
			{
12
			{
10
				int width = dimension - insets.right;
13
				int width = parent.getWidth() - insets.right;
11
				int rowHeight = Math.max(dim.height,closeBox.getPreferredSize().width);
14
				int rowHeight = Math.max(dim.height,closeBox.getPreferredSize().width);
12
				int x = rowHeight * 2 + insets.left;
15
				int x = rowHeight * 2 + insets.left;
13
				Dimension returnValue = new Dimension(0,rowHeight
16
				Dimension returnValue = new Dimension(0,rowHeight
14
					+ insets.top + insets.bottom);
17
					+ insets.top + insets.bottom);
15
				for(int i = 2; i < comp.length; i++)
18
				for(int i = 2; i < comp.length; i++)
16
				{
19
				{
17
					int btnWidth = comp[i].getPreferredSize().width;
20
					int btnWidth = comp[i].getPreferredSize().width;
18
					if(btnWidth + x > width)
21
					if(btnWidth + x > width)
19
					{
22
					{
20
						returnValue.height += rowHeight;
23
						returnValue.height += rowHeight;
21
						x = insets.left;
24
						x = insets.left;
22
					}
25
					}
23
					x += btnWidth;
26
					x += btnWidth;
24
				}
27
				}
25
				return returnValue.height;
28
				return returnValue;
26
			}
29
			}
27
			else
30
			else
28
			{
31
			{
29
				int height = dimension - insets.bottom;
32
				int height = parent.getHeight() - insets.bottom;
30
				int colWidth = Math.max(dim.width,closeBox.getPreferredSize().height);
33
				int colWidth = Math.max(dim.width,closeBox.getPreferredSize().height);
31
				int y = colWidth * 2 + insets.top;
34
				int y = colWidth * 2 + insets.top;
32
				Dimension returnValue = new Dimension(colWidth
35
				Dimension returnValue = new Dimension(colWidth
33
					+ insets.left + insets.right,0);
36
					+ insets.left + insets.right,0);
34
				for(int i = 2; i < comp.length; i++)
37
				for(int i = 2; i < comp.length; i++)
35
				{
38
				{
36
					int btnHeight = comp[i].getPreferredSize().height;
39
					int btnHeight = comp[i].getPreferredSize().height;
37
					if(btnHeight + y > height)
40
					if(btnHeight + y > height)
38
					{
41
					{
39
						returnValue.width += colWidth;
42
						returnValue.width += colWidth;
40
						y = insets.top;
43
						y = insets.top;
41
					}
44
					}
42
					y += btnHeight;
45
					y += btnHeight;
43
				}
46
				}
44
				return returnValue.width;
47
				return returnValue;
45
			}
48
			}
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)4.8
Clones locationClones are declared in the same class
Number of node comparisons182
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements25
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)29.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Insets insets = ((JComponent)parent).getBorder().getBorderInsets((JComponent)parent);
    1
    Insets insets = ((JComponent)parent).getBorder().getBorderInsets((JComponent)parent);
    1
    Insets insets = ((JComponent)parent).getBorder().getBorderInsets((JComponent)parent);
    Differences
    Expression1Expression2Difference
    javax.swing.JComponentjava.awt.ContainerSUBCLASS_TYPE_MISMATCH
    javax.swing.JComponentjava.awt.ContainerSUBCLASS_TYPE_MISMATCH
    1
    Insets insets = ((JComponent)parent).getBorder().getBorderInsets((JComponent)parent);
    2
    Component[] comp = parent.getComponents();
    2
    Component[] comp = parent.getComponents();
    2
    Component[] comp = parent.getComponents();
    Differences
    Expression1Expression2Difference
    javax.swing.JComponentjava.awt.ContainerSUBCLASS_TYPE_MISMATCH
    2
    Component[] comp = parent.getComponents();
    3
    if (comp.length <= 2)
    3
    if (comp.length <= 2)
                                                              
    4
    return new Dimension(0, 0);
    Preondition Violations
    Unmatched return new Dimension(0,0);
    4
    return new Dimension(0, 0);
    4
    return 0;
    4
    return 0;
    Preondition Violations
    Unmatched return 0;
                            
    5
    Dimension dim = comp[2].getPreferredSize();
    5
    Dimension dim = comp[2].getPreferredSize();
    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 (3)
    Row Violation
    1Unmatched return new Dimension(0,0);
    2Unmatched return 0;
    3Clone fragment #1 returns variables returnValue, returnValue , while Clone fragment #2 returns variables returnValue, returnValue