CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); CategoryDataset dataset = plot.getDataset(rendererIndex); if (dataset != null) { int columns = dataset.getColumnCount(); int rows = dataset.getRowCount(); double space = 0.0; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); double categoryMargin = 0.0; double currentItemMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } if (rows > 1) { currentItemMargin = getItemMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin); if ((rows * columns) > 0) { state.setBarWidth(Math.min(used / (rows * columns), maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } }
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 groups = this.seriesToGroupMap.getGroupCount(); int categories = data.getColumnCount(); int columns = groups * categories; double categoryMargin = 0.0; double itemMargin = 0.0; if (categories > 1) { categoryMargin = xAxis.getCategoryMargin(); } if (groups > 1) { itemMargin = getItemMargin(); } double used = space * (1 - xAxis.getLowerMargin() - xAxis.getUpperMargin() - categoryMargin - itemMargin); 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/BarRenderer.java File path: /jfreechart-1.0.10/src/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java
Method name: void calculateBarWidth(CategoryPlot, Rectangle2D, int, CategoryItemRendererState) Method name: void calculateBarWidth(CategoryPlot, Rectangle2D, int, CategoryItemRendererState)
Number of AST nodes: 22 Number of AST nodes: 23
1
CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
1
CategoryAxis xAxis = plot.getDomainAxisForDataset(rendererIndex);
2
        CategoryDataset dataset = plot.getDataset(rendererIndex);
2
        CategoryDataset data = plot.getDataset(rendererIndex);
3
        if (dataset != null) {
3
        if (data != null) {
4
            int columns = dataset.getColumnCount();
4
            
5
            int rows = dataset.getRowCount();
6
            double space = 0.0;
7
            PlotOrientation orientation = plot.getOrientation()
5
PlotOrientation orientation = plot.getOrientation();
8
;
6
            double space = 0.0;
9
            if (orientation == PlotOrientation.HORIZONTAL) {
7
            if (orientation == PlotOrientation.HORIZONTAL) {
10
                space = dataArea.getHeight();
8
                space = dataArea.getHeight();
11
            }
9
            }
12
            else if (orientation == PlotOrientation.VERTICAL) {
10
            else if (orientation == PlotOrientation.VERTICAL) {
13
                space = dataArea.getWidth();
11
                space = dataArea.getWidth();
14
            }
12
            }
15
            double maxWidth = space * getMaximumBarWidth();
13
            double maxWidth = space * getMaximumBarWidth();
14
            int groups = this.seriesToGroupMap.getGroupCount();
15
            int categories = data.getColumnCount();
16
            int columns = groups * categories;
16
            double categoryMargin = 0.0;
17
            double categoryMargin = 0.0;
17
            double currentItemMargin = 0.0;
18
            double itemMargin = 0.0;
18
            if (columns > 1) {
19
            if (categories > 1) {
19
                categoryMargin = domainAxis.getCategoryMargin();
20
                categoryMargin = xAxis.getCategoryMargin();
20
            }
21
            }
21
            if (rows > 1) {
22
            if (groups > 1) {
22
                currentItemMargin = getItemMargin();
23
                itemMargin = getItemMargin();
23
            }
24
            }
24
            double used = space * (1 - domainAxis.getLowerMargin()
25
            double used = space * (1 - xAxis.getLowerMargin()
25
                                     - domainAxis.getUpperMargin()
26
                                     - xAxis.getUpperMargin()
26
                                     - categoryMargin - currentItemMargin);
27
                                     - categoryMargin - itemMargin);
27
            if ((rows * columns) > 0) {
28
            if (columns > 0) {
28
                state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
29
                state.setBarWidth(Math.min(used / columns, maxWidth));
29
            }
30
            }
30
            else {
31
            else {
31
                state.setBarWidth(Math.min(used, maxWidth));
32
                state.setBarWidth(Math.min(used, maxWidth));
32
            }
33
            }
33
        }
34
        }
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)2.1
Clones locationClones are in different classes having the same super class
Number of node comparisons155
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements19
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)101.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                        
    1
    CategoryAxis xAxis = plot.getDomainAxisForDataset(rendererIndex);
    1
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
                                                                                                                              
    2
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    2
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    2
    CategoryDataset data = plot.getDataset(rendererIndex);
    Differences
    Expression1Expression2Difference
    datasetdataVARIABLE_NAME_MISMATCH
    2
    CategoryDataset data = plot.getDataset(rendererIndex);
    3
    if (dataset != null)
    3
    if (dataset != null)
    3
    if (data != null)
    Differences
    Expression1Expression2Difference
    datasetdataVARIABLE_NAME_MISMATCH
    3
    if (data != null)
    4
    int columns = dataset.getColumnCount();
    4
    int columns = dataset.getColumnCount();
    Preondition Violations
    Unmatched statement int columns=dataset.getColumnCount(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                    
    5
    int rows = dataset.getRowCount();
    5
    int rows = dataset.getRowCount();
    Preondition Violations
    Unmatched statement int rows=dataset.getRowCount(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                        
    6
    double space = 0.0;
    5
    double space = 0.0;
    7
    PlotOrientation orientation = plot.getOrientation();
    4
    PlotOrientation orientation = plot.getOrientation();
    8
    if (orientation == PlotOrientation.HORIZONTAL)
    6
    if (orientation == PlotOrientation.HORIZONTAL)
    9
    space = dataArea.getHeight();
    7
    space = dataArea.getHeight();
    10
    else if (orientation == PlotOrientation.VERTICAL)
    8
    else if (orientation == PlotOrientation.VERTICAL)
    11
    space = dataArea.getWidth();
    9
    space = dataArea.getWidth();
    12
    double maxWidth = space * getMaximumBarWidth();
    10
    double maxWidth = space * getMaximumBarWidth();
                                                                                                              
    11
    int groups = this.seriesToGroupMap.getGroupCount();
                                                                                      
    12
    int categories = data.getColumnCount();
    Preondition Violations
    Unmatched statement int categories=data.getColumnCount(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    int categories = data.getColumnCount();
                                                                            
    13
    int columns = groups * categories;
    13
    double categoryMargin = 0.0;
    13
    double categoryMargin = 0.0;
    15
    double itemMargin = 0.0;
    Differences
    Expression1Expression2Difference
    categoryMarginitemMarginVARIABLE_NAME_MISMATCH
    15
    double itemMargin = 0.0;
    14
    double currentItemMargin = 0.0;
    14
    double currentItemMargin = 0.0;
    14
    double categoryMargin = 0.0;
    Differences
    Expression1Expression2Difference
    currentItemMargincategoryMarginVARIABLE_NAME_MISMATCH
    14
    double categoryMargin = 0.0;
    15
    if (columns > 1)
    15
    if (columns > 1)
    16
    if (categories > 1)
    Differences
    Expression1Expression2Difference
    columnscategoriesVARIABLE_NAME_MISMATCH
    16
    if (categories > 1)
    16
    categoryMargin = domainAxis.getCategoryMargin();
    16
    categoryMargin = domainAxis.getCategoryMargin();
    17
    categoryMargin = xAxis.getCategoryMargin();
    Differences
    Expression1Expression2Difference
    domainAxisxAxisVARIABLE_NAME_MISMATCH
    17
    categoryMargin = xAxis.getCategoryMargin();
    17
    if (rows > 1)
    17
    if (rows > 1)
    18
    if (groups > 1)
    Differences
    Expression1Expression2Difference
    rowsgroupsVARIABLE_NAME_MISMATCH
    18
    if (groups > 1)
    18
    currentItemMargin = getItemMargin();
    18
    currentItemMargin = getItemMargin();
    19
    itemMargin = getItemMargin();
    Differences
    Expression1Expression2Difference
    currentItemMarginitemMarginVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression currentItemMargin cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression itemMargin cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19
    itemMargin = getItemMargin();
    19
    double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin);
    19
    double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin);
    20
    double used = space * (1 - xAxis.getLowerMargin() - xAxis.getUpperMargin() - categoryMargin - itemMargin);
    Differences
    Expression1Expression2Difference
    domainAxisxAxisVARIABLE_NAME_MISMATCH
    currentItemMarginitemMarginVARIABLE_NAME_MISMATCH
    domainAxisxAxisVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression currentItemMargin cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression itemMargin cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20
    double used = space * (1 - xAxis.getLowerMargin() - xAxis.getUpperMargin() - categoryMargin - itemMargin);
    20
    if ((rows * columns) > 0)
    20
    if ((rows * columns) > 0)
    21
    if (columns > 0)
    Differences
    Expression1Expression2Difference
    (rows * columns)columnsTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression (rows * columns) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression columns cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21
    if (columns > 0)
    21
    state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
    21
    state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
    22
    state.setBarWidth(Math.min(used / columns, maxWidth));
    Differences
    Expression1Expression2Difference
    (rows * columns)columnsTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression (rows * columns) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression columns cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22
    state.setBarWidth(Math.min(used / columns, maxWidth));
    else
    else
    22
    state.setBarWidth(Math.min(used, maxWidth));
    23
    state.setBarWidth(Math.min(used, maxWidth));
    Precondition Violations (11)
    Row Violation
    1Unmatched statement int columns=dataset.getColumnCount(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement int rows=dataset.getRowCount(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement int categories=data.getColumnCount(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Expression currentItemMargin cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression itemMargin cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression currentItemMargin cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression itemMargin cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression (rows * columns) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression columns cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression (rows * columns) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression columns cannot be parameterized, because it has dependencies to/from statements that will be extracted