File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialBackgroundTests.java | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/StandardDialScaleTests.java | |||
Method name: void testCloning()
|
Method name: void testCloning()
|
|||
Number of AST nodes: 20 | Number of AST nodes: 21 | |||
1 | DialBackground b1 = new DialBackground();↵ | 1 | StandardDialScale s1 = new StandardDialScale();↵ | |
2 | DialBackground b2 = null;↵ | 2 | StandardDialScale s2 = null;↵ | |
3 | try {↵ | 3 | try {↵ | |
4 | b2 = (DialBackground) b1.clone();↵ | 4 | s2 = (StandardDialScale) s1.clone();↵ | |
5 | }↵ | 5 | }↵ | |
6 | catch (CloneNotSupportedException e) {↵ | 6 | catch (CloneNotSupportedException e) {↵ | |
7 | e.printStackTrace();↵ | 7 | e.printStackTrace();↵ | |
8 | }↵ | 8 | }↵ | |
9 | assertTrue(b1 != b2);↵ | 9 | assertTrue(s1 != s2);↵ | |
10 | assertTrue(b1.getClass() == b2.getClass());↵ | 10 | assertTrue(s1.getClass() == s2.getClass());↵ | |
11 | assertTrue(b1.equals(b2));↵ | 11 | assertTrue(s1.equals(s2));↵ | |
12 | ↵ | 12 | ↵ | |
13 | // test a customised instance↵ | 13 | // try a customised instance↵ | |
14 | b1 = new DialBackground(↵ | 14 | s1 = new StandardDialScale();↵ | |
15 | );↵ | 15 | s1.setExtent(123.4);↵ | |
16 | b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,↵ | 16 | s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, ↵ | |
17 | Color.green));↵ | 17 | 4.0f, Color.white));↵ | |
18 | b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(↵ | 18 | s1.set↵ | |
19 | GradientPaintTransformType.CENTER_VERTICAL));↵ | 19 | MajorTickStroke(new BasicStroke(2.0f));↵ | |
20 | b2 = null;↵ | 20 | s2 = null;↵ | |
21 | try {↵ | 21 | try {↵ | |
22 | b2 = (DialBackground) b1.clone();↵ | 22 | s2 = (StandardDialScale) s1.clone();↵ | |
23 | }↵ | 23 | }↵ | |
24 | catch (CloneNotSupportedException e) {↵ | 24 | catch (CloneNotSupportedException e) {↵ | |
25 | e.printStackTrace();↵ | 25 | e.printStackTrace();↵ | |
26 | }↵ | 26 | }↵ | |
27 | assertTrue(b1 != b2);↵ | 27 | assertTrue(s1 != s2);↵ | |
28 | assertTrue(b1.getClass() == b2.getClass());↵ | 28 | assertTrue(s1.getClass() == s2.getClass());↵ | |
29 | assertTrue(b1.equals(b2));↵ | 29 | assertTrue(s1.equals(s2));↵ | |
30 | ↵ | 30 | ↵ | |
31 | // check that the listener lists are independent↵ | 31 | // check that the listener lists are independent↵ | |
32 | MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();↵ | 32 | MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();↵ | |
33 | b1.addChangeListener(l1);↵ | 33 | s1.addChangeListener(l1);↵ | |
34 | assertTrue(b1.hasListener(l1));↵ | 34 | assertTrue(s1.hasListener(l1));↵ | |
35 | assertFalse(b2.hasListener(l1)); | 35 | assertFalse(s2.hasListener(l1)); | |
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) | 0.4 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 182 |
Number of mapped statements | 19 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 58.6 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | DialBackground b1 = new DialBackground(); |
| 1 | StandardDialScale s1 = new StandardDialScale(); | ||||||||||||||||||||||||
2 | DialBackground b2 = null; |
| 2 | StandardDialScale s2 = null; | ||||||||||||||||||||||||
3 | try | 3 | try | |||||||||||||||||||||||||
4 | b2 = (DialBackground)b1.clone(); |
| 4 | s2 = (StandardDialScale)s1.clone(); | ||||||||||||||||||||||||
5 | assertTrue(b1 != b2); |
| 5 | assertTrue(s1 != s2); | ||||||||||||||||||||||||
6 | assertTrue(b1.getClass() == b2.getClass()); |
| 6 | assertTrue(s1.getClass() == s2.getClass()); | ||||||||||||||||||||||||
7 | assertTrue(b1.equals(b2)); |
| 7 | assertTrue(s1.equals(s2)); | ||||||||||||||||||||||||
8 | b1 = new DialBackground(); |
| 8 | s1 = new StandardDialScale(); | ||||||||||||||||||||||||
|
| 9 | s1.setExtent(123.4); | |||||||||||||||||||||||||
9 | b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); |
| 10 | s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); | ||||||||||||||||||||||||
10 | b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); |
| | |||||||||||||||||||||||||
|
| 11 | s1.setMajorTickStroke(new BasicStroke(2.0f)); | |||||||||||||||||||||||||
11 | b2 = null; |
| 12 | s2 = null; | ||||||||||||||||||||||||
12 | try | 13 | try | |||||||||||||||||||||||||
13 | b2 = (DialBackground)b1.clone(); |
| 14 | s2 = (StandardDialScale)s1.clone(); | ||||||||||||||||||||||||
14 | assertTrue(b1 != b2); |
| 15 | assertTrue(s1 != s2); | ||||||||||||||||||||||||
15 | assertTrue(b1.getClass() == b2.getClass()); |
| 16 | assertTrue(s1.getClass() == s2.getClass()); | ||||||||||||||||||||||||
16 | assertTrue(b1.equals(b2)); |
| 17 | assertTrue(s1.equals(s2)); | ||||||||||||||||||||||||
17 | MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); | 18 | MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); | |||||||||||||||||||||||||
18 | b1.addChangeListener(l1); |
| 19 | s1.addChangeListener(l1); | ||||||||||||||||||||||||
19 | assertTrue(b1.hasListener(l1)); |
| 20 | assertTrue(s1.hasListener(l1)); | ||||||||||||||||||||||||
20 | assertFalse(b2.hasListener(l1)); |
| 21 | assertFalse(s2.hasListener(l1)); |
Row | Violation |
---|---|
1 | Expression new DialBackground() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression new StandardDialScale() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression (DialBackground)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression (StandardDialScale)s1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression new DialBackground() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression new StandardDialScale() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement s1.setExtent(123.4); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) is a void method call, and thus it cannot be parameterized |
11 | Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) is a void method call, and thus it cannot be parameterized |
12 | Expression b1 cannot be unified with expression s1 , because common superclass org.jfree.chart.plot.dial.AbstractDialLayer does not declare member(s) public void setPaint(java.awt.Paint) , public void setMajorTickPaint(java.awt.Paint) |
13 | Unmatched statement b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Unmatched statement s1.setMajorTickStroke(new BasicStroke(2.0f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
15 | Expression (DialBackground)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression (StandardDialScale)s1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Clone fragment #1 returns variable b1 with type org.jfree.chart.plot.dial.DialBackground , while Clone fragment #2 returns variable s1 with type org.jfree.chart.plot.dial.StandardDialScale |