double anchorX = state.getLinkArea().getMinX(); double targetX = anchorX - record.getGap(); double targetY = record.getAllocatedY(); if (this.labelLinksVisible) { double theta = record.getAngle(); double linkX = state.getPieCenterX() + Math.cos(theta) * state.getPieWRadius() * record.getLinkPercent(); double linkY = state.getPieCenterY() - Math.sin(theta) * state.getPieHRadius() * record.getLinkPercent(); double elbowX = state.getPieCenterX() + Math.cos(theta) * state.getLinkArea().getWidth() / 2.0; double elbowY = state.getPieCenterY() - Math.sin(theta) * state.getLinkArea().getHeight() / 2.0; double anchorY = elbowY; g2.setPaint(this.labelLinkPaint); g2.setStroke(this.labelLinkStroke); PieLabelLinkStyle style = getLabelLinkStyle(); if (style.equals(PieLabelLinkStyle.STANDARD)) { g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY)); g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY)); g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY)); } else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) { QuadCurve2D q = new QuadCurve2D.Float(); q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY); g2.draw(q); g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY)); } else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) { CubicCurve2D c = new CubicCurve2D .Float(); c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY, linkX, linkY); g2.draw(c); } } TextBox tb = record.getLabel(); tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.RIGHT);
double anchorX = state.getLinkArea().getMaxX(); double targetX = anchorX + record.getGap(); double targetY = record.getAllocatedY(); if (this.labelLinksVisible) { double theta = record.getAngle(); double linkX = state.getPieCenterX() + Math.cos(theta) * state.getPieWRadius() * record.getLinkPercent(); double linkY = state.getPieCenterY() - Math.sin(theta) * state.getPieHRadius() * record.getLinkPercent(); double elbowX = state.getPieCenterX() + Math.cos(theta) * state.getLinkArea().getWidth() / 2.0; double elbowY = state.getPieCenterY() - Math.sin(theta) * state.getLinkArea().getHeight() / 2.0; double anchorY = elbowY; g2.setPaint(this.labelLinkPaint); g2.setStroke(this.labelLinkStroke); PieLabelLinkStyle style = getLabelLinkStyle(); if (style.equals(PieLabelLinkStyle.STANDARD)) { g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY)); g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY)); g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY)); } else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) { QuadCurve2D q = new QuadCurve2D.Float(); q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY); g2.draw(q); g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY)); } else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) { CubicCurve2D c = new CubicCurve2D .Float(); c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY, linkX, linkY); g2.draw(c); } } TextBox tb = record.getLabel(); tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.LEFT);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/plot/PiePlot.java File path: /jfreechart-1.0.10/src/org/jfree/chart/plot/PiePlot.java
Method name: void drawLeftLabel(Graphics2D, PiePlotState, PieLabelRecord) Method name: void drawRightLabel(Graphics2D, PiePlotState, PieLabelRecord)
Number of AST nodes: 28 Number of AST nodes: 28
1
double anchorX = state.getLinkArea().getMinX();
1
double anchorX = state.getLinkArea().getMaxX();
2
        double targetX = anchorX - record.getGap();
2
        double targetX = anchorX + record.getGap();
3
        double targetY = record.getAllocatedY();
3
        double targetY = record.getAllocatedY();
4
        
4
        
5
        if (this.labelLinksVisible) {
5
        if (this.labelLinksVisible) {
6
            double theta = record.getAngle();
6
            double theta = record.getAngle();
7
            double linkX = state.getPieCenterX() + Math.cos(theta) 
7
            double linkX = state.getPieCenterX() + Math.cos(theta) 
8
                    * state.getPieWRadius() * record.getLinkPercent();
8
                    * state.getPieWRadius() * record.getLinkPercent();
9
            double linkY = state.getPieCenterY() - Math.sin(theta) 
9
            double linkY = state.getPieCenterY() - Math.sin(theta) 
10
                    * state.getPieHRadius() * record.getLinkPercent();
10
                    * state.getPieHRadius() * record.getLinkPercent();
11
            double elbowX = state.getPieCenterX() + Math.cos(theta) 
11
            double elbowX = state.getPieCenterX() + Math.cos(theta) 
12
                    * state.getLinkArea().getWidth() / 2.0;
12
                    * state.getLinkArea().getWidth() / 2.0;
13
            double elbowY = state.getPieCenterY() - Math.sin(theta) 
13
            double elbowY = state.getPieCenterY() - Math.sin(theta) 
14
                    * state.getLinkArea().getHeight() / 2.0;
14
                    * state.getLinkArea().getHeight() / 2.0;
15
            double anchorY = elbowY;
15
            double anchorY = elbowY;
16
            g2.setPaint(this.labelLinkPaint);
16
            g2.setPaint(this.labelLinkPaint);
17
            g2.setStroke(this.labelLinkStroke);
17
            g2.setStroke(this.labelLinkStroke);
18
            PieLabelLinkStyle style = getLabelLinkStyle();
18
            PieLabelLinkStyle style = getLabelLinkStyle();
19
            if (style.equals(PieLabelLinkStyle.STANDARD)) {
19
            if (style.equals(PieLabelLinkStyle.STANDARD)) {
20
                g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
20
                g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
21
                g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
21
                g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
22
                g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
22
                g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
23
            }
23
            }
24
            else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) {
24
            else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) {
25
                QuadCurve2D q = new QuadCurve2D.Float();
25
                QuadCurve2D q = new QuadCurve2D.Float();
26
                q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
26
                q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
27
                g2.draw(q);
27
                g2.draw(q);
28
                g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));               
28
                g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));               
29
            }
29
            }
30
            else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) {
30
            else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) {
31
                CubicCurve2D c = new CubicCurve2D .Float();
31
                CubicCurve2D c = new CubicCurve2D .Float();
32
                c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY, 
32
                c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY, 
33
                        linkX, linkY);
33
                        linkX, linkY);
34
                g2.draw(c);
34
                g2.draw(c);
35
            }
35
            }
36
        }
36
        }
37
        
37
        TextBox tb = record.getLabel();
38
        TextBox tb = record.getLabel();
38
        tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.RIGHT);
39
        tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.LEFT);
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)1.3
Clones locationClones are declared in the same class
Number of node comparisons241
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements28
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)56.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    double anchorX = state.getLinkArea().getMinX();
    1
    double anchorX = state.getLinkArea().getMinX();
    1
    double anchorX = state.getLinkArea().getMaxX();
    Differences
    Expression1Expression2Difference
    getMinXgetMaxXMETHOD_INVOCATION_NAME_MISMATCH
    1
    double anchorX = state.getLinkArea().getMaxX();
    2
    double targetX = anchorX - record.getGap();
    2
    double targetX = anchorX - record.getGap();
    2
    double targetX = anchorX + record.getGap();
    Differences
    Expression1Expression2Difference
    -+OPERATOR_MISMATCH
    Preondition Violations
    Expression anchorX - record.getGap() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression anchorX + record.getGap() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    double targetX = anchorX + record.getGap();
    3
    double targetY = record.getAllocatedY();
    3
    double targetY = record.getAllocatedY();
    4
    if (this.labelLinksVisible)
    4
    if (this.labelLinksVisible)
    5
    double theta = record.getAngle();
    5
    double theta = record.getAngle();
    6
    double linkX = state.getPieCenterX() + Math.cos(theta) * state.getPieWRadius() * record.getLinkPercent();
    6
    double linkX = state.getPieCenterX() + Math.cos(theta) * state.getPieWRadius() * record.getLinkPercent();
    7
    double linkY = state.getPieCenterY() - Math.sin(theta) * state.getPieHRadius() * record.getLinkPercent();
    7
    double linkY = state.getPieCenterY() - Math.sin(theta) * state.getPieHRadius() * record.getLinkPercent();
    8
    double elbowX = state.getPieCenterX() + Math.cos(theta) * state.getLinkArea().getWidth() / 2.0;
    8
    double elbowX = state.getPieCenterX() + Math.cos(theta) * state.getLinkArea().getWidth() / 2.0;
    9
    double elbowY = state.getPieCenterY() - Math.sin(theta) * state.getLinkArea().getHeight() / 2.0;
    9
    double elbowY = state.getPieCenterY() - Math.sin(theta) * state.getLinkArea().getHeight() / 2.0;
    10
    double anchorY = elbowY;
    10
    double anchorY = elbowY;
    11
    g2.setPaint(this.labelLinkPaint);
    11
    g2.setPaint(this.labelLinkPaint);
    12
    g2.setStroke(this.labelLinkStroke);
    12
    g2.setStroke(this.labelLinkStroke);
    13
    PieLabelLinkStyle style = getLabelLinkStyle();
    13
    PieLabelLinkStyle style = getLabelLinkStyle();
    14
    if (style.equals(PieLabelLinkStyle.STANDARD))
    14
    if (style.equals(PieLabelLinkStyle.STANDARD))
    15
    g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
    15
    g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
    16
    g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
    16
    g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
    17
    g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
    17
    g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
    18
    else if (style.equals(PieLabelLinkStyle.QUAD_CURVE))
    18
    else if (style.equals(PieLabelLinkStyle.QUAD_CURVE))
    19
    QuadCurve2D q = new QuadCurve2D.Float();
    19
    QuadCurve2D q = new QuadCurve2D.Float();
    20
    q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
    20
    q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
    21
    g2.draw(q);
    21
    g2.draw(q);
    22
    g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));
    22
    g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));
    23
    else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE))
    23
    else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE))
    24
    CubicCurve2D c = new CubicCurve2D.Float();
    24
    CubicCurve2D c = new CubicCurve2D.Float();
    25
    c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY, linkX, linkY);
    25
    c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY, linkX, linkY);
    26
    g2.draw(c);
    26
    g2.draw(c);
    27
    TextBox tb = record.getLabel();
    27
    TextBox tb = record.getLabel();
    28
    tb.draw(g2, (float)targetX, (float)targetY, RectangleAnchor.RIGHT);
    28
    tb.draw(g2, (float)targetX, (float)targetY, RectangleAnchor.RIGHT);
    28
    tb.draw(g2, (float)targetX, (float)targetY, RectangleAnchor.LEFT);
    Differences
    Expression1Expression2Difference
    RIGHTLEFTVARIABLE_NAME_MISMATCH
    28
    tb.draw(g2, (float)targetX, (float)targetY, RectangleAnchor.LEFT);
    Precondition Violations (2)
    Row Violation
    1Expression anchorX - record.getGap() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression anchorX + record.getGap() cannot be parameterized, because it has dependencies to/from statements that will be extracted