259-1-2

if (image == null) { throw new IllegalArgumentException("Null 'image' argument."); } int w = image.getWidth(null); int h = image.getHeight(null); if (w == -1 || h == -1) { return false; } Paint savedPaint = getPaint(); fill(new Rectangle2D.Double(x, y, w, h)); setPaint(savedPaint); return drawImage(image, x, y, observer);
if (image == null) { throw new IllegalArgumentException("Null 'image' argument."); } int w = image.getWidth(null); int h = image.getHeight(null); if (w == -1 || h == -1) { return false; } Paint savedPaint = getPaint(); fill(new Rectangle2D.Double(x, y, w, h)); setPaint(savedPaint); return drawImage(image, x, y, width, height, observer);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/swt/org/jfree/experimental/swt/SWTGraphics2D.java |  | File path: /jfreechart-1.0.10/swt/org/jfree/experimental/swt/SWTGraphics2D.java
Method name: `boolean drawImage(Image, int, int, Color, ImageObserver)` |  | Method name: `boolean drawImage(Image, int, int, int, int, Color, ImageObserver)`
Number of AST nodes: 10 |  | Number of AST nodes: 10

1

    if (image == null) {↵

1

    if (image == null) {↵

2

                throw new IllegalArgumentException("Null 'image' argument.");↵

2

                throw new IllegalArgumentException("Null 'image' argument.");↵

3

            }↵

3

            }↵

4

            int w = image.getWidth(null);↵

4

            int w = image.getWidth(null);↵

5

            int h = image.getHeight(null);↵

5

            int h = image.getHeight(null);↵

6

            if (w == -1 || h == -1) {↵

6

            if (w == -1 || h == -1) {↵

7

                return false;↵

7

                return false;↵

8

            }↵

8

            }↵

9

            Paint savedPaint = getPaint();↵

9

            Paint savedPaint = getPaint();↵

10

            fill(new Rectangle2D.Double(x, y, w, h));↵

10

            fill(new Rectangle2D.Double(x, y, w, h));↵

11

            setPaint(savedPaint);↵

11

            setPaint(savedPaint);↵

12

            return drawImage(image, x, y, observer);

12

            return drawImage(image, x, y, width, height, observer);

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 declared in the same class
Number of node comparisons | 49

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 10
   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.1
   Clone type | Type 2

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

   1

       if (image == null)

   1

       if (image == null)

   2

       throw new IllegalArgumentException("Null 'image' argument.");

   2

       throw new IllegalArgumentException("Null 'image' argument.");

   3

       int w = image.getWidth(null);

   3

       int w = image.getWidth(null);

   4

       int h = image.getHeight(null);

   4

       int h = image.getHeight(null);

   5

       if (w == -1 || h == -1)

   5

       if (w == -1 || h == -1)

   6

       return false;

   6

       return false;

   7

       Paint savedPaint = getPaint();

   7

       Paint savedPaint = getPaint();

   8

       fill(new Rectangle2D.Double(x, y, w, h));

   8

       fill(new Rectangle2D.Double(x, y, w, h));

   9

       setPaint(savedPaint);

   9

       setPaint(savedPaint);

   10

       return drawImage(image, x, y, observer);

   10 | return drawImage(image, x, y, observer);
   10 | return drawImage(image, x, y, width, height, observer);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   drawImage(image,x,y,observer) | drawImage(image,x,y,width,height,observer) | ARGUMENT_NUMBER_MISMATCH

   10

       return drawImage(image, x, y, width, height, observer);

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