AxisSpace space = new AxisSpace(); PlotOrientation orientation = getOrientation(); // work out the space required by the domain axis... AxisSpace fixed = getFixedRangeAxisSpace(); if (fixed != null) { if (orientation == PlotOrientation.VERTICAL) { space.setLeft(fixed.getLeft()); space.setRight(fixed.getRight()); } else if (orientation == PlotOrientation.HORIZONTAL) { space.setTop(fixed.getTop()); space.setBottom(fixed.getBottom()); } } else { ValueAxis valueAxis = getRangeAxis(); RectangleEdge valueEdge = Plot.resolveRangeAxisLocation( getRangeAxisLocation(), orientation); if (valueAxis != null) { space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, space); } } Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); // work out the maximum height or width of the non-shared axes... int n = this.subplots.size(); // calculate plotAreas of all sub-plots, maximum vertical/horizontal // axis width/height this.subplotArea = new Rectangle2D[n]; double x = adjustedPlotArea.getX(); double y = adjustedPlotArea.getY(); double usableSize = 0.0; if (orientation == PlotOrientation.VERTICAL) { usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); } else if (orientation == PlotOrientation.HORIZONTAL) { usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); } for (int i = 0; i < n; i++) { CategoryPlot plot = (CategoryPlot) this.subplots.get(i); // calculate sub-plot area if (orientation == PlotOrientation.VERTICAL) { double w = usableSize * plot.getWeight() / this.totalWeight; this.subplotArea[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); x = x + w + this.gap; } else if (orientation == PlotOrientation.HORIZONTAL) { double h = usableSize * plot.getWeight() / this.totalWeight; this.subplotArea[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); y = y + h + this.gap; } AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotArea[i], null); space.ensureAtLeast(subSpace); } return space;
AxisSpace space = new AxisSpace(); PlotOrientation orientation = getOrientation(); // work out the space required by the domain axis... AxisSpace fixed = getFixedRangeAxisSpace(); if (fixed != null) { if (orientation == PlotOrientation.VERTICAL) { space.setLeft(fixed.getLeft()); space.setRight(fixed.getRight()); } else if (orientation == PlotOrientation.HORIZONTAL) { space.setTop(fixed.getTop()); space.setBottom(fixed.getBottom()); } } else { ValueAxis valueAxis = getRangeAxis(); RectangleEdge valueEdge = Plot.resolveRangeAxisLocation( getRangeAxisLocation(), orientation ); if (valueAxis != null) { space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, space); } } Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); // work out the maximum height or width of the non-shared axes... int n = this.subplots.size(); // calculate plotAreas of all sub-plots, maximum vertical/horizontal // axis width/height this.subplotAreas = new Rectangle2D[n]; double x = adjustedPlotArea.getX(); double y = adjustedPlotArea.getY(); double usableSize = 0.0; if (orientation == PlotOrientation.VERTICAL) { usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); } else if (orientation == PlotOrientation.HORIZONTAL) { usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); } for (int i = 0; i < n; i++) { XYPlot plot = (XYPlot) this.subplots.get(i); // calculate sub-plot area if (orientation == PlotOrientation.VERTICAL) { double w = usableSize * plot.getWeight() / this.totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); x = x + w + this.gap; } else if (orientation == PlotOrientation.HORIZONTAL) { double h = usableSize * plot.getWeight() / this.totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); y = y + h + this.gap; } AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotAreas[i], null); space.ensureAtLeast(subSpace); } return space;
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/plot/CombinedRangeCategoryPlot.java File path: /jfreechart-1.0.10/src/org/jfree/chart/plot/CombinedRangeXYPlot.java
Method name: AxisSpace calculateAxisSpace(Graphics2D, Rectangle2D) Method name: AxisSpace calculateAxisSpace(Graphics2D, Rectangle2D)
Number of AST nodes: 37 Number of AST nodes: 37
1
AxisSpace space = new AxisSpace();  
1
AxisSpace space = new AxisSpace();
2
        PlotOrientation orientation = getOrientation();
2
        PlotOrientation orientation = getOrientation();
3
        
4
        // work out the space required by the domain axis...
3
        // work out the space required by the domain axis...
5
        AxisSpace fixed = getFixedRangeAxisSpace();
4
        AxisSpace fixed = getFixedRangeAxisSpace();
6
        if (fixed != null) {
5
        if (fixed != null) {
7
            if (orientation == PlotOrientation.VERTICAL) {
6
            if (orientation == PlotOrientation.VERTICAL) {
8
                space.setLeft(fixed.getLeft());
7
                space.setLeft(fixed.getLeft());
9
                space.setRight(fixed.getRight());
8
                space.setRight(fixed.getRight());
10
            }
9
            }
11
            else if (orientation == PlotOrientation.HORIZONTAL) {
10
            else if (orientation == PlotOrientation.HORIZONTAL) {
12
                space.setTop(fixed.getTop());
11
                space.setTop(fixed.getTop());
13
                space.setBottom(fixed.getBottom());                
12
                space.setBottom(fixed.getBottom());
14
            }
13
            }
15
        }
14
        }
16
        else {
15
        else {
17
            ValueAxis valueAxis = getRangeAxis();
16
            ValueAxis valueAxis = getRangeAxis();
18
            RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
17
            RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
19
                    getRangeAxisLocation(), orientation
18
                getRangeAxisLocation(), orientation
20
);
19
            );
21
            if (valueAxis != null) {
20
            if (valueAxis != null) {
22
                space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, 
21
                space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
23
                        space);
22
                        space);
24
            }
23
            }
25
        }
24
        }
26
        
27
        Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
25
        Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
28
        // work out the maximum height or width of the non-shared axes...
26
        // work out the maximum height or width of the non-shared axes...
29
        int n = this.subplots.size();
27
        int n = this.subplots.size();
30
        // calculate plotAreas of all sub-plots, maximum vertical/horizontal 
28
        // calculate plotAreas of all sub-plots, maximum vertical/horizontal
31
        // axis width/height
29
        // axis width/height
32
        this.subplotArea = new Rectangle2D[n];
30
        this.subplotAreas = new Rectangle2D[n];
33
        double x = adjustedPlotArea.getX();
31
        double x = adjustedPlotArea.getX();
34
        double y = adjustedPlotArea.getY();
32
        double y = adjustedPlotArea.getY();
35
        double usableSize = 0.0;
33
        double usableSize = 0.0;
36
        if (orientation == PlotOrientation.VERTICAL) {
34
        if (orientation == PlotOrientation.VERTICAL) {
37
            usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
35
            usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
38
        }
36
        }
39
        else if (orientation == PlotOrientation.HORIZONTAL) {
37
        else if (orientation == PlotOrientation.HORIZONTAL) {
40
            usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
38
            usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
41
        }
39
        }
42
        for (int i = 0; i < n; i++) {
40
        for (int i = 0; i < n; i++) {
43
            CategoryPlot plot = (CategoryPlot) this.subplots.get(i);
41
            XYPlot plot = (XYPlot) this.subplots.get(i);
44
            // calculate sub-plot area
42
            // calculate sub-plot area
45
            if (orientation == PlotOrientation.VERTICAL) {
43
            if (orientation == PlotOrientation.VERTICAL) {
46
                double w = usableSize * plot.getWeight() / this.totalWeight;
44
                double w = usableSize * plot.getWeight() / this.totalWeight;
47
                this.subplotArea[i] = new Rectangle2D.Double(x, y, w, 
45
                this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
48
                        adjustedPlotArea.getHeight());
46
                        adjustedPlotArea.getHeight());
49
                x = x + w + this.gap;
47
                x = x + w + this.gap;
50
            }
48
            }
51
            else if (orientation == PlotOrientation.HORIZONTAL) {
49
            else if (orientation == PlotOrientation.HORIZONTAL) {
52
                double h = usableSize * plot.getWeight() / this.totalWeight;
50
                double h = usableSize * plot.getWeight() / this.totalWeight;
53
                this.subplotArea[i] = new Rectangle2D.Double(x, y, 
51
                this.subplotAreas[i] = new Rectangle2D.Double(x, y,
54
                        adjustedPlotArea.getWidth(), h);
52
                        adjustedPlotArea.getWidth(), h);
55
                y = y + h + this.gap;
53
                y = y + h + this.gap;
56
            }
54
            }
57
            AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, 
55
            AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
58
                    this.subplotArea[i], null);
56
                    this.subplotAreas[i], null);
59
            space.ensureAtLeast(subSpace);
57
            space.ensureAtLeast(subSpace);
60
        }
58
        }
61
        return space;
59
        return space;
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)7.1
Clones locationClones are in different classes having the same super class
Number of node comparisons232
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements37
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)175.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    AxisSpace space = new AxisSpace();
    1
    AxisSpace space = new AxisSpace();
    2
    PlotOrientation orientation = getOrientation();
    2
    PlotOrientation orientation = getOrientation();
    3
    AxisSpace fixed = getFixedRangeAxisSpace();
    3
    AxisSpace fixed = getFixedRangeAxisSpace();
    4
    if (fixed != null)
    4
    if (fixed != null)
    5
    if (orientation == PlotOrientation.VERTICAL)
    5
    if (orientation == PlotOrientation.VERTICAL)
    6
    space.setLeft(fixed.getLeft());
    6
    space.setLeft(fixed.getLeft());
    7
    space.setRight(fixed.getRight());
    7
    space.setRight(fixed.getRight());
    8
    else if (orientation == PlotOrientation.HORIZONTAL)
    8
    else if (orientation == PlotOrientation.HORIZONTAL)
    9
    space.setTop(fixed.getTop());
    9
    space.setTop(fixed.getTop());
    10
    space.setBottom(fixed.getBottom());
    10
    space.setBottom(fixed.getBottom());
    else
    else
    11
    ValueAxis valueAxis = getRangeAxis();
    11
    ValueAxis valueAxis = getRangeAxis();
    12
    RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(getRangeAxisLocation(), orientation);
    12
    RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(getRangeAxisLocation(), orientation);
    13
    if (valueAxis != null)
    13
    if (valueAxis != null)
    14
    space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, space);
    14
    space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, space);
    15
    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    15
    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    16
    int n = this.subplots.size();
    16
    int n = this.subplots.size();
    17
    this.subplotArea = new Rectangle2D[n];
    17
    this.subplotArea = new Rectangle2D[n];
    17
    this.subplotAreas = new Rectangle2D[n];
    Differences
    Expression1Expression2Difference
    subplotAreasubplotAreasVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression this.subplotArea is a field being modified, and thus it cannot be parameterized
    Expression this.subplotAreas is a field being modified, and thus it cannot be parameterized
    17
    this.subplotAreas = new Rectangle2D[n];
    18
    double x = adjustedPlotArea.getX();
    18
    double x = adjustedPlotArea.getX();
    19
    double y = adjustedPlotArea.getY();
    19
    double y = adjustedPlotArea.getY();
    20
    double usableSize = 0.0;
    20
    double usableSize = 0.0;
    21
    if (orientation == PlotOrientation.VERTICAL)
    21
    if (orientation == PlotOrientation.VERTICAL)
    22
    usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    22
    usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    23
    else if (orientation == PlotOrientation.HORIZONTAL)
    23
    else if (orientation == PlotOrientation.HORIZONTAL)
    24
    usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    24
    usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    25
    for (int i = 0; i < n; i++)
    25
    for (int i = 0; i < n; i++)
    26
    CategoryPlot plot = (CategoryPlot)this.subplots.get(i);
    26
    CategoryPlot plot = (CategoryPlot)this.subplots.get(i);
    26
    XYPlot plot = (XYPlot)this.subplots.get(i);
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.CategoryPlotorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.CategoryPlotorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.CategoryPlotorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (CategoryPlot)this.subplots.get(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (XYPlot)this.subplots.get(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26
    XYPlot plot = (XYPlot)this.subplots.get(i);
    27
    if (orientation == PlotOrientation.VERTICAL)
    27
    if (orientation == PlotOrientation.VERTICAL)
    28
    double w = usableSize * plot.getWeight() / this.totalWeight;
    28
    double w = usableSize * plot.getWeight() / this.totalWeight;
    28
    double w = usableSize * plot.getWeight() / this.totalWeight;
    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 int getWeight()
    28
    double w = usableSize * plot.getWeight() / this.totalWeight;
    29
    this.subplotArea[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight());
    29
    this.subplotArea[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight());
    29
    this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight());
    Differences
    Expression1Expression2Difference
    subplotAreasubplotAreasVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression this.subplotArea cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression this.subplotAreas cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29
    this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight());
    30
    x = x + w + this.gap;
    30
    x = x + w + this.gap;
    31
    else if (orientation == PlotOrientation.HORIZONTAL)
    31
    else if (orientation == PlotOrientation.HORIZONTAL)
    32
    double h = usableSize * plot.getWeight() / this.totalWeight;
    32
    double h = usableSize * plot.getWeight() / this.totalWeight;
    32
    double h = usableSize * plot.getWeight() / this.totalWeight;
    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 int getWeight()
    32
    double h = usableSize * plot.getWeight() / this.totalWeight;
    33
    this.subplotArea[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h);
    33
    this.subplotArea[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h);
    33
    this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h);
    Differences
    Expression1Expression2Difference
    subplotAreasubplotAreasVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression this.subplotArea cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression this.subplotAreas cannot be parameterized, because it has dependencies to/from statements that will be extracted
    33
    this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h);
    34
    y = y + h + this.gap;
    34
    y = y + h + this.gap;
    35
    AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotArea[i], null);
    35
    AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotArea[i], null);
    35
    AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotAreas[i], null);
    Differences
    Expression1Expression2Difference
    subplotAreasubplotAreasVARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.CategoryPlotorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression this.subplotArea cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression this.subplotAreas cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) protected org.jfree.chart.axis.AxisSpace calculateDomainAxisSpace(java.awt.Graphics2D, java.awt.geom.Rectangle2D, org.jfree.chart.axis.AxisSpace)
    35
    AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotAreas[i], null);
    36
    space.ensureAtLeast(subSpace);
    36
    space.ensureAtLeast(subSpace);
    37
    return space;
    37
    return space;
    Precondition Violations (13)
    Row Violation
    1Expression this.subplotArea is a field being modified, and thus it cannot be parameterized
    2Expression this.subplotAreas is a field being modified, and thus it cannot be parameterized
    3Expression (CategoryPlot)this.subplots.get(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression (XYPlot)this.subplots.get(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) public int getWeight()
    6Expression this.subplotArea cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression this.subplotAreas cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) public int getWeight()
    9Expression this.subplotArea cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression this.subplotAreas cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression this.subplotArea cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression this.subplotAreas cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) protected org.jfree.chart.axis.AxisSpace calculateDomainAxisSpace(java.awt.Graphics2D, java.awt.geom.Rectangle2D, org.jfree.chart.axis.AxisSpace)