216-1-2

if (this.showTitle) { TextTitle title = chart.getTitle(); if (title == null) { title = new TextTitle(); chart.setTitle(title); } title.setText(getTitleText()); title.setFont(getTitleFont()); title.setPaint(getTitlePaint()); } else { chart.setTitle((TextTitle) null); }
if (this.showTitle) { TextTitle title = chart.getTitle(); if (title == null) { title = new TextTitle(); chart.setTitle(title); } title.setText(getTitleText()); title.setFont(SWTUtils.toAwtFont(getDisplay(), getTitleFont(), true)); title.setPaint(SWTUtils.toAwtColor(getTitleColor())); } else { chart.setTitle((TextTitle) null); }

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/editor/DefaultTitleEditor.java |  | File path: /jfreechart-1.0.10/swt/org/jfree/experimental/chart/swt/editor/SWTTitleEditor.java
Method name: `void setTitleProperties(JFreeChart)` |  | Method name: `void setTitleProperties(JFreeChart)`
Number of AST nodes: 9 |  | Number of AST nodes: 9

1

    if (this.showTitle) {
    ↵

1

    if (this.showTitle) {↵

2

                TextTitle title = chart.getTitle();
    ↵

2

                TextTitle title = chart.getTitle();↵

3

                if (title == null) {
    ↵

3

                if (title == null) {↵

4

                    title = new TextTitle();
    ↵

4

                    title = new TextTitle();↵

5

                    chart.setTitle(title);
    ↵

5

                    chart.setTitle(title);↵

6

                }
    ↵

6

                }↵

7

                title.setText(getTitleText());
    ↵

7

                title.setText(getTitleText());↵

8

                title.setFont(getTitleFont(↵

8

                title.setFont(SWTUtils.toAwtFont(getDisplay(), getTitleFont(), ↵

9

    ));
    ↵

9

                        true));↵

10

                title.setPaint(getTitlePaint());
    ↵

10

                title.setPaint(SWTUtils.toAwtColor(getTitleColor()));↵

11

            }
    ↵

11

            }↵

12

            else {
    ↵

12

            else {↵

13

                chart.setTitle((TextTitle) null);
    ↵

13

                chart.setTitle((TextTitle) null);↵

14

            }

14

            }

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.2
Clones location | Clones are in different classes
Number of node comparisons | 45

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 8
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 1
   Time elapsed for statement mapping (ms) | 2.8
   Clone type | Type 2

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

   1

       if (this.showTitle)

   1

       if (this.showTitle)

   2

       TextTitle title = chart.getTitle();

   2

       TextTitle title = chart.getTitle();

   3

       if (title == null)

   3

       if (title == null)

   4

       title = new TextTitle();

   4

       title = new TextTitle();

   5

       chart.setTitle(title);

   5

       chart.setTitle(title);

   6

       title.setText(getTitleText());

   6

       title.setText(getTitleText());

   7

       title.setFont(getTitleFont());

   7 | title.setFont(getTitleFont());
   7 | title.setFont(SWTUtils.toAwtFont(getDisplay(), getTitleFont(), true));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getTitleFont | toAwtFont | METHOD_INVOCATION_NAME_MISMATCH
   getTitleFont() | SWTUtils.toAwtFont(getDisplay(),getTitleFont(),true) | ARGUMENT_NUMBER_MISMATCH
   | SWTUtils | MISSING_METHOD_INVOCATION_EXPRESSION

   7

       title.setFont(SWTUtils.toAwtFont(getDisplay(), getTitleFont(), true));

   8

       title.setPaint(SWTUtils.toAwtColor(getTitleColor()));

   8

       title.setPaint(getTitlePaint());

       else

       else

   9

       chart.setTitle((TextTitle)null);

   9

       chart.setTitle((TextTitle)null);

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