255-1-2

if (this.chart != null) { this.chart.removeChangeListener(this); this.chart.removeProgressListener(this); } // add the new chart this.chart = chart; if (chart != null) { this.chart.addChangeListener(this); this.chart.addProgressListener(this); Plot plot = chart.getPlot(); this.domainZoomable = false; this.rangeZoomable = false; if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.domainZoomable = z.isDomainZoomable(); this.rangeZoomable = z.isRangeZoomable(); this.orientation = z.getOrientation(); } } else { this.domainZoomable = false; this.rangeZoomable = false; } if (this.useBuffer) { this.refreshBuffer = true; } repaint();
if (this.chart != null) { this.chart.removeChangeListener(this); this.chart.removeProgressListener(this); } // add the new chart this.chart = chart; if (chart != null) { this.chart.addChangeListener(this); this.chart.addProgressListener(this); Plot plot = chart.getPlot(); this.domainZoomable = false; this.rangeZoomable = false; if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.domainZoomable = z.isDomainZoomable(); this.rangeZoomable = z.isRangeZoomable(); this.orientation = z.getOrientation(); } } else { this.domainZoomable = false; this.rangeZoomable = false; } if (this.useBuffer) { this.refreshBuffer = true; }

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/ChartPanel.java |  | File path: /jfreechart-1.0.10/swt/org/jfree/experimental/chart/swt/ChartComposite.java
Method name: `void setChart(JFreeChart)` |  | Method name: `void setChart(JFreeChart)`
Number of AST nodes: 20 |  | Number of AST nodes: 19

1

    if (this.chart != null) {
    ↵

1

    if (this.chart != null) {↵

2

                this.chart.removeChangeListener(this);
    ↵

2

                this.chart.removeChangeListener(this);↵

3

                this.chart.removeProgressListener(this);
    ↵

3

                this.chart.removeProgressListener(this);↵

4

            }↵

4

            }↵

5

    ↵

6

            // add the new chart
    ↵

5

            // add the new chart↵

7

            this.chart = chart;
    ↵

6

            this.chart = chart;↵

8

            if (chart != null) {
    ↵

7

            if (chart != null) {↵

9

                this.chart.addChangeListener(this);
    ↵

8

                this.chart.addChangeListener(this);↵

10

                this.chart.addProgressListener(this);
    ↵

9

                this.chart.addProgressListener(this);↵

11

                Plot plot = chart.getPlot();
    ↵

10

                Plot plot = chart.getPlot();↵

12

                this.domainZoomable = false;
    ↵

11

                this.domainZoomable = false;↵

13

                this.rangeZoomable = false;
    ↵

12

                this.rangeZoomable = false;↵

14

                if (plot instanceof Zoomable) {
    ↵

13

                if (plot instanceof Zoomable) {↵

15

                    Zoomable z = (Zoomable) plot;
    ↵

14

                    Zoomable z = (Zoomable) plot;↵

16

                    this.domainZoomable = z.isDomainZoomable();
    ↵

15

                    this.domainZoomable = z.isDomainZoomable();↵

17

                    this.rangeZoomable = z.isRangeZoomable();
    ↵

16

                    this.rangeZoomable = z.isRangeZoomable();↵

18

                    this.orientation = z.getOrientation();
    ↵

17

                    this.orientation = z.getOrientation();↵

19

                }
    ↵

18

                }↵

20

            }
    ↵

19

            }↵

21

            else {
    ↵

20

            else {↵

22

                this.domainZoomable = false;
    ↵

21

                this.domainZoomable = false;↵

23

                this.rangeZoomable = false;
    ↵

22

                this.rangeZoomable = false;↵

24

            }
    ↵

23

            }↵

25

            if (this.useBuffer) {
    ↵

24

            if (this.useBuffer) {↵

26

                this.refreshBuffer = true;
    ↵

25

                this.refreshBuffer = true;↵

27

            }↵

26

            }

28

            repaint();

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 1
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.3
Clones location | Clones are in different classes
Number of node comparisons | 110

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 19
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 7.8
   Clone type | Type 3

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       if (this.chart != null)

   1

       if (this.chart != null)

   2

       this.chart.removeChangeListener(this);

   2

       this.chart.removeChangeListener(this);

   3

       this.chart.removeProgressListener(this);

   3

       this.chart.removeProgressListener(this);

   4

       this.chart = chart;

   4

       this.chart = chart;

   5

       if (chart != null)

   5

       if (chart != null)

   6

       this.chart.addChangeListener(this);

   6

       this.chart.addChangeListener(this);

   7

       this.chart.addProgressListener(this);

   7

       this.chart.addProgressListener(this);

   8

       Plot plot = chart.getPlot();

   8

       Plot plot = chart.getPlot();

   9

       this.domainZoomable = false;

   9

       this.domainZoomable = false;

   10

       this.rangeZoomable = false;

   10

       this.rangeZoomable = false;

   11

       if (plot instanceof Zoomable)

   11

       if (plot instanceof Zoomable)

   12

       Zoomable z = (Zoomable)plot;

   12

       Zoomable z = (Zoomable)plot;

   13

       this.domainZoomable = z.isDomainZoomable();

   13

       this.domainZoomable = z.isDomainZoomable();

   14

       this.rangeZoomable = z.isRangeZoomable();

   14

       this.rangeZoomable = z.isRangeZoomable();

   15

       this.orientation = z.getOrientation();

   15

       this.orientation = z.getOrientation();

       else

       else

   16

       this.domainZoomable = false;

   16

       this.domainZoomable = false;

   17

       this.rangeZoomable = false;

   17

       this.rangeZoomable = false;

   18

       if (this.useBuffer)

   18

       if (this.useBuffer)

   19

       this.refreshBuffer = true;

   19

       this.refreshBuffer = true;

   20

       repaint();

   Precondition Violations (0)
   Row | Violation
   --- | ---