373-1-7

Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation( 10.0, 20.0, 100.0, 200.0, stroke, Color.blue ); XYLineAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); a2 = (XYLineAnnotation) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(a1, a2);
ThermometerPlot p1 = new ThermometerPlot(); p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); ThermometerPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (ThermometerPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(p1.equals(p2));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/annotations/junit/XYLineAnnotationTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/ThermometerPlotTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization2()`
Number of AST nodes: 12 |  | Number of AST nodes: 12

1

    Stroke stroke = new BasicStroke(2.0f);↵

2

            XYLineAnnotation a1 = new XYLineAnnotation(↵

3

                10.0, 20.0, 100.0, 200.0, stroke↵

1

    ThermometerPlot p1 = new ThermometerPlot();↵

2

            p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, ↵

4

    , Color.blue↵

3

                    4.0f, Color.blue↵

5

            );↵

4

    ));↵

6

            XYLineAnnotation a2 = null;↵

5

            ThermometerPlot p2 = null;↵

7

            try {↵

6

            try {↵

8

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

7

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

9

                ObjectOutput out = new ObjectOutputStream(buffer);↵

8

                ObjectOutput out = new ObjectOutputStream(buffer);↵

10

                out.writeObject(a1);↵

9

                out.writeObject(p1);↵

11

                out.close();↵

10

                out.close();↵

12

                ObjectInput in = new ObjectInputStream(↵

11

                ObjectInput in = new ObjectInputStream(↵

13

                    new ByteArrayInputStream(buffer.toByteArray())↵

12

                        new ByteArrayInputStream(buffer.toByteArray())↵

14

                );↵

13

    );↵

15

                a2 = (XYLineAnnotation) in.readObject();↵

14

                p2 = (ThermometerPlot) in.readObject();↵

16

                in.close();↵

15

                in.close();↵

17

            }↵

16

            }↵

18

            catch (Exception e) {↵

17

            catch (Exception e) {↵

19

                System.out.println(e.toString());↵

18

                e.printStackTrace();↵

20

            }↵

19

            }↵

21

            assertEquals(a1, a2);

20

            assertTrue(p1.equals(p2));

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 0
Number of refactorable cases | 0
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 1