String label = generator.generateLabel(data, row, column); if (label == null) { return; // nothing to do } Font labelFont = getItemLabelFont(row, column); g2.setFont(labelFont); Paint paint = getItemLabelPaint(row, column); g2.setPaint(paint); // find out where to place the label... ItemLabelPosition position = null; if (!negative) { position = getPositiveItemLabelPosition(row, column); } else { position = getNegativeItemLabelPosition(row, column); } // work out the label anchor point... Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); if (isInternalAnchor(position.getItemLabelAnchor())) { Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); if (bounds != null) { if (!bar.contains(bounds.getBounds2D())) { if (!negative) { position = getPositiveItemLabelPositionFallback(); } else { position = getNegativeItemLabelPositionFallback(); } if (position != null) { anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); } } } } if (position != null) { TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); }
if (generator == null) { return; // nothing to do } String label = generator.generateLabel(dataset, series, item); if (label == null) { return; // nothing to do } Font labelFont = getItemLabelFont(series, item); g2.setFont(labelFont); Paint paint = getItemLabelPaint(series, item); g2.setPaint(paint); // find out where to place the label... ItemLabelPosition position = null; if (!negative) { position = getPositiveItemLabelPosition(series, item); } else { position = getNegativeItemLabelPosition(series, item); } // work out the label anchor point... Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); if (isInternalAnchor(position.getItemLabelAnchor())) { Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); if (bounds != null) { if (!bar.contains(bounds.getBounds2D())) { if (!negative) { position = getPositiveItemLabelPositionFallback(); } else { position = getNegativeItemLabelPositionFallback(); } if (position != null) { anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); } } } } if (position != null) { TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/category/BarRenderer.java File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/xy/XYBarRenderer.java
Method name: void drawItemLabel(Graphics2D, CategoryDataset, int, int, CategoryPlot, CategoryItemLabelGenerator, Rectangle2D, boolean) Method name: void drawItemLabel(Graphics2D, XYDataset, int, int, XYPlot, XYItemLabelGenerator, Rectangle2D, boolean)
Number of AST nodes: 23 Number of AST nodes: 25
1
if (generator == null) {
2
            return;  // nothing to do
3
        }
1
String label = generator.generateLabel(data, row, column);
4
        String label = generator.generateLabel(dataset, series, item);
2
        if (label == null) {
5
        if (label == null) {
3
            return;  // nothing to do
6
            return;  // nothing to do   
4
        }
7
        }
8
        
5
        Font labelFont = getItemLabelFont(row, column);
9
        Font labelFont = getItemLabelFont(series, item);
6
        g2.setFont(labelFont);
10
        g2.setFont(labelFont);
7
        Paint paint = getItemLabelPaint(row, column);
11
        Paint paint = getItemLabelPaint(series, item);
8
        g2.setPaint(paint);
12
        g2.setPaint(paint);
9
        // find out where to place the label...
13
        // find out where to place the label...
10
        ItemLabelPosition position = null;
14
        ItemLabelPosition position = null;
11
        if (!negative) {
15
        if (!negative) {
12
            position = getPositiveItemLabelPosition(row, column);
16
            position = getPositiveItemLabelPosition(series, item);
13
        }
17
        }
14
        else {
18
        else {
15
            position = getNegativeItemLabelPosition(row, column);
19
            position = getNegativeItemLabelPosition(series, item);
16
        }
20
        }
17
        // work out the label anchor point...
21
        // work out the label anchor point...
18
        Point2D anchorPoint = calculateLabelAnchorPoint(
22
        Point2D anchorPoint = calculateLabelAnchorPoint(
19
                position.getItemLabelAnchor(), bar, plot.getOrientation());
23
                position.getItemLabelAnchor(), bar, plot.getOrientation());
24
        
20
        if (isInternalAnchor(position.getItemLabelAnchor())) {
25
        if (isInternalAnchor(position.getItemLabelAnchor())) {
21
            Shape bounds = TextUtilities.calculateRotatedStringBounds(label,
26
            Shape bounds = TextUtilities.calculateRotatedStringBounds(label, 
22
                    g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
27
                    g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
23
                    position.getTextAnchor(), position.getAngle(),
28
                    position.getTextAnchor(), position.getAngle(),
24
                    position.getRotationAnchor());
29
                    position.getRotationAnchor());
30
            
25
            if (bounds != null) {
31
            if (bounds != null) {
26
                if (!bar.contains(bounds.getBounds2D())) {
32
                if (!bar.contains(bounds.getBounds2D())) {
27
                    if (!negative) {
33
                    if (!negative) {
28
                        position = getPositiveItemLabelPositionFallback();
34
                        position = getPositiveItemLabelPositionFallback();
29
                    }
35
                    }
30
                    else {
36
                    else {
31
                        position = getNegativeItemLabelPositionFallback();
37
                        position = getNegativeItemLabelPositionFallback();
32
                    }
38
                    }
33
                    if (position != null) {
39
                    if (position != null) {
34
                        anchorPoint = calculateLabelAnchorPoint(
40
                        anchorPoint = calculateLabelAnchorPoint(
35
                                position.getItemLabelAnchor(), bar,
41
                                position.getItemLabelAnchor(), bar, 
36
                                plot.getOrientation());
42
                                plot.getOrientation());
37
                    }
43
                    }
38
                }
44
                }
39
            }
45
            }
46
        
40
        }
47
        }
48
        
41
        if (position != null) {
49
        if (position != null) {
42
            TextUtilities.drawRotatedString(label, g2,
50
            TextUtilities.drawRotatedString(label, g2, 
43
                    (float) anchorPoint.getX(), (float) anchorPoint.getY(),
51
                    (float) anchorPoint.getX(), (float) anchorPoint.getY(),
44
                    position.getTextAnchor(), position.getAngle(),
52
                    position.getTextAnchor(), position.getAngle(), 
45
                    position.getRotationAnchor());
53
                    position.getRotationAnchor());
46
        }
54
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)1.1
Clones locationClones are in different classes having the same super class
Number of node comparisons97
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements23
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)40.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                    
    1
    if (generator == null)
                        
    2
    return;
    Preondition Violations
    Unmatched return;
    2
    return;
    1
    String label = generator.generateLabel(data, row, column);
    1
    String label = generator.generateLabel(data, row, column);
    3
    String label = generator.generateLabel(dataset, series, item);
    Differences
    Expression1Expression2Difference
    datadatasetVARIABLE_NAME_MISMATCH
    org.jfree.data.category.CategoryDatasetorg.jfree.data.xy.XYDatasetSUBCLASS_TYPE_MISMATCH
    rowseriesVARIABLE_NAME_MISMATCH
    columnitemVARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.CategoryItemLabelGeneratororg.jfree.chart.labels.XYItemLabelGeneratorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression data cannot be unified with expression dataset , because common superclass type org.jfree.data.general.Dataset cannot be passed as an argument to public abstract java.lang.String generateLabel(org.jfree.data.category.CategoryDataset, int, int)
    Type org.jfree.chart.labels.CategoryItemLabelGenerator of variable generator does not match with type org.jfree.chart.labels.XYItemLabelGenerator of variable generator
    • Make classes org.jfree.chart.labels.CategoryItemLabelGenerator and org.jfree.chart.labels.XYItemLabelGenerator extend a common superclass
    3
    String label = generator.generateLabel(dataset, series, item);
    2
    if (label == null)
    4
    if (label == null)
    3
    return;
    5
    return;
    4
    Font labelFont = getItemLabelFont(row, column);
    4
    Font labelFont = getItemLabelFont(row, column);
    6
    Font labelFont = getItemLabelFont(series, item);
    Differences
    Expression1Expression2Difference
    rowseriesVARIABLE_NAME_MISMATCH
    columnitemVARIABLE_NAME_MISMATCH
    6
    Font labelFont = getItemLabelFont(series, item);
    5
    g2.setFont(labelFont);
    7
    g2.setFont(labelFont);
    6
    Paint paint = getItemLabelPaint(row, column);
    6
    Paint paint = getItemLabelPaint(row, column);
    8
    Paint paint = getItemLabelPaint(series, item);
    Differences
    Expression1Expression2Difference
    rowseriesVARIABLE_NAME_MISMATCH
    columnitemVARIABLE_NAME_MISMATCH
    8
    Paint paint = getItemLabelPaint(series, item);
    7
    g2.setPaint(paint);
    9
    g2.setPaint(paint);
    8
    ItemLabelPosition position = null;
    10
    ItemLabelPosition position = null;
    9
    if (!negative)
    11
    if (!negative)
    10
    position = getPositiveItemLabelPosition(row, column);
    10
    position = getPositiveItemLabelPosition(row, column);
    12
    position = getPositiveItemLabelPosition(series, item);
    Differences
    Expression1Expression2Difference
    rowseriesVARIABLE_NAME_MISMATCH
    columnitemVARIABLE_NAME_MISMATCH
    12
    position = getPositiveItemLabelPosition(series, item);
    else
    else
    11
    position = getNegativeItemLabelPosition(row, column);
    11
    position = getNegativeItemLabelPosition(row, column);
    13
    position = getNegativeItemLabelPosition(series, item);
    Differences
    Expression1Expression2Difference
    rowseriesVARIABLE_NAME_MISMATCH
    columnitemVARIABLE_NAME_MISMATCH
    13
    position = getNegativeItemLabelPosition(series, item);
    12
    Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());
    12
    Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());
    14
    Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.CategoryPlotorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) public org.jfree.chart.plot.PlotOrientation getOrientation()
    14
    Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());
    13
    if (isInternalAnchor(position.getItemLabelAnchor()))
    15
    if (isInternalAnchor(position.getItemLabelAnchor()))
    14
    Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float)anchorPoint.getX(), (float)anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());
    16
    Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float)anchorPoint.getX(), (float)anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());
    15
    if (bounds != null)
    17
    if (bounds != null)
    16
    if (!bar.contains(bounds.getBounds2D()))
    18
    if (!bar.contains(bounds.getBounds2D()))
    17
    if (!negative)
    19
    if (!negative)
    18
    position = getPositiveItemLabelPositionFallback();
    20
    position = getPositiveItemLabelPositionFallback();
    else
    else
    19
    position = getNegativeItemLabelPositionFallback();
    21
    position = getNegativeItemLabelPositionFallback();
    20
    if (position != null)
    22
    if (position != null)
    21
    anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());
    21
    anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());
    23
    anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.CategoryPlotorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) public org.jfree.chart.plot.PlotOrientation getOrientation()
    23
    anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, plot.getOrientation());
    22
    if (position != null)
    24
    if (position != null)
    23
    TextUtilities.drawRotatedString(label, g2, (float)anchorPoint.getX(), (float)anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());
    25
    TextUtilities.drawRotatedString(label, g2, (float)anchorPoint.getX(), (float)anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());
    Precondition Violations (5)
    Row Violation
    1Unmatched return;
    2Expression data cannot be unified with expression dataset , because common superclass type org.jfree.data.general.Dataset cannot be passed as an argument to public abstract java.lang.String generateLabel(org.jfree.data.category.CategoryDataset, int, int)
    3Type org.jfree.chart.labels.CategoryItemLabelGenerator of variable generator does not match with type org.jfree.chart.labels.XYItemLabelGenerator of variable generator
    4Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) public org.jfree.chart.plot.PlotOrientation getOrientation()
    5Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) public org.jfree.chart.plot.PlotOrientation getOrientation()