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 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 4.8 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 182 |
Number of mapped statements | 25 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 29.9 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Insets insets = ((JComponent)parent).getBorder().getBorderInsets((JComponent)parent); |
| 1 | Insets insets = ((JComponent)parent).getBorder().getBorderInsets((JComponent)parent); | |||||||||||||
2 | Component[] comp = parent.getComponents(); |
| 2 | Component[] comp = parent.getComponents(); | |||||||||||||
3 | if (comp.length <= 2) | 3 | if (comp.length <= 2) | ||||||||||||||
|
| 4 | return new Dimension(0, 0); | ||||||||||||||
4 | 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 = 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 = 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; | |
Row | Violation |
---|---|
1 | Unmatched return new Dimension(0,0); |
2 | Unmatched return 0; |
3 | Clone fragment #1 returns variables returnValue, returnValue , while Clone fragment #2 returns variables returnValue, returnValue |