Point2D.Double pen = getDrawingOrigin().getPoint2D(); double width = getDrawingSize().getWidth().getPoints(); for (Iterator it = paragraphs.iterator(); it.hasNext();) { LineBreakMeasurer lineBreaker = new LineBreakMeasurer(((AttributedString) it.next()).getIterator(), new FontRenderContext(null, true, true)); // for (int i = 0; i < paragraphs.size(); i++) { // LineBreakMeasurer lineBreaker = // new LineBreakMeasurer( // ((AttributedString) paragraphs.get(i)).getIterator(), // new FontRenderContext(null, true, true)); TextLayout layout; float layoutX; while ((layout = lineBreaker.nextLayout((float) width)) != null) { pen.y += layout.getAscent(); layoutX = ((float) (pen.x + width)) - layout.getAdvance(); layout.draw(g, layoutX, (float) pen.y); pen.y += (layout.getDescent() + layout.getLeading()); } }
Point2D.Double pen = getDrawingOrigin().getPoint2D(); double width = getDrawingSize().getWidth().getPoints(); for (Iterator it = paragraphs.iterator(); it.hasNext();) { LineBreakMeasurer lineBreaker = new LineBreakMeasurer(((AttributedString) it.next()).getIterator(), new FontRenderContext(null, true, true)); // for (int i = 0; i < paragraphs.size(); i++) { // LineBreakMeasurer lineBreaker = // new LineBreakMeasurer( // ((AttributedString) paragraphs.get(i)).getIterator(), // new FontRenderContext(null, true, true)); TextLayout layout; float layoutX; while ((layout = lineBreaker.nextLayout((float) width)) != null) { pen.y += layout.getAscent(); layoutX = ((float) (pen.x + (width / 2))) - (layout.getAdvance() / 2); layout.draw(g, layoutX, (float) pen.y); pen.y += (layout.getDescent() + layout.getLeading()); } }
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/core/src/main/java/org/columba/core/print/cParagraph.java File path: /columba-1.4-src/core/src/main/java/org/columba/core/print/cParagraph.java
Method name: void renderRightAligned(Graphics2D) Method name: void renderCenterAligned(Graphics2D)
Number of AST nodes: 11 Number of AST nodes: 11
1
Point2D.Double pen = getDrawingOrigin().getPoint2D();
1
Point2D.Double pen = getDrawingOrigin().getPoint2D();
2
        double width = getDrawingSize().getWidth().getPoints();
2
        double width = getDrawingSize().getWidth().getPoints();
3
        for (Iterator it = paragraphs.iterator(); it.hasNext();) {
3
        for (Iterator it = paragraphs.iterator(); it.hasNext();) {
4
            LineBreakMeasurer lineBreaker = new LineBreakMeasurer(((AttributedString) it.next()).getIterator(),
4
            LineBreakMeasurer lineBreaker = new LineBreakMeasurer(((AttributedString) it.next()).getIterator(),
5
                    new FontRenderContext(null, true, true));
5
                    new FontRenderContext(null, true, true));
6
            // for (int i = 0; i < paragraphs.size(); i++) {
6
            // for (int i = 0; i < paragraphs.size(); i++) {
7
            // LineBreakMeasurer lineBreaker =
7
            // LineBreakMeasurer lineBreaker =
8
            // new LineBreakMeasurer(
8
            // new LineBreakMeasurer(
9
            // ((AttributedString) paragraphs.get(i)).getIterator(),
9
            // ((AttributedString) paragraphs.get(i)).getIterator(),
10
            // new FontRenderContext(null, true, true));
10
            // new FontRenderContext(null, true, true));
11
            TextLayout layout;
11
            TextLayout layout;
12
            float layoutX;
12
            float layoutX;
13
            while ((layout = lineBreaker.nextLayout((float) width)) != null) {
13
            while ((layout = lineBreaker.nextLayout((float) width)) != null) {
14
                pen.y += layout.getAscent();
14
                pen.y += layout.getAscent();
15
                layoutX = ((float) (pen.x + width)) - 
15
                layoutX = ((float) (pen.x + (width / 2))) -
16
layout.getAdvance();
16
                    (layout.getAdvance() / 2);
17
                layout.draw(g, layoutX, (float) pen.y);
17
                layout.draw(g, layoutX, (float) pen.y);
18
                pen.y += (layout.getDescent() + layout.getLeading());
18
                pen.y += (layout.getDescent() + layout.getLeading());
19
            }
19
            }
20
        }
20
        }
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.5
Clones locationClones are declared in the same class
Number of node comparisons47
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)48.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Point2D.Double pen = getDrawingOrigin().getPoint2D();
    1
    Point2D.Double pen = getDrawingOrigin().getPoint2D();
    2
    double width = getDrawingSize().getWidth().getPoints();
    2
    double width = getDrawingSize().getWidth().getPoints();
    3
    for (Iterator it = paragraphs.iterator(); it.hasNext(); )
    3
    for (Iterator it = paragraphs.iterator(); it.hasNext(); )
    4
    LineBreakMeasurer lineBreaker = new LineBreakMeasurer(((AttributedString)it.next()).getIterator(), new FontRenderContext(null, true, true));
    4
    LineBreakMeasurer lineBreaker = new LineBreakMeasurer(((AttributedString)it.next()).getIterator(), new FontRenderContext(null, true, true));
    5
    TextLayout layout;
    5
    TextLayout layout;
    6
    float layoutX;
    6
    float layoutX;
    7
    while ((layout = lineBreaker.nextLayout((float)width)) != null)
    7
    while ((layout = lineBreaker.nextLayout((float)width)) != null)
    8
    pen.y += layout.getAscent();
    8
    pen.y += layout.getAscent();
    9
    layoutX = ((float)(pen.x + width)) - layout.getAdvance();
    9
    layoutX = ((float)(pen.x + width)) - layout.getAdvance();
    9
    layoutX = ((float)(pen.x + (width / 2))) - (layout.getAdvance() / 2);
    Differences
    Expression1Expression2Difference
    width(width / 2)TYPE_COMPATIBLE_REPLACEMENT
    layout.getAdvance()(layout.getAdvance() / 2)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (width / 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression layout.getAdvance() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (layout.getAdvance() / 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    layoutX = ((float)(pen.x + (width / 2))) - (layout.getAdvance() / 2);
    10
    layout.draw(g, layoutX, (float)pen.y);
    10
    layout.draw(g, layoutX, (float)pen.y);
    11
    pen.y += (layout.getDescent() + layout.getLeading());
    11
    pen.y += (layout.getDescent() + layout.getLeading());
    Precondition Violations (4)
    Row Violation
    1Expression width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression (width / 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression layout.getAdvance() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression (layout.getAdvance() / 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted