CategoryAxis xAxis = plot.getDomainAxisForDataset(rendererIndex); CategoryDataset data = plot.getDataset(rendererIndex); if (data != null) { PlotOrientation orientation = plot.getOrientation(); double space = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); int columns = data.getColumnCount(); double categoryMargin = 0.0; if (columns > 1) { categoryMargin = xAxis.getCategoryMargin(); } double used = space * (1 - xAxis.getLowerMargin() - xAxis.getUpperMargin() - categoryMargin); if (columns > 0) { state.setBarWidth(Math.min(used / columns, maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } }
CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); CategoryDataset data = plot.getDataset(rendererIndex); if (data != null) { PlotOrientation orientation = plot.getOrientation(); double space = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); int columns = data.getColumnCount(); double categoryMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin); if (columns > 0) { state.setBarWidth(Math.min(used / columns, maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/category/StackedBarRenderer.java File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/category/StackedBarRenderer3D.java
Method name: void calculateBarWidth(CategoryPlot, Rectangle2D, int, CategoryItemRendererState) Method name: void calculateBarWidth(CategoryPlot, Rectangle2D, int, CategoryItemRendererState)
Number of AST nodes: 18 Number of AST nodes: 18
1
CategoryAxis xAxis = plot.getDomainAxisForDataset(rendererIndex);
1
CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
2
        CategoryDataset data = plot.getDataset(rendererIndex);
2
        CategoryDataset data = plot.getDataset(rendererIndex);
3
        if (data != null) {
3
        if (data != null) {
4
            PlotOrientation orientation = plot.getOrientation();
4
            PlotOrientation orientation = plot.getOrientation();
5
            double space = 0.0;
5
            double space = 0.0;
6
            if (orientation == PlotOrientation.HORIZONTAL) {
6
            if (orientation == PlotOrientation.HORIZONTAL) {
7
                space = dataArea.getHeight();
7
                space = dataArea.getHeight();
8
            }
8
            }
9
            else if (orientation == PlotOrientation.VERTICAL) {
9
            else if (orientation == PlotOrientation.VERTICAL) {
10
                space = dataArea.getWidth();
10
                space = dataArea.getWidth();
11
            }
11
            }
12
            double maxWidth = space * getMaximumBarWidth();
12
            double maxWidth = space * getMaximumBarWidth();
13
            int columns = data.getColumnCount();
13
            int columns = data.getColumnCount();
14
            double categoryMargin = 0.0;
14
            double categoryMargin = 0.0;
15
            if (columns > 1) {
15
            if (columns > 1) {
16
                categoryMargin = xAxis.getCategoryMargin();
16
                categoryMargin = domainAxis.getCategoryMargin();
17
            }
17
            }
18
            double used = space * (1 - xAxis.getLowerMargin()
18
            double used = space * (1 - domainAxis.getLowerMargin()
19
                                     - xAxis.getUpperMargin()
19
                                     - domainAxis.getUpperMargin()
20
                                     - categoryMargin);
20
                                     - categoryMargin);
21
            if (columns > 0) {
21
            if (columns > 0) {
22
                state.setBarWidth(Math.min(used / columns, maxWidth));
22
                state.setBarWidth(Math.min(used / columns, maxWidth));
23
            }
23
            }
24
            else {
24
            else {
25
                state.setBarWidth(Math.min(used, maxWidth));
25
                state.setBarWidth(Math.min(used, maxWidth));
26
            }
26
            }
27
        }
27
        }
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 in different classes having the same super class
Number of node comparisons99
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements17
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)40.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                              
    1
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    1
    CategoryAxis xAxis = plot.getDomainAxisForDataset(rendererIndex);
                                                                                                                                        
    2
    CategoryDataset data = plot.getDataset(rendererIndex);
    2
    CategoryDataset data = plot.getDataset(rendererIndex);
    3
    if (data != null)
    3
    if (data != null)
    4
    PlotOrientation orientation = plot.getOrientation();
    4
    PlotOrientation orientation = plot.getOrientation();
    5
    double space = 0.0;
    5
    double space = 0.0;
    6
    if (orientation == PlotOrientation.HORIZONTAL)
    6
    if (orientation == PlotOrientation.HORIZONTAL)
    7
    space = dataArea.getHeight();
    7
    space = dataArea.getHeight();
    8
    else if (orientation == PlotOrientation.VERTICAL)
    8
    else if (orientation == PlotOrientation.VERTICAL)
    9
    space = dataArea.getWidth();
    9
    space = dataArea.getWidth();
    10
    double maxWidth = space * getMaximumBarWidth();
    10
    double maxWidth = space * getMaximumBarWidth();
    11
    int columns = data.getColumnCount();
    11
    int columns = data.getColumnCount();
    12
    double categoryMargin = 0.0;
    12
    double categoryMargin = 0.0;
    13
    if (columns > 1)
    13
    if (columns > 1)
    14
    categoryMargin = xAxis.getCategoryMargin();
    14
    categoryMargin = xAxis.getCategoryMargin();
    14
    categoryMargin = domainAxis.getCategoryMargin();
    Differences
    Expression1Expression2Difference
    xAxisdomainAxisVARIABLE_NAME_MISMATCH
    14
    categoryMargin = domainAxis.getCategoryMargin();
    15
    double used = space * (1 - xAxis.getLowerMargin() - xAxis.getUpperMargin() - categoryMargin);
    15
    double used = space * (1 - xAxis.getLowerMargin() - xAxis.getUpperMargin() - categoryMargin);
    15
    double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin);
    Differences
    Expression1Expression2Difference
    xAxisdomainAxisVARIABLE_NAME_MISMATCH
    xAxisdomainAxisVARIABLE_NAME_MISMATCH
    15
    double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin);
    16
    if (columns > 0)
    16
    if (columns > 0)
    17
    state.setBarWidth(Math.min(used / columns, maxWidth));
    17
    state.setBarWidth(Math.min(used / columns, maxWidth));
    else
    else
    18
    state.setBarWidth(Math.min(used, maxWidth));
    18
    state.setBarWidth(Math.min(used, maxWidth));
    Precondition Violations (0)
    Row Violation