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 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 * getMaximumItemWidth(); 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)); } }
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/LevelRenderer.java
Method name: void calculateBarWidth(CategoryPlot, Rectangle2D, int, CategoryItemRendererState) Method name: void calculateItemWidth(CategoryPlot, Rectangle2D, int, CategoryItemRendererState)
Number of AST nodes: 22 Number of AST nodes: 22
1
CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
1
CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
2
        CategoryDataset dataset = plot.getDataset(rendererIndex);
2
        CategoryDataset dataset = plot.getDataset(rendererIndex);
3
        if (dataset != null) {
3
        if (dataset != null) {
4
            int columns = dataset.getColumnCount();
4
            int columns = dataset.getColumnCount();
5
            int rows = dataset.getRowCount();
5
            int rows = dataset.getRowCount();
6
            double space = 0.0;
6
            double space = 0.0;
7
            PlotOrientation orientation = plot.getOrientation();
7
            PlotOrientation orientation = plot.getOrientation();
8
            if (orientation == PlotOrientation.HORIZONTAL) {
8
            if (orientation == PlotOrientation.HORIZONTAL) {
9
                space = dataArea.getHeight();
9
                space = dataArea.getHeight();
10
            }
10
            }
11
            else if (orientation == PlotOrientation.VERTICAL) {
11
            else if (orientation == PlotOrientation.VERTICAL) {
12
                space = dataArea.getWidth();
12
                space = dataArea.getWidth();
13
            }
13
            }
14
            double maxWidth = space * getMaximumBarWidth();
14
            double maxWidth = space * getMaximumItemWidth();
15
            double categoryMargin = 0.0;
15
            double categoryMargin = 0.0;
16
            double currentItemMargin = 0.0;
16
            double currentItemMargin = 0.0;
17
            if (columns > 1) {
17
            if (columns > 1) {
18
                categoryMargin = domainAxis.getCategoryMargin();
18
                categoryMargin = domainAxis.getCategoryMargin();
19
            }
19
            }
20
            if (rows > 1) {
20
            if (rows > 1) {
21
                currentItemMargin = getItemMargin();
21
                currentItemMargin = getItemMargin();
22
            }
22
            }
23
            double used = space * (1 - domainAxis.getLowerMargin()
23
            double used = space * (1 - domainAxis.getLowerMargin()
24
                                     - domainAxis.getUpperMargin()
24
                                     - domainAxis.getUpperMargin()
25
                                     - categoryMargin - currentItemMargin);
25
                                     - categoryMargin - currentItemMargin);
26
            if ((rows * columns) > 0) {
26
            if ((rows * columns) > 0) {
27
                state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
27
                state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
28
            }
28
            }
29
            else {
29
            else {
30
                state.setBarWidth(Math.min(used, maxWidth));
30
                state.setBarWidth(Math.min(used, maxWidth));
31
            }
31
            }
32
        }
32
        }
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)2.0
Clones locationClones are in different classes having the same super class
Number of node comparisons146
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements22
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)53.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    1
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    2
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    2
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    3
    if (dataset != null)
    3
    if (dataset != null)
    4
    int columns = dataset.getColumnCount();
    4
    int columns = dataset.getColumnCount();
    5
    int rows = dataset.getRowCount();
    5
    int rows = dataset.getRowCount();
    6
    double space = 0.0;
    6
    double space = 0.0;
    7
    PlotOrientation orientation = plot.getOrientation();
    7
    PlotOrientation orientation = plot.getOrientation();
    8
    if (orientation == PlotOrientation.HORIZONTAL)
    8
    if (orientation == PlotOrientation.HORIZONTAL)
    9
    space = dataArea.getHeight();
    9
    space = dataArea.getHeight();
    10
    else if (orientation == PlotOrientation.VERTICAL)
    10
    else if (orientation == PlotOrientation.VERTICAL)
    11
    space = dataArea.getWidth();
    11
    space = dataArea.getWidth();
    12
    double maxWidth = space * getMaximumBarWidth();
    12
    double maxWidth = space * getMaximumBarWidth();
    12
    double maxWidth = space * getMaximumItemWidth();
    Differences
    Expression1Expression2Difference
    getMaximumBarWidthgetMaximumItemWidthMETHOD_INVOCATION_NAME_MISMATCH
    12
    double maxWidth = space * getMaximumItemWidth();
    13
    double categoryMargin = 0.0;
    13
    double categoryMargin = 0.0;
    14
    double currentItemMargin = 0.0;
    Differences
    Expression1Expression2Difference
    categoryMargincurrentItemMarginVARIABLE_NAME_MISMATCH
    14
    double currentItemMargin = 0.0;
    14
    double currentItemMargin = 0.0;
    14
    double currentItemMargin = 0.0;
    13
    double categoryMargin = 0.0;
    Differences
    Expression1Expression2Difference
    currentItemMargincategoryMarginVARIABLE_NAME_MISMATCH
    13
    double categoryMargin = 0.0;
    15
    if (columns > 1)
    15
    if (columns > 1)
    16
    categoryMargin = domainAxis.getCategoryMargin();
    16
    categoryMargin = domainAxis.getCategoryMargin();
    17
    if (rows > 1)
    17
    if (rows > 1)
    18
    currentItemMargin = getItemMargin();
    18
    currentItemMargin = getItemMargin();
    19
    double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin);
    19
    double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin);
    20
    if ((rows * columns) > 0)
    20
    if ((rows * columns) > 0)
    21
    state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
    21
    state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
    else
    else
    22
    state.setBarWidth(Math.min(used, maxWidth));
    22
    state.setBarWidth(Math.min(used, maxWidth));
    Precondition Violations (0)
    Row Violation