AxisSpace space = new AxisSpace(); PlotOrientation orientation = getOrientation(); // work out the space required by the domain axis... AxisSpace fixed = getFixedDomainAxisSpace(); if (fixed != null) { if (orientation == PlotOrientation.HORIZONTAL) { space.setLeft(fixed.getLeft()); space.setRight(fixed.getRight()); } else if (orientation == PlotOrientation.VERTICAL) { space.setTop(fixed.getTop()); space.setBottom(fixed.getBottom()); } } else { ValueAxis xAxis = getDomainAxis(); RectangleEdge xEdge = Plot.resolveDomainAxisLocation( getDomainAxisLocation(), orientation); if (xAxis != null) { space = xAxis.reserveSpace(g2, this, plotArea, xEdge, space); } } Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); // work out the maximum height or width of the non-shared axes... int n = this.subplots.size(); this.subplotAreas = new Rectangle2D[n]; double x = adjustedPlotArea.getX(); double y = adjustedPlotArea.getY(); double usableSize = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); } else if (orientation == PlotOrientation.VERTICAL) { 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.HORIZONTAL) { 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.VERTICAL) { 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.calculateRangeAxisSpace(g2, this.subplotAreas[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/CombinedDomainXYPlot.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
        // work out the space required by the domain axis...
3
        // work out the space required by the domain axis...
4
        AxisSpace fixed = getFixedDomainAxisSpace();
4
        AxisSpace fixed = getFixedRangeAxisSpace();
5
        if (fixed != null) {
5
        if (fixed != null) {
6
            if (orientation == PlotOrientation.HORIZONTAL) {
6
            if (orientation == PlotOrientation.VERTICAL) {
7
                space.setLeft(fixed.getLeft());
7
                space.setLeft(fixed.getLeft());
8
                space.setRight(fixed.getRight());
8
                space.setRight(fixed.getRight());
9
            }
9
            }
10
            else if (orientation == PlotOrientation.VERTICAL) {
10
            else if (orientation == PlotOrientation.HORIZONTAL) {
11
                space.setTop(fixed.getTop());
11
                space.setTop(fixed.getTop());
12
                space.setBottom(fixed.getBottom());
12
                space.setBottom(fixed.getBottom());
13
            }
13
            }
14
        }
14
        }
15
        else {
15
        else {
16
            ValueAxis xAxis = getDomainAxis();
16
            ValueAxis valueAxis = getRangeAxis();
17
            RectangleEdge xEdge = Plot.resolveDomainAxisLocation(
17
            RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
18
                    getDomainAxisLocation(), orientation
18
                getRangeAxisLocation(), orientation
19
);
19
            );
20
            if (xAxis != null) {
20
            if (valueAxis != null) {
21
                space = xAxis.reserveSpace(g2, this, plotArea, xEdge,
21
                space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
22
 space);
22
                        space);
23
            }
23
            }
24
        }
24
        }
25
        Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
25
        Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
26
        // 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...
27
        int n = this.subplots.size();
27
        int n = this.subplots.size();
28
        // calculate plotAreas of all sub-plots, maximum vertical/horizontal
29
        // axis width/height
28
        this.subplotAreas = new Rectangle2D[n];
30
        this.subplotAreas = new Rectangle2D[n];
29
        double x = adjustedPlotArea.getX();
31
        double x = adjustedPlotArea.getX();
30
        double y = adjustedPlotArea.getY();
32
        double y = adjustedPlotArea.getY();
31
        double usableSize = 0.0;
33
        double usableSize = 0.0;
32
        if (orientation == PlotOrientation.HORIZONTAL) {
34
        if (orientation == PlotOrientation.VERTICAL) {
33
            usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
35
            usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
34
        }
36
        }
35
        else if (orientation == PlotOrientation.VERTICAL) {
37
        else if (orientation == PlotOrientation.HORIZONTAL) {
36
            usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
38
            usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
37
        }
39
        }
38
        for (int i = 0; i < n; i++) {
40
        for (int i = 0; i < n; i++) {
39
            XYPlot plot = (XYPlot) this.subplots.get(i);
41
            XYPlot plot = (XYPlot) this.subplots.get(i);
40
            // calculate sub-plot area
42
            // calculate sub-plot area
41
            if (orientation == PlotOrientation.HORIZONTAL) {
43
            if (orientation == PlotOrientation.VERTICAL) {
42
                double w = usableSize * plot.getWeight() / this.totalWeight;
44
                double w = usableSize * plot.getWeight() / this.totalWeight;
43
                this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
45
                this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
44
                        adjustedPlotArea.getHeight());
46
                        adjustedPlotArea.getHeight());
45
                x = x + w + this.gap;
47
                x = x + w + this.gap;
46
            }
48
            }
47
            else if (orientation == PlotOrientation.VERTICAL) {
49
            else if (orientation == PlotOrientation.HORIZONTAL) {
48
                double h = usableSize * plot.getWeight() / this.totalWeight;
50
                double h = usableSize * plot.getWeight() / this.totalWeight;
49
                this.subplotAreas[i] = new Rectangle2D.Double(x, y,
51
                this.subplotAreas[i] = new Rectangle2D.Double(x, y,
50
                        adjustedPlotArea.getWidth(), h);
52
                        adjustedPlotArea.getWidth(), h);
51
                y = y + h + this.gap;
53
                y = y + h + this.gap;
52
            }
54
            }
53
            AxisSpace subSpace = plot.calculateRangeAxisSpace(g2,
55
            AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
54
                    this.subplotAreas[i], null);
56
                    this.subplotAreas[i], null);
55
            space.ensureAtLeast(subSpace);
57
            space.ensureAtLeast(subSpace);
56
        }
58
        }
57
        return space;
59
        return space;
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)4.1
Clones locationClones are in different classes having the same super class
Number of node comparisons232
  1. {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)380.8
    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 = getFixedDomainAxisSpace();
    3
    AxisSpace fixed = getFixedDomainAxisSpace();
    3
    AxisSpace fixed = getFixedRangeAxisSpace();
    Differences
    Expression1Expression2Difference
    getFixedDomainAxisSpacegetFixedRangeAxisSpaceMETHOD_INVOCATION_NAME_MISMATCH
    3
    AxisSpace fixed = getFixedRangeAxisSpace();
    4
    if (fixed != null)
    4
    if (fixed != null)
    5
    if (orientation == PlotOrientation.HORIZONTAL)
    5
    if (orientation == PlotOrientation.HORIZONTAL)
    5
    if (orientation == PlotOrientation.VERTICAL)
    Differences
    Expression1Expression2Difference
    HORIZONTALVERTICALVARIABLE_NAME_MISMATCH
    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.VERTICAL)
    8
    else if (orientation == PlotOrientation.VERTICAL)
    8
    else if (orientation == PlotOrientation.HORIZONTAL)
    Differences
    Expression1Expression2Difference
    VERTICALHORIZONTALVARIABLE_NAME_MISMATCH
    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 xAxis = getDomainAxis();
    11
    ValueAxis xAxis = getDomainAxis();
    11
    ValueAxis valueAxis = getRangeAxis();
    Differences
    Expression1Expression2Difference
    xAxisvalueAxisVARIABLE_NAME_MISMATCH
    getDomainAxisgetRangeAxisMETHOD_INVOCATION_NAME_MISMATCH
    11
    ValueAxis valueAxis = getRangeAxis();
    12
    RectangleEdge xEdge = Plot.resolveDomainAxisLocation(getDomainAxisLocation(), orientation);
    12
    RectangleEdge xEdge = Plot.resolveDomainAxisLocation(getDomainAxisLocation(), orientation);
    12
    RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(getRangeAxisLocation(), orientation);
    Differences
    Expression1Expression2Difference
    xEdgevalueEdgeVARIABLE_NAME_MISMATCH
    getDomainAxisLocationgetRangeAxisLocationMETHOD_INVOCATION_NAME_MISMATCH
    resolveDomainAxisLocationresolveRangeAxisLocationMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression Plot.resolveDomainAxisLocation(getDomainAxisLocation(),orientation) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Plot.resolveRangeAxisLocation(getRangeAxisLocation(),orientation) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(getRangeAxisLocation(), orientation);
    13
    if (xAxis != null)
    13
    if (xAxis != null)
    13
    if (valueAxis != null)
    Differences
    Expression1Expression2Difference
    xAxisvalueAxisVARIABLE_NAME_MISMATCH
    13
    if (valueAxis != null)
    14
    space = xAxis.reserveSpace(g2, this, plotArea, xEdge, space);
    14
    space = xAxis.reserveSpace(g2, this, plotArea, xEdge, space);
    14
    space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, space);
    Differences
    Expression1Expression2Difference
    xEdgevalueEdgeVARIABLE_NAME_MISMATCH
    xAxisvalueAxisVARIABLE_NAME_MISMATCH
    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.subplotAreas = new Rectangle2D[n];
    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.HORIZONTAL)
    21
    if (orientation == PlotOrientation.HORIZONTAL)
    21
    if (orientation == PlotOrientation.VERTICAL)
    Differences
    Expression1Expression2Difference
    HORIZONTALVERTICALVARIABLE_NAME_MISMATCH
    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.VERTICAL)
    23
    else if (orientation == PlotOrientation.VERTICAL)
    23
    else if (orientation == PlotOrientation.HORIZONTAL)
    Differences
    Expression1Expression2Difference
    VERTICALHORIZONTALVARIABLE_NAME_MISMATCH
    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
    XYPlot plot = (XYPlot)this.subplots.get(i);
    26
    XYPlot plot = (XYPlot)this.subplots.get(i);
    27
    if (orientation == PlotOrientation.HORIZONTAL)
    27
    if (orientation == PlotOrientation.HORIZONTAL)
    27
    if (orientation == PlotOrientation.VERTICAL)
    Differences
    Expression1Expression2Difference
    HORIZONTALVERTICALVARIABLE_NAME_MISMATCH
    27
    if (orientation == PlotOrientation.VERTICAL)
    28
    double w = usableSize * plot.getWeight() / this.totalWeight;
    28
    double w = usableSize * plot.getWeight() / this.totalWeight;
    29
    this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight());
    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.VERTICAL)
    31
    else if (orientation == PlotOrientation.VERTICAL)
    31
    else if (orientation == PlotOrientation.HORIZONTAL)
    Differences
    Expression1Expression2Difference
    VERTICALHORIZONTALVARIABLE_NAME_MISMATCH
    31
    else if (orientation == PlotOrientation.HORIZONTAL)
    32
    double h = usableSize * plot.getWeight() / this.totalWeight;
    32
    double h = usableSize * plot.getWeight() / this.totalWeight;
    33
    this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h);
    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.calculateRangeAxisSpace(g2, this.subplotAreas[i], null);
    35
    AxisSpace subSpace = plot.calculateRangeAxisSpace(g2, this.subplotAreas[i], null);
    35
    AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotAreas[i], null);
    Differences
    Expression1Expression2Difference
    calculateRangeAxisSpacecalculateDomainAxisSpaceMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression plot.calculateRangeAxisSpace(g2,this.subplotAreas[i],null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression plot.calculateDomainAxisSpace(g2,this.subplotAreas[i],null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    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 (4)
    Row Violation
    1Expression Plot.resolveDomainAxisLocation(getDomainAxisLocation(),orientation) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression Plot.resolveRangeAxisLocation(getRangeAxisLocation(),orientation) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression plot.calculateRangeAxisSpace(g2,this.subplotAreas[i],null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression plot.calculateDomainAxisSpace(g2,this.subplotAreas[i],null) cannot be parameterized, because it has dependencies to/from statements that will be extracted