BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE); Graphics2D graphics = (Graphics2D) bi.getGraphics(); if (!stroke.equals("transparent")) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); graphics.draw(new Ellipse2D.Double(0, 0, width, height)); } if (!fill.equals("transparent")) { graphics.setColor(ColorMapper.getColorByName(fill)); graphics.fill(new Ellipse2D.Double(0, 0, width, height)); } for (int i = 0; i < instructions.size(); i++) { ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); if (instr instanceof DrawOperation) { PlanarImage img = ((DrawOperation) instr).executeDrawOperation(); graphics.drawImage(img.getAsBufferedImage(), null, 0, 0); } else if (instr instanceof TransformOperation) { graphics = (Graphics2D) bi.getGraphics(); PlanarImage image = ((TransformOperation) instr) .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); bi = image.getAsBufferedImage(); } } return PlanarImage.wrapRenderedImage(bi);
BufferedImage bi = new BufferedImage(width + (stroke_width * 2), height + (stroke_width * 2), BufferedImage.TYPE_4BYTE_ABGR_PRE); Graphics2D graphics = (Graphics2D) bi.getGraphics(); if (!stroke.equals("transparent")) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width, height, start, stop, type)); } if (!fill.equals("transparent")) { graphics.setColor(ColorMapper.getColorByName(fill)); graphics.fill(new Arc2D.Double(stroke_width, stroke_width, width, height, start, stop, type)); } for (int i = 0; i < instructions.size(); i++) { ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); if (instr instanceof DrawOperation) { PlanarImage img = ((DrawOperation) instr).executeDrawOperation(); graphics.drawImage(img.getAsBufferedImage(), null, 0, 0); } else if (instr instanceof TransformOperation) { graphics = (Graphics2D) bi.getGraphics(); PlanarImage image = ((TransformOperation) instr) .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); bi = image.getAsBufferedImage(); } } return PlanarImage.wrapRenderedImage(bi);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/optional/image/Ellipse.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/optional/image/Arc.java
Method name: PlanarImage executeDrawOperation() Method name: PlanarImage executeDrawOperation()
Number of AST nodes: 20 Number of AST nodes: 20
1
BufferedImage bi = new BufferedImage(width, height
1
BufferedImage bi = new BufferedImage(width + (stroke_width * 2),
2
, BufferedImage.TYPE_4BYTE_ABGR_PRE);
2
            height + (stroke_width * 2), BufferedImage.TYPE_4BYTE_ABGR_PRE);
3
        Graphics2D graphics = (Graphics2D) bi.getGraphics();
3
        Graphics2D graphics = (Graphics2D) bi.getGraphics();
4
        if (!stroke.equals("transparent")) {
4
        if (!stroke.equals("transparent")) {
5
            BasicStroke bStroke = new BasicStroke(stroke_width);
5
            BasicStroke bStroke = new BasicStroke(stroke_width);
6
            graphics.setColor(ColorMapper.getColorByName(stroke));
6
            graphics.setColor(ColorMapper.getColorByName(stroke));
7
            graphics.setStroke(bStroke);
7
            graphics.setStroke(bStroke);
8
            graphics.draw(new Ellipse2D.Double(0, 0, width, height
8
            graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width,
9
));
9
                height, start, stop, type));
10
        }
10
        }
11
        if (!fill.equals("transparent")) {
11
        if (!fill.equals("transparent")) {
12
            graphics.setColor(ColorMapper.getColorByName(fill));
12
            graphics.setColor(ColorMapper.getColorByName(fill));
13
            graphics.fill(new Ellipse2D.Double(0, 0, width, height
13
            graphics.fill(new Arc2D.Double(stroke_width, stroke_width,
14
));
14
                width, height, start, stop, type));
15
        }
15
        }
16
        for (int i = 0; i < instructions.size(); i++) {
16
        for (int i = 0; i < instructions.size(); i++) {
17
            ImageOperation instr = ((ImageOperation) instructions.elementAt(i));
17
            ImageOperation instr = ((ImageOperation) instructions.elementAt(i));
18
            if (instr instanceof DrawOperation) {
18
            if (instr instanceof DrawOperation) {
19
                PlanarImage img = ((DrawOperation) instr).executeDrawOperation();
19
                PlanarImage img = ((DrawOperation) instr).executeDrawOperation();
20
                graphics.drawImage(img.getAsBufferedImage(), null, 0, 0);
20
                graphics.drawImage(img.getAsBufferedImage(), null, 0, 0);
21
            } else if (instr instanceof TransformOperation) {
21
            } else if (instr instanceof TransformOperation) {
22
                graphics = (Graphics2D) bi.getGraphics();
22
                graphics = (Graphics2D) bi.getGraphics();
23
                PlanarImage image = ((TransformOperation) instr)
23
                PlanarImage image = ((TransformOperation) instr)
24
                    .executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
24
                    .executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
25
                bi = image.getAsBufferedImage();
25
                bi = image.getAsBufferedImage();
26
            }
26
            }
27
        }
27
        }
28
        return PlanarImage.wrapRenderedImage(bi);
28
        return PlanarImage.wrapRenderedImage(bi);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.8
Clones locationClones are in different classes having the same super class
Number of node comparisons97
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements20
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)7.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE);
    1
    BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE);
    1
    BufferedImage bi = new BufferedImage(width + (stroke_width * 2), height + (stroke_width * 2), BufferedImage.TYPE_4BYTE_ABGR_PRE);
    Differences
    Expression1Expression2Difference
    widthwidth + (stroke_width * 2)TYPE_COMPATIBLE_REPLACEMENT
    heightheight + (stroke_width * 2)TYPE_COMPATIBLE_REPLACEMENT
    1
    BufferedImage bi = new BufferedImage(width + (stroke_width * 2), height + (stroke_width * 2), BufferedImage.TYPE_4BYTE_ABGR_PRE);
    2
    Graphics2D graphics = (Graphics2D)bi.getGraphics();
    2
    Graphics2D graphics = (Graphics2D)bi.getGraphics();
    3
    if (!stroke.equals("transparent"))
    3
    if (!stroke.equals("transparent"))
    4
    BasicStroke bStroke = new BasicStroke(stroke_width);
    4
    BasicStroke bStroke = new BasicStroke(stroke_width);
    5
    graphics.setColor(ColorMapper.getColorByName(stroke));
    5
    graphics.setColor(ColorMapper.getColorByName(stroke));
    6
    graphics.setStroke(bStroke);
    6
    graphics.setStroke(bStroke);
    7
    graphics.draw(new Ellipse2D.Double(0, 0, width, height));
    7
    graphics.draw(new Ellipse2D.Double(0, 0, width, height));
    7
    graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width, height, start, stop, type));
    Differences
    Expression1Expression2Difference
    java.awt.geom.Ellipse2Djava.awt.geom.Arc2DSUBCLASS_TYPE_MISMATCH
    new Ellipse2D.Double(0,0,width,height)new Arc2D.Double(stroke_width,stroke_width,width,height,start,stop,type)ARGUMENT_NUMBER_MISMATCH
    7
    graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width, height, start, stop, type));
    8
    if (!fill.equals("transparent"))
    8
    if (!fill.equals("transparent"))
    9
    graphics.setColor(ColorMapper.getColorByName(fill));
    9
    graphics.setColor(ColorMapper.getColorByName(fill));
    10
    graphics.fill(new Ellipse2D.Double(0, 0, width, height));
    10
    graphics.fill(new Ellipse2D.Double(0, 0, width, height));
    10
    graphics.fill(new Arc2D.Double(stroke_width, stroke_width, width, height, start, stop, type));
    Differences
    Expression1Expression2Difference
    java.awt.geom.Ellipse2Djava.awt.geom.Arc2DSUBCLASS_TYPE_MISMATCH
    new Ellipse2D.Double(0,0,width,height)new Arc2D.Double(stroke_width,stroke_width,width,height,start,stop,type)ARGUMENT_NUMBER_MISMATCH
    10
    graphics.fill(new Arc2D.Double(stroke_width, stroke_width, width, height, start, stop, type));
    11
    for (int i = 0; i < instructions.size(); i++)
    11
    for (int i = 0; i < instructions.size(); i++)
    12
    ImageOperation instr = ((ImageOperation)instructions.elementAt(i));
    12
    ImageOperation instr = ((ImageOperation)instructions.elementAt(i));
    13
    if (instr instanceof DrawOperation)
    13
    if (instr instanceof DrawOperation)
    14
    PlanarImage img = ((DrawOperation)instr).executeDrawOperation();
    14
    PlanarImage img = ((DrawOperation)instr).executeDrawOperation();
    15
    graphics.drawImage(img.getAsBufferedImage(), null, 0, 0);
    15
    graphics.drawImage(img.getAsBufferedImage(), null, 0, 0);
    16
    else if (instr instanceof TransformOperation)
    16
    else if (instr instanceof TransformOperation)
    17
    graphics = (Graphics2D)bi.getGraphics();
    17
    graphics = (Graphics2D)bi.getGraphics();
    18
    PlanarImage image = ((TransformOperation)instr).executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
    18
    PlanarImage image = ((TransformOperation)instr).executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
    19
    bi = image.getAsBufferedImage();
    19
    bi = image.getAsBufferedImage();
    20
    return PlanarImage.wrapRenderedImage(bi);
    20
    return PlanarImage.wrapRenderedImage(bi);
    Precondition Violations (0)
    Row Violation