DefaultCategoryDataset dataset = new DefaultCategoryDataset(); JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRenderer(1, new LineAndShapeRenderer()); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success);
DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(1, new XYLineAndShapeRenderer()); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/CategoryPlotTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/XYPlotTests.java
Method name: void test1654215() Method name: void test1654215()
Number of AST nodes: 12 Number of AST nodes: 12
1
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
1
DefaultXYDataset dataset = new DefaultXYDataset();
2
        JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
2
        JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
3
                dataset, PlotOrientation.VERTICAL, true, false, false);
3
                dataset, PlotOrientation.VERTICAL, true, false, false);
4
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
4
        XYPlot plot = (XYPlot) chart.getPlot();
5
        plot.setRenderer(1, new LineAndShapeRenderer());
5
        plot.setRenderer(1, new XYLineAndShapeRenderer());
6
        boolean success = false;
6
        boolean success = false;
7
        try {
7
        try {
8
            BufferedImage image = new BufferedImage(200 , 100,
8
            BufferedImage image = new BufferedImage(200 , 100, 
9
                    BufferedImage.TYPE_INT_RGB);
9
                    BufferedImage.TYPE_INT_RGB);
10
            Graphics2D g2 = image.createGraphics();
10
            Graphics2D g2 = image.createGraphics();
11
            chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
11
            chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
12
            g2.dispose();
12
            g2.dispose();
13
            success = true;
13
            success = true;
14
        }
14
        }
15
        catch (Exception e) {
15
        catch (Exception e) {
16
            e.printStackTrace();
16
            e.printStackTrace();
17
            success = false;
17
            success = false;
18
        }
18
        }
19
        assertTrue(success);
19
        assertTrue(success);
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)0.2
Clones locationClones are in different classes having the same super class
Number of node comparisons52
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)135.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    1
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    1
    DefaultXYDataset dataset = new DefaultXYDataset();
    Differences
    Expression1Expression2Difference
    org.jfree.data.category.DefaultCategoryDatasetorg.jfree.data.xy.DefaultXYDatasetSUBCLASS_TYPE_MISMATCH
    org.jfree.data.category.DefaultCategoryDatasetorg.jfree.data.xy.DefaultXYDatasetSUBCLASS_TYPE_MISMATCH
    org.jfree.data.category.DefaultCategoryDatasetorg.jfree.data.xy.DefaultXYDatasetSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new DefaultCategoryDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new DefaultXYDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    DefaultXYDataset dataset = new DefaultXYDataset();
    2
    JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false);
    2
    JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false);
    2
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false);
    Differences
    Expression1Expression2Difference
    org.jfree.data.category.DefaultCategoryDatasetorg.jfree.data.xy.DefaultXYDatasetSUBCLASS_TYPE_MISMATCH
    createLineChartcreateXYLineChartMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression ChartFactory.createLineChart("Title","X","Y",dataset,PlotOrientation.VERTICAL,true,false,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ChartFactory.createXYLineChart("Title","X","Y",dataset,PlotOrientation.VERTICAL,true,false,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false);
    3
    CategoryPlot plot = (CategoryPlot)chart.getPlot();
    3
    CategoryPlot plot = (CategoryPlot)chart.getPlot();
    3
    XYPlot plot = (XYPlot)chart.getPlot();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.CategoryPlotorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.CategoryPlotorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.CategoryPlotorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (CategoryPlot)chart.getPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (XYPlot)chart.getPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    XYPlot plot = (XYPlot)chart.getPlot();
    4
    plot.setRenderer(1, new LineAndShapeRenderer());
    4
    plot.setRenderer(1, new LineAndShapeRenderer());
    4
    plot.setRenderer(1, new XYLineAndShapeRenderer());
    Differences
    Expression1Expression2Difference
    org.jfree.chart.renderer.category.LineAndShapeRendererorg.jfree.chart.renderer.xy.XYLineAndShapeRendererSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.CategoryPlotorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new LineAndShapeRenderer() cannot be unified with expression new XYLineAndShapeRenderer() , because common superclass type org.jfree.chart.renderer.AbstractRenderer cannot be passed as an argument to public void setRenderer(int, org.jfree.chart.renderer.category.CategoryItemRenderer)
    Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) public void setRenderer(int, org.jfree.chart.renderer.category.CategoryItemRenderer) , public void setRenderer(int, org.jfree.chart.renderer.xy.XYItemRenderer)
    4
    plot.setRenderer(1, new XYLineAndShapeRenderer());
    5
    boolean success = false;
    5
    boolean success = false;
    6
    try
    6
    try
    7
    BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
    7
    BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
    8
    Graphics2D g2 = image.createGraphics();
    8
    Graphics2D g2 = image.createGraphics();
    9
    chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
    9
    chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
    10
    g2.dispose();
    10
    g2.dispose();
    11
    success = true;
    11
    success = true;
    12
    assertTrue(success);
    12
    assertTrue(success);
    Precondition Violations (8)
    Row Violation
    1Expression new DefaultCategoryDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new DefaultXYDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression ChartFactory.createLineChart("Title","X","Y",dataset,PlotOrientation.VERTICAL,true,false,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression ChartFactory.createXYLineChart("Title","X","Y",dataset,PlotOrientation.VERTICAL,true,false,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression (CategoryPlot)chart.getPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression (XYPlot)chart.getPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression new LineAndShapeRenderer() cannot be unified with expression new XYLineAndShapeRenderer() , because common superclass type org.jfree.chart.renderer.AbstractRenderer cannot be passed as an argument to public void setRenderer(int, org.jfree.chart.renderer.category.CategoryItemRenderer)
    8Expression plot cannot be unified with expression plot , because common superclass org.jfree.chart.plot.Plot does not declare member(s) public void setRenderer(int, org.jfree.chart.renderer.category.CategoryItemRenderer) , public void setRenderer(int, org.jfree.chart.renderer.xy.XYItemRenderer)