DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart( "Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); assertEquals(axis.getLowerBound(), 0.0, EPSILON); assertEquals(axis.getUpperBound(), 210.0, EPSILON);
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(axis.getLowerBound(), 95.0, EPSILON); assertEquals(axis.getUpperBound(), 205.0, EPSILON);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/axis/junit/NumberAxisTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/axis/junit/NumberAxisTests.java
Method name: void testAutoRange1() Method name: void testAutoRange2()
Number of AST nodes: 8 Number of AST nodes: 9
1
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
1
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
2
        dataset.setValue(100.0, "Row 1", "Column 1");
2
        dataset.setValue(100.0, "Row 1", "Column 1");
3
        dataset.setValue(200.0, "Row 1", "Column 2");
3
        dataset.setValue(200.0, "Row 1", "Column 2");
4
        JFreeChart chart = ChartFactory.createBarChart(
4
        JFreeChart chart = ChartFactory.createLineChart(
5
            "Test", 
6
            "Categories",
5
"Test", "Categories",
7
            "Value",
6
                "Value",
8
            dataset,
9
            PlotOrientation.VERTICAL,
10
            false, 
11
            false,
7
 dataset, PlotOrientation.VERTICAL, false, false,
12
            false
8
                false
13
        );
9
);
14
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
10
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
15
        NumberAxis axis = (NumberAxis) plot.getRangeAxis();
11
        NumberAxis axis = (NumberAxis) plot.getRangeAxis();
12
        axis.setAutoRangeIncludesZero(false);
16
        assertEquals(axis.getLowerBound(), 0.0, EPSILON);    
13
        assertEquals(axis.getLowerBound(), 95.0, EPSILON);    
17
        assertEquals(axis.getUpperBound(), 210.0, EPSILON);
14
        assertEquals(axis.getUpperBound(), 205.0, EPSILON);
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)0.0
Clones locationClones are declared in the same class
Number of node comparisons45
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    1
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    2
    dataset.setValue(100.0, "Row 1", "Column 1");
    2
    dataset.setValue(100.0, "Row 1", "Column 1");
    3
    dataset.setValue(200.0, "Row 1", "Column 2");
    3
    dataset.setValue(200.0, "Row 1", "Column 2");
    4
    JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false);
    4
    JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false);
    4
    JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false);
    Differences
    Expression1Expression2Difference
    createBarChartcreateLineChartMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression ChartFactory.createBarChart("Test","Categories","Value",dataset,PlotOrientation.VERTICAL,false,false,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ChartFactory.createLineChart("Test","Categories","Value",dataset,PlotOrientation.VERTICAL,false,false,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false);
    5
    CategoryPlot plot = (CategoryPlot)chart.getPlot();
    5
    CategoryPlot plot = (CategoryPlot)chart.getPlot();
    6
    NumberAxis axis = (NumberAxis)plot.getRangeAxis();
    6
    NumberAxis axis = (NumberAxis)plot.getRangeAxis();
                                                                                    
    7
    axis.setAutoRangeIncludesZero(false);
    Preondition Violations
    Unmatched statement axis.setAutoRangeIncludesZero(false); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    axis.setAutoRangeIncludesZero(false);
    7
    assertEquals(axis.getLowerBound(), 0.0, EPSILON);
    7
    assertEquals(axis.getLowerBound(), 0.0, EPSILON);
    8
    assertEquals(axis.getLowerBound(), 95.0, EPSILON);
    Differences
    Expression1Expression2Difference
    0.095.0LITERAL_VALUE_MISMATCH
    8
    assertEquals(axis.getLowerBound(), 95.0, EPSILON);
    8
    assertEquals(axis.getUpperBound(), 210.0, EPSILON);
    8
    assertEquals(axis.getUpperBound(), 210.0, EPSILON);
    9
    assertEquals(axis.getUpperBound(), 205.0, EPSILON);
    Differences
    Expression1Expression2Difference
    210.0205.0LITERAL_VALUE_MISMATCH
    9
    assertEquals(axis.getUpperBound(), 205.0, EPSILON);
    Precondition Violations (3)
    Row Violation
    1Expression ChartFactory.createBarChart("Test","Categories","Value",dataset,PlotOrientation.VERTICAL,false,false,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression ChartFactory.createLineChart("Test","Categories","Value",dataset,PlotOrientation.VERTICAL,false,false,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement axis.setAutoRangeIncludesZero(false); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted