297-2-3

FontDialog dlg = new FontDialog(getShell()); dlg.setText(localizationResources.getString( "Font_Selection")); dlg.setFontList(new FontData[] { SWTAxisEditor.this.tickLabelFont}); if (dlg.open() != null) { // Dispose of any fonts we have created if (SWTAxisEditor.this.font != null) { SWTAxisEditor.this.font.dispose(); } // Create the new font and set it into the title // label SWTAxisEditor.this.font = new Font( getShell().getDisplay(), dlg.getFontList()); //tickLabelFontField.setFont(font); SWTAxisEditor.this.tickLabelFontField.setText( SWTAxisEditor.this.font.getFontData()[0] .toString()); SWTAxisEditor.this.tickLabelFont = SWTAxisEditor.this.font.getFontData()[0]; }
FontDialog dlg = new FontDialog(getShell()); dlg.setText(localizationResources.getString( "Font_Selection")); dlg.setFontList(new FontData[] { SWTAxisEditor.this.labelFont }); if (dlg.open() != null) { // Dispose of any fonts we have created if (SWTAxisEditor.this.font != null) { SWTAxisEditor.this.font.dispose(); } // Create the new font and set it into the title // label SWTAxisEditor.this.font = new Font( getShell().getDisplay(), dlg.getFontList()); //label.setFont(font); SWTAxisEditor.this.labelFontField.setText( SWTAxisEditor.this.font.getFontData()[0] .toString()); SWTAxisEditor.this.labelFont = SWTAxisEditor.this.font.getFontData()[0]; }

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

1

    FontDialog dlg = new FontDialog(getShell());↵

1

    FontDialog dlg = new FontDialog(getShell());↵

2

                            dlg.setText(localizationResources.getString(↵

2

                            dlg.setText(localizationResources.getString(↵

3

                                    "Font_Selection"));↵

3

                                    "Font_Selection"));↵

4

                            dlg.setFontList(new FontData[] {↵

4

                            dlg.setFontList(new FontData[] { ↵

5

                                    SWTAxisEditor.this.tickLabelFont});↵

5

                                    SWTAxisEditor.this.labelFont });↵

6

                            if (dlg.open() != null) {↵

6

                            if (dlg.open() != null) {↵

7

                                // Dispose of any fonts we have created↵

7

                                // Dispose of any fonts we have created↵

8

                                if (SWTAxisEditor.this.font != null) {↵

8

                                if (SWTAxisEditor.this.font != null) {↵

9

                                    SWTAxisEditor.this.font.dispose();↵

9

                                    SWTAxisEditor.this.font.dispose();↵

10

                                }↵

10

                                }↵

11

                                // Create the new font and set it into the title ↵

11

                                // Create the new font and set it into the title ↵

12

                                // label↵

12

                                // label↵

13

                                SWTAxisEditor.this.font = new Font(↵

13

                                SWTAxisEditor.this.font = new Font(↵

14

                                        getShell().getDisplay(), dlg.getFontList());↵

14

                                        getShell().getDisplay(), dlg.getFontList());↵

15

                                //tickLabelFontField.setFont(font);↵

15

                                //label.setFont(font);↵

16

                                SWTAxisEditor.this.tickLabelFontField.setText(↵

16

                                SWTAxisEditor.this.labelFontField.setText(↵

17

                                        SWTAxisEditor.this.font.getFontData()[0]↵

17

                                        SWTAxisEditor.this.font.getFontData()[0]↵

18

                                        .toString());↵

18

                                        .toString());↵

19

                                SWTAxisEditor.this.tickLabelFont ↵

19

                                SWTAxisEditor.this.labelFont ↵

20

                                        = SWTAxisEditor.this.font.getFontData()[0];↵

20

                                        = SWTAxisEditor.this.font.getFontData()[0];↵

21

                            }

21

                            }

See real code fragment |  | See real code fragment

Summary
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) | 1.2
Clones location | Clones are in the same java file
Number of node comparisons | 25

1. {Non-refactorable}

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

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

   1

       FontDialog dlg = new FontDialog(getShell());

   1

       FontDialog dlg = new FontDialog(getShell());

   2

       dlg.setText(localizationResources.getString("Font_Selection"));

   2

       dlg.setText(localizationResources.getString("Font_Selection"));

   3

       dlg.setFontList(new FontData[] {SWTAxisEditor.this.tickLabelFont});

   3 | dlg.setFontList(new FontData[] {SWTAxisEditor.this.tickLabelFont});
   3 | dlg.setFontList(new FontData[] {SWTAxisEditor.this.labelFont});

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   tickLabelFont | labelFont | VARIABLE_NAME_MISMATCH

   3

       dlg.setFontList(new FontData[] {SWTAxisEditor.this.labelFont});

   4

       if (dlg.open() != null)

   4 | if (dlg.open() != null)
   4 | if (dlg.open() != null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   tickLabelFontField | labelFontField | VARIABLE_NAME_MISMATCH
   tickLabelFont | labelFont | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression SWTAxisEditor.this.tickLabelFont is a field being modified, and thus it cannot be parameterized
   Expression SWTAxisEditor.this.labelFont is a field being modified, and thus it cannot be parameterized

   4

       if (dlg.open() != null)

   5

       if (SWTAxisEditor.this.font != null)

   5

       if (SWTAxisEditor.this.font != null)

   6

       SWTAxisEditor.this.font.dispose();

   6

       SWTAxisEditor.this.font.dispose();

   7

       SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());

   7

       SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());

   8

       SWTAxisEditor.this.tickLabelFontField.setText(SWTAxisEditor.this.font.getFontData()[0].toString());

   8 | SWTAxisEditor.this.tickLabelFontField.setText(SWTAxisEditor.this.font.getFontData()[0].toString());
   8 | SWTAxisEditor.this.labelFontField.setText(SWTAxisEditor.this.font.getFontData()[0].toString());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   tickLabelFontField | labelFontField | VARIABLE_NAME_MISMATCH

   8

       SWTAxisEditor.this.labelFontField.setText(SWTAxisEditor.this.font.getFontData()[0].toString());

   9

       SWTAxisEditor.this.tickLabelFont = SWTAxisEditor.this.font.getFontData()[0];

   9 | SWTAxisEditor.this.tickLabelFont = SWTAxisEditor.this.font.getFontData()[0];
   9 | SWTAxisEditor.this.labelFont = SWTAxisEditor.this.font.getFontData()[0];

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   tickLabelFont | labelFont | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression SWTAxisEditor.this.tickLabelFont is a field being modified, and thus it cannot be parameterized
   Expression SWTAxisEditor.this.labelFont is a field being modified, and thus it cannot be parameterized

   9

       SWTAxisEditor.this.labelFont = SWTAxisEditor.this.font.getFontData()[0];

   Precondition Violations (4)
   Row | Violation
   --- | ---
   1 | Expression SWTAxisEditor.this.tickLabelFont is a field being modified, and thus it cannot be parameterized
   2 | Expression SWTAxisEditor.this.labelFont is a field being modified, and thus it cannot be parameterized
   3 | Expression SWTAxisEditor.this.tickLabelFont is a field being modified, and thus it cannot be parameterized
   4 | Expression SWTAxisEditor.this.labelFont is a field being modified, and thus it cannot be parameterized