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);
DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(null); 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/XYPlotTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/XYPlotTests.java
Method name: void test1654215() Method name: void testDrawRangeGridlines()
Number of AST nodes: 12 Number of AST nodes: 12
1
DefaultXYDataset dataset = new DefaultXYDataset();
1
DefaultXYDataset dataset = new DefaultXYDataset();
2
        JFreeChart chart = ChartFactory.createXYLineChart("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
        XYPlot plot = (XYPlot) chart.getPlot();
4
        XYPlot plot = (XYPlot) chart.getPlot();
5
        plot.setRenderer(1, new XYLineAndShapeRenderer());
5
        plot.setRenderer(null);
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 cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are declared in the same class
Number of node comparisons52
  1. {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)61.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultXYDataset dataset = new DefaultXYDataset();
    1
    DefaultXYDataset dataset = new DefaultXYDataset();
    2
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false);
    2
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false);
    3
    XYPlot plot = (XYPlot)chart.getPlot();
    3
    XYPlot plot = (XYPlot)chart.getPlot();
    4
    plot.setRenderer(1, new XYLineAndShapeRenderer());
    4
    plot.setRenderer(1, new XYLineAndShapeRenderer());
    4
    plot.setRenderer(null);
    Differences
    Expression1Expression2Difference
    plot.setRenderer(1,new XYLineAndShapeRenderer())plot.setRenderer(null)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression plot.setRenderer(1,new XYLineAndShapeRenderer()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression plot.setRenderer(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression plot.setRenderer(1,new XYLineAndShapeRenderer()) is a void method call, and thus it cannot be parameterized
    Expression plot.setRenderer(null) is a void method call, and thus it cannot be parameterized
    4
    plot.setRenderer(null);
    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 (4)
    Row Violation
    1Expression plot.setRenderer(1,new XYLineAndShapeRenderer()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression plot.setRenderer(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression plot.setRenderer(1,new XYLineAndShapeRenderer()) is a void method call, and thus it cannot be parameterized
    4Expression plot.setRenderer(null) is a void method call, and thus it cannot be parameterized