synchronized (parent.getTreeLock()){ update(parent); int ncomponents = parent.getComponentCount(); int h = 0; int w = 0; for (int r = 0, i = 0; r < nrows; r++) { int row_height = 0; for (int c = 0; c < ncols; c++, i++) { if (i < ncomponents) { switch (which) { case 0: row_height = Math.max(row_height, parent.getComponent(i).getMinimumSize().height); break; case 1: row_height = Math.max(row_height, parent.getComponent(i).getMaximumSize().height); break; default: row_height = Math.max(row_height, parent.getComponent(i).getPreferredSize().height); break; } } else { break; } } h += row_height; } for (int c = 0; c < ncols; c++) { int col_width = 0; for (int r = 0; r < nrows; r++) { int i = r * ncols + c; if (i < ncomponents) { switch (which) { case 0: col_width = Math.max(col_width, parent.getComponent(i).getMinimumSize().width); break; case 1: col_width = Math.max(col_width, parent.getComponent(i).getMaximumSize().width); break; default: col_width = Math.max(col_width, parent.getComponent(i).getPreferredSize().width); break; } } else { break; } } w += col_width; } Insets insets = parent.getInsets(); return new Dimension(w + insets.left + insets.right + ((ncols - 1) * hgap), h + insets.top + insets.bottom + ((nrows - 1) * vgap)); }
synchronized (parent.getTreeLock()){ update(parent); int ncomponents = parent.getComponentCount(); int h = 0; int w = 0; for (int r = 0, i = 0; r < nrows; r++) { int row_height = 0; for (int c = 0; c < ncols; c++, i++) { if (i < ncomponents) { switch (which) { case 0: row_height = Math.max(row_height, parent.getComponent(i).getMinimumSize().height); break; case 1: row_height = Math.max(row_height, parent.getComponent(i).getMaximumSize().height); break; default: row_height = Math.max(row_height, parent.getComponent(i).getPreferredSize().height); break; } } else { break; } } h += row_height; } for (int c = 0; c < ncols; c++) { int col_width = 0; for (int r = 0; r < nrows; r++) { int i = r * ncols + c; if (i < ncomponents) { switch (which) { case 0: col_width = Math.max(col_width, parent.getComponent(i).getMinimumSize().width); break; case 1: col_width = Math.max(col_width, parent.getComponent(i).getMaximumSize().width); break; default: col_width = Math.max(col_width, parent.getComponent(i).getPreferredSize().width); break; } } else { break; } } w += col_width; } Insets insets = parent.getInsets(); return new Dimension(w + insets.left + insets.right + ((ncols - 1) * hgap), h + insets.top + insets.bottom + ((nrows - 1) * vgap)); }
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/org/gjt/sp/jedit/gui/VariableGridLayout.java File path: /jEdit-4.2/src/installer/VariableGridLayout.java
Method name: Dimension getLayoutSize(Container, int) Method name: Dimension getLayoutSize(Container, int)
Number of AST nodes: 40 Number of AST nodes: 40
1
synchronized (parent.getTreeLock()){
1
synchronized (parent.getTreeLock()){
2
			update(parent);
2
			update(parent);
3
			int ncomponents = parent.getComponentCount();
3
			int ncomponents = parent.getComponentCount();
4
			int h = 0;
4
			int h = 0;
5
			int w = 0;
5
			int w = 0;
6
			for (int r = 0, i = 0; r < nrows; r++) {
6
			for (int r = 0, i = 0; r < nrows; r++) {
7
				int row_height = 0;
7
				int row_height = 0;
8
				for (int c = 0; c < ncols; c++, i++) {
8
				for (int c = 0; c < ncols; c++, i++) {
9
					if (i < ncomponents) {
9
					if (i < ncomponents) {
10
						switch (which) {
10
						switch (which) {
11
							case 0:
11
							case 0:
12
								row_height = Math.max(row_height, parent.getComponent(i).getMinimumSize().height);
12
								row_height = Math.max(row_height, parent.getComponent(i).getMinimumSize().height);
13
								break;
13
								break;
14
							case 1:
14
							case 1:
15
								row_height = Math.max(row_height, parent.getComponent(i).getMaximumSize().height);
15
								row_height = Math.max(row_height, parent.getComponent(i).getMaximumSize().height);
16
								break;
16
								break;
17
							default:
17
							default:
18
								row_height = Math.max(row_height, parent.getComponent(i).getPreferredSize().height);
18
								row_height = Math.max(row_height, parent.getComponent(i).getPreferredSize().height);
19
								break;
19
								break;
20
						}
20
						}
21
					} else {
21
					} else {
22
						break;
22
						break;
23
					}
23
					}
24
				}
24
				}
25
				h += row_height;
25
				h += row_height;
26
			}
26
			}
27
			for (int c = 0; c < ncols; c++) {
27
			for (int c = 0; c < ncols; c++) {
28
				int col_width = 0;
28
				int col_width = 0;
29
				for (int r = 0; r < nrows; r++) {
29
				for (int r = 0; r < nrows; r++) {
30
					int i = r * ncols + c;
30
					int i = r * ncols + c;
31
					if (i < ncomponents) {
31
					if (i < ncomponents) {
32
						switch (which) {
32
						switch (which) {
33
							case 0:
33
							case 0:
34
								col_width = Math.max(col_width, parent.getComponent(i).getMinimumSize().width);
34
								col_width = Math.max(col_width, parent.getComponent(i).getMinimumSize().width);
35
								break;
35
								break;
36
							case 1:
36
							case 1:
37
								col_width = Math.max(col_width, parent.getComponent(i).getMaximumSize().width);
37
								col_width = Math.max(col_width, parent.getComponent(i).getMaximumSize().width);
38
								break;
38
								break;
39
							default:
39
							default:
40
								col_width = Math.max(col_width, parent.getComponent(i).getPreferredSize().width);
40
								col_width = Math.max(col_width, parent.getComponent(i).getPreferredSize().width);
41
								break;
41
								break;
42
						}
42
						}
43
					} else {
43
					} else {
44
						break;
44
						break;
45
					}
45
					}
46
				}
46
				}
47
				w += col_width;
47
				w += col_width;
48
			}
48
			}
49
			Insets insets = parent.getInsets();
49
			Insets insets = parent.getInsets();
50
			return new Dimension(w + insets.left + insets.right + ((ncols - 1) * hgap),
50
			return new Dimension(w + insets.left + insets.right + ((ncols - 1) * hgap),
51
								 h + insets.top + insets.bottom + ((nrows - 1) * vgap));
51
								 h + insets.top + insets.bottom + ((nrows - 1) * vgap));
52
		}
52
		}
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)19.3
Clones locationClones are in different classes
Number of node comparisons256
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements40
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)247.6
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    1
    synchronized (parent.getTreeLock())
    1
    synchronized (parent.getTreeLock())
    2
    update(parent);
    2
    update(parent);
    3
    int ncomponents = parent.getComponentCount();
    3
    int ncomponents = parent.getComponentCount();
    4
    int h = 0;
    4
    int h = 0;
    5
    int w = 0;
    5
    int w = 0;
    6
    for (int r = 0, i = 0; r < nrows; r++)
    6
    for (int r = 0, i = 0; r < nrows; r++)
    7
    int row_height = 0;
    7
    int row_height = 0;
    8
    for (int c = 0; c < ncols; c++, i++)
    8
    for (int c = 0; c < ncols; c++, i++)
    9
    if (i < ncomponents)
    9
    if (i < ncomponents)
    10
    switch (which)
    10
    switch (which)
    11
    case 0:
    11
    case 0:
    12
    row_height = Math.max(row_height, parent.getComponent(i).getMinimumSize().height);
    12
    row_height = Math.max(row_height, parent.getComponent(i).getMinimumSize().height);
    13
    break;
    13
    break;
    14
    case 1:
    14
    case 1:
    15
    row_height = Math.max(row_height, parent.getComponent(i).getMaximumSize().height);
    15
    row_height = Math.max(row_height, parent.getComponent(i).getMaximumSize().height);
    16
    break;
    16
    break;
    17
    default:
    17
    default:
    18
    row_height = Math.max(row_height, parent.getComponent(i).getPreferredSize().height);
    18
    row_height = Math.max(row_height, parent.getComponent(i).getPreferredSize().height);
    19
    break;
    19
    break;
    else
    else
    20
    break;
    20
    break;
    21
    h += row_height;
    21
    h += row_height;
    22
    for (int c = 0; c < ncols; c++)
    22
    for (int c = 0; c < ncols; c++)
    23
    int col_width = 0;
    23
    int col_width = 0;
    24
    for (int r = 0; r < nrows; r++)
    24
    for (int r = 0; r < nrows; r++)
    25
    int i = r * ncols + c;
    25
    int i = r * ncols + c;
    26
    if (i < ncomponents)
    26
    if (i < ncomponents)
    27
    switch (which)
    27
    switch (which)
    28
    case 0:
    28
    case 0:
    29
    col_width = Math.max(col_width, parent.getComponent(i).getMinimumSize().width);
    29
    col_width = Math.max(col_width, parent.getComponent(i).getMinimumSize().width);
    30
    break;
    30
    break;
    31
    case 1:
    31
    case 1:
    32
    col_width = Math.max(col_width, parent.getComponent(i).getMaximumSize().width);
    32
    col_width = Math.max(col_width, parent.getComponent(i).getMaximumSize().width);
    33
    break;
    33
    break;
    34
    default:
    34
    default:
    35
    col_width = Math.max(col_width, parent.getComponent(i).getPreferredSize().width);
    35
    col_width = Math.max(col_width, parent.getComponent(i).getPreferredSize().width);
    36
    break;
    36
    break;
    else
    else
    37
    break;
    37
    break;
    38
    w += col_width;
    38
    w += col_width;
    39
    Insets insets = parent.getInsets();
    39
    Insets insets = parent.getInsets();
    40
    return new Dimension(w + insets.left + insets.right + ((ncols - 1) * hgap), h + insets.top + insets.bottom + ((nrows - 1) * vgap));
    40
    return new Dimension(w + insets.left + insets.right + ((ncols - 1) * hgap), h + insets.top + insets.bottom + ((nrows - 1) * vgap));
    Precondition Violations (0)
    Row Violation