CloneSet 5

# CloneSet5

Previous CloneSet | Next CloneSet | Back to Main Report

Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length]
--- | --- | --- | --- | ---
121 | 7 | 3 | 0.997 | class_body_declarations[6]

Clone Abstraction | Parameter Bindings

Clone Instance (Click to see clone) | Line Count | Source Line | Source File
--- | --- | --- | ---

1

111

107

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/BarChart3DTests.java

2

122

107

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/BarChartTests.java

3

120

104

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/LineChart3DTests.java

4

120

104

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/LineChartTests.java

5

119

104

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/StackedAreaChartTests.java

6

119

104

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/StackedBarChart3DTests.java

7

121

108

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/StackedBarChartTests.java

Next
Last

Clone Instance
1

Line Count
111

Source Line
107

Source File

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/BarChart3DTests.java

    /**
     * Draws the chart with a null info object to make sure that no exceptions
     * are thrown (a problem that was occurring at one point).
     */
    public void testDrawWithNullInfo() {
      boolean success = false;
      try {
        BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
      }
      catch (Exception
             e) {
        success = false;
      }
      assertTrue(success);
    }

    /**
     * Replaces the dataset and checks that the data range is as expected.
     */
    public void testReplaceDataset() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-30),
                                            new Integer(-20)
                                          },
                                          {
                                            new Integer(-10),
                                            new Integer(10)
                                          },
                                          {
                                            new Integer(20),
                                            new Integer(30)
                                          }
                                        };
      CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);
      LocalListener l = new LocalListener();
      this.chart.addChangeListener(l);
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      plot.setDataset(newData);
      assertEquals(true, l.flag);
      ValueAxis axis = plot.getRangeAxis();
      Range range = axis.getRange();
      assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30);
      assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30);
    }

    /**
     * Check that setting a tool tip generator for a series does override the
     * default generator.
     */
    public void testSetSeriesToolTipGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator();
      renderer.setSeriesToolTipGenerator(0, tt);
      CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
      assertTrue(tt2 == tt);
    }

    /**
     * Check that setting a URL generator for a series does override the
     * default generator.
     */
    public void testSetSeriesURLGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
      renderer.setSeriesItemURLGenerator(0, url1);
      CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
      assertTrue(url2 == url1);
    }

    /**
     * Create a horizontal bar chart with sample data in the range -3 to +3.
     *
     * @return The chart.
     */
    private static JFreeChart createBarChart3D() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-3),
                                            new Integer(-2)
                                          },
                                          {
                                            new Integer(-1),
                                            new Integer(1)
                                          },
                                          {
                                            new Integer(2),
                                            new Integer(3)
                                          }
                                        };
      CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
      // create the chart...
      return ChartFactory.createBarChart3D("Bar Chart 3D", "Domain", "Range", dataset, PlotOrientation.HORIZONTAL, true, true, true);
    }

    /**
     * A chart change listener.
     *
     */
    static class LocalListener implements ChartChangeListener {
      /** A flag. */
      private boolean flag = false;

      /**
       * Event handler.
       *
       * @param event  the event.
       */
      public void chartChanged(ChartChangeEvent event) {
        this.flag = true;
      }
    }

Next
Previous

Clone Instance
2

Line Count
122

Source Line
107

Source File

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/BarChartTests.java

    /**
     * Draws the chart with a null info object to make sure that no exceptions
     * are thrown (a problem that was occurring at one point).
     */
    public void testDrawWithNullInfo() {
      boolean success = false;
      try {
        BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
      }
      catch (Exception
             e) {
        success = false;
      }
      assertTrue(success);
    }

    /**
     * Replaces the chart's dataset and then checks that the new dataset is OK.
     */
    public void testReplaceDataset() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-30),
                                            new Integer(-20)
                                          },
                                          {
                                            new Integer(-10),
                                            new Integer(10)
                                          },
                                          {
                                            new Integer(20),
                                            new Integer(30)
                                          }
                                        };
      CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);
      LocalListener l = new LocalListener();
      this.chart.addChangeListener(l);
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      plot.setDataset(newData);
      assertEquals(true, l.flag);
      ValueAxis axis = plot.getRangeAxis();
      Range range = axis.getRange();
      assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30);
      assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30);
    }

    /**
     * Check that setting a tool tip generator for a series does override the
     * default generator.
     */
    public void testSetSeriesToolTipGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator();
      renderer.setSeriesToolTipGenerator(0, tt);
      CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
      assertTrue(tt2 == tt);
    }

    /**
     * Check that setting a URL generator for a series does override the
     * default generator.
     */
    public void testSetSeriesURLGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
      renderer.setSeriesItemURLGenerator(0, url1);
      CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
      assertTrue(url2 == url1);
    }

    /**
     * Create a bar chart with sample data in the range -3 to +3.
     *
     * @return The chart.
     */
    private static JFreeChart createBarChart() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-3),
                                            new Integer(-2)
                                          },
                                          {
                                            new Integer(-1),
                                            new Integer(1)
                                          },
                                          {
                                            new Integer(2),
                                            new Integer(3)
                                          }
                                        };
      CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
      // create the chart...
      return ChartFactory.createBarChart("Bar Chart", "Domain", "Range", dataset, PlotOrientation.HORIZONTAL, true, // include legend
                                          true, true);
    }

    /**
     * A chart change listener.
     *
     */
    static class LocalListener implements ChartChangeListener {
      /** A flag. */
      private boolean flag = false;

      /**
       * Event handler.
       *
       * @param event  the event.
       */
      public void chartChanged(ChartChangeEvent event) {
        this.flag = true;
      }
    }

Next
Previous

Clone Instance
3

Line Count
120

Source Line
104

Source File

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/LineChart3DTests.java

    /**
     * Draws the chart with a null info object to make sure that no exceptions
     * are thrown (a problem that was occurring at one point).
     */
    public void testDrawWithNullInfo() {
      boolean success = false;
      try {
        BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
      }
      catch (Exception
             e) {
        success = false;
      }
      assertTrue(success);
    }

    /**
     * Replaces the chart's dataset and then checks that the new dataset is OK.
     */
    public void testReplaceDataset() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-30),
                                            new Integer(-20)
                                          },
                                          {
                                            new Integer(-10),
                                            new Integer(10)
                                          },
                                          {
                                            new Integer(20),
                                            new Integer(30)
                                          }
                                        };
      CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);
      LocalListener l = new LocalListener();
      this.chart.addChangeListener(l);
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      plot.setDataset(newData);
      assertEquals(true, l.flag);
      ValueAxis axis = plot.getRangeAxis();
      Range range = axis.getRange();
      assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30);
      assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30);
    }

    /**
     * Check that setting a tool tip generator for a series does override the
     * default generator.
     */
    public void testSetSeriesToolTipGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator();
      renderer.setSeriesToolTipGenerator(0, tt);
      CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
      assertTrue(tt2 == tt);
    }

    /**
     * Check that setting a URL generator for a series does override the
     * default generator.
     */
    public void testSetSeriesURLGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
      renderer.setSeriesItemURLGenerator(0, url1);
      CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
      assertTrue(url2 == url1);
    }

    /**
     * Create a line chart with sample data in the range -3 to +3.
     *
     * @return The chart.
     */
    private static JFreeChart createLineChart3D() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-3),
                                            new Integer(-2)
                                          },
                                          {
                                            new Integer(-1),
                                            new Integer(1)
                                          },
                                          {
                                            new Integer(2),
                                            new Integer(3)
                                          }
                                        };
      CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
      // create the chart...
      return ChartFactory.createLineChart3D("Line Chart", "Domain", "Range", dataset, PlotOrientation.HORIZONTAL, true, // include legend
                                             true, true);
    }

    /**
     * A chart change listener.
     *
     */
    static class LocalListener implements ChartChangeListener {
      /** A flag. */
      private boolean flag = false;

      /**
       * Event handler.
       *
       * @param event  the event.
       */
      public void chartChanged(ChartChangeEvent event) {
        this.flag = true;
      }
    }

Next
Previous

Clone Instance
4

Line Count
120

Source Line
104

Source File

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/LineChartTests.java

    /**
     * Draws the chart with a null info object to make sure that no exceptions
     * are thrown (a problem that was occurring at one point).
     */
    public void testDrawWithNullInfo() {
      boolean success = false;
      try {
        BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
      }
      catch (Exception
             e) {
        success = false;
      }
      assertTrue(success);
    }

    /**
     * Replaces the chart's dataset and then checks that the new dataset is OK.
     */
    public void testReplaceDataset() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-30),
                                            new Integer(-20)
                                          },
                                          {
                                            new Integer(-10),
                                            new Integer(10)
                                          },
                                          {
                                            new Integer(20),
                                            new Integer(30)
                                          }
                                        };
      CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);
      LocalListener l = new LocalListener();
      this.chart.addChangeListener(l);
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      plot.setDataset(newData);
      assertEquals(true, l.flag);
      ValueAxis axis = plot.getRangeAxis();
      Range range = axis.getRange();
      assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30);
      assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30);
    }

    /**
     * Check that setting a tool tip generator for a series does override the
     * default generator.
     */
    public void testSetSeriesToolTipGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator();
      renderer.setSeriesToolTipGenerator(0, tt);
      CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
      assertTrue(tt2 == tt);
    }

    /**
     * Check that setting a URL generator for a series does override the
     * default generator.
     */
    public void testSetSeriesURLGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
      renderer.setSeriesItemURLGenerator(0, url1);
      CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
      assertTrue(url2 == url1);
    }

    /**
     * Create a line chart with sample data in the range -3 to +3.
     *
     * @return The chart.
     */
    private static JFreeChart createLineChart() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-3),
                                            new Integer(-2)
                                          },
                                          {
                                            new Integer(-1),
                                            new Integer(1)
                                          },
                                          {
                                            new Integer(2),
                                            new Integer(3)
                                          }
                                        };
      CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
      // create the chart...
      return ChartFactory.createLineChart("Line Chart", "Domain", "Range", dataset, PlotOrientation.HORIZONTAL, true, // include legend
                                           true, true);
    }

    /**
     * A chart change listener.
     *
     */
    static class LocalListener implements ChartChangeListener {
      /** A flag. */
      private boolean flag = false;

      /**
       * Event handler.
       *
       * @param event  the event.
       */
      public void chartChanged(ChartChangeEvent event) {
        this.flag = true;
      }
    }

Next
Previous

Clone Instance
5

Line Count
119

Source Line
104

Source File

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/StackedAreaChartTests.java

    /**
     * Draws the chart with a null info object to make sure that no exceptions
     * are thrown (a problem that was occurring at one point).
     */
    public void testDrawWithNullInfo() {
      boolean success = false;
      try {
        BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
      }
      catch (Exception
             e) {
        success = false;
      }
      assertTrue(success);
    }

    /**
     * Replaces the dataset and checks that it has changed as expected.
     */
    public void testReplaceDataset() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-30),
                                            new Integer(-20)
                                          },
                                          {
                                            new Integer(-10),
                                            new Integer(10)
                                          },
                                          {
                                            new Integer(20),
                                            new Integer(30)
                                          }
                                        };
      CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);
      LocalListener l = new LocalListener();
      this.chart.addChangeListener(l);
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      plot.setDataset(newData);
      assertEquals(true, l.flag);
      ValueAxis axis = plot.getRangeAxis();
      Range range = axis.getRange();
      assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30);
      assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30);
    }

    /**
     * Check that setting a tool tip generator for a series does override the
     * default generator.
     */
    public void testSetSeriesToolTipGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator();
      renderer.setSeriesToolTipGenerator(0, tt);
      CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
      assertTrue(tt2 == tt);
    }

    /**
     * Check that setting a URL generator for a series does override the
     * default generator.
     */
    public void testSetSeriesURLGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
      renderer.setSeriesItemURLGenerator(0, url1);
      CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
      assertTrue(url2 == url1);
    }

    /**
     * Create a stacked bar chart with sample data in the range -3 to +3.
     *
     * @return The chart.
     */
    private static JFreeChart createChart() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-3),
                                            new Integer(-2)
                                          },
                                          {
                                            new Integer(-1),
                                            new Integer(1)
                                          },
                                          {
                                            new Integer(2),
                                            new Integer(3)
                                          }
                                        };
      CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
      // create the chart...
      return ChartFactory.createStackedAreaChart("Stacked Area Chart", // chart title
                                                  "Domain", "Range", dataset, // data
                                                  PlotOrientation.HORIZONTAL, true, // include legend
                                                  true, true);
    }

    /**
     * A chart change listener.
     */
    static class LocalListener implements ChartChangeListener {
      /** A flag. */
      private boolean flag = false;

      /**
       * Event handler.
       *
       * @param event  the event.
       */
      public void chartChanged(ChartChangeEvent event) {
        this.flag = true;
      }
    }

Next
Previous

Clone Instance
6

Line Count
119

Source Line
104

Source File

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/StackedBarChart3DTests.java

    /**
     * Draws the chart with a null info object to make sure that no exceptions
     * are thrown (a problem that was occurring at one point).
     */
    public void testDrawWithNullInfo() {
      boolean success = false;
      try {
        BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
      }
      catch (Exception
             e) {
        success = false;
      }
      assertTrue(success);
    }

    /**
     * Replaces the dataset and checks that it has changed as expected.
     */
    public void testReplaceDataset() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-30),
                                            new Integer(-20)
                                          },
                                          {
                                            new Integer(-10),
                                            new Integer(10)
                                          },
                                          {
                                            new Integer(20),
                                            new Integer(30)
                                          }
                                        };
      CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);
      LocalListener l = new LocalListener();
      this.chart.addChangeListener(l);
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      plot.setDataset(newData);
      assertEquals(true, l.flag);
      ValueAxis axis = plot.getRangeAxis();
      Range range = axis.getRange();
      assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30);
      assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30);
    }

    /**
     * Check that setting a tool tip generator for a series does override the
     * default generator.
     */
    public void testSetSeriesToolTipGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator();
      renderer.setSeriesToolTipGenerator(0, tt);
      CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
      assertTrue(tt2 == tt);
    }

    /**
     * Check that setting a URL generator for a series does override the
     * default generator.
     */
    public void testSetSeriesURLGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
      renderer.setSeriesItemURLGenerator(0, url1);
      CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
      assertTrue(url2 == url1);
    }

    /**
     * Create a stacked bar chart with sample data in the range -3 to +3.
     *
     * @return The chart.
     */
    private static JFreeChart createChart() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-3),
                                            new Integer(-2)
                                          },
                                          {
                                            new Integer(-1),
                                            new Integer(1)
                                          },
                                          {
                                            new Integer(2),
                                            new Integer(3)
                                          }
                                        };
      CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
      // create the chart...
      return ChartFactory.createStackedBarChart3D("Stacked Bar Chart 3D", // chart title
                                                   "Domain", "Range", dataset, // data
                                                   PlotOrientation.HORIZONTAL, true, // include legend
                                                   true, true);
    }

    /**
     * A chart change listener.
     */
    static class LocalListener implements ChartChangeListener {
      /** A flag. */
      private boolean flag = false;

      /**
       * Event handler.
       *
       * @param event  the event.
       */
      public void chartChanged(ChartChangeEvent event) {
        this.flag = true;
      }
    }

First
Previous

Clone Instance
7

Line Count
121

Source Line
108

Source File

    E:/TSE/Projects-CloneDR/jfreechart-1.0.10/tests/org/jfree/chart/junit/StackedBarChartTests.java

    /**
     * Draws the chart with a null info object to make sure that no exceptions
     * are thrown (a problem that was occurring at one point).
     */
    public void testDrawWithNullInfo() {
      boolean success = false;
      try {
        BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
      }
      catch (Exception
             e) {
        success = false;
      }
      assertTrue(success);
    }

    /**
     * Replaces the dataset and checks that it has changed as expected.
     */
    public void testReplaceDataset() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-30),
                                            new Integer(-20)
                                          },
                                          {
                                            new Integer(-10),
                                            new Integer(10)
                                          },
                                          {
                                            new Integer(20),
                                            new Integer(30)
                                          }
                                        };
      CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);
      LocalListener l = new LocalListener();
      this.chart.addChangeListener(l);
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      plot.setDataset(newData);
      assertEquals(true, l.flag);
      ValueAxis axis = plot.getRangeAxis();
      Range range = axis.getRange();
      assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30);
      assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30);
    }

    /**
     * Check that setting a tool tip generator for a series does override the
     * default generator.
     */
    public void testSetSeriesToolTipGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator();
      renderer.setSeriesToolTipGenerator(0, tt);
      CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
      assertTrue(tt2 == tt);
    }

    /**
     * Check that setting a URL generator for a series does override the
     * default generator.
     */
    public void testSetSeriesURLGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
      renderer.setSeriesItemURLGenerator(0, url1);
      CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
      assertTrue(url2 == url1);
    }

    /**
     * Create a stacked bar chart with sample data in the range -3 to +3.
     *
     * @return The chart.
     */
    private static JFreeChart createChart() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-3),
                                            new Integer(-2)
                                          },
                                          {
                                            new Integer(-1),
                                            new Integer(1)
                                          },
                                          {
                                            new Integer(2),
                                            new Integer(3)
                                          }
                                        };
      CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
      // create the chart...
      return ChartFactory.createStackedBarChart("Stacked Bar Chart", // chart title
                                                 "Domain", "Range", dataset, // data
                                                 PlotOrientation.HORIZONTAL, true, // include legend
                                                 true, true);
    }

    /**
     * A chart change listener.
     */
    static class LocalListener implements ChartChangeListener {
      /** A flag. */
      private boolean flag = false;

      /**
       * Event handler.
       *
       * @param event  the event.
       */
      public void chartChanged(ChartChangeEvent event) {
        this.flag = true;
      }
    }

Clone Abstraction | Parameter Count: 3 | Parameter Bindings

    /**
         * Draws the chart with a null info object to make sure that no exceptions
         * are thrown (a problem that was occurring at one point).
         */
    public void testDrawWithNullInfo() {
      boolean success = false;
      try {
        BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
      }
      catch (Exception
             e) {
        success = false;
      }
      assertTrue(success);
    }

    /**
         * Replaces the dataset and checks that it has changed as expected.
         */
    /**
         * Replaces the chart's dataset and then checks that the new dataset is OK.
         */
    /**
         * Replaces the dataset and checks that the data range is as expected.
         */
    public void testReplaceDataset() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-30),
                                            new Integer(-20)
                                          },
                                          {
                                            new Integer(-10),
                                            new Integer(10)
                                          },
                                          {
                                            new Integer(20),
                                            new Integer(30)
                                          }
                                        };
      CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);
      LocalListener l = new LocalListener();
      this.chart.addChangeListener(l);
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      plot.setDataset(newData);
      assertEquals(true, l.flag);
      ValueAxis axis = plot.getRangeAxis();
      Range range = axis.getRange();
      assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30);
      assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30);
    }

    /**
         * Check that setting a tool tip generator for a series does override the
         * default generator.
         */
    public void testSetSeriesToolTipGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator();
      renderer.setSeriesToolTipGenerator(0, tt);
      CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
      assertTrue(tt2 == tt);
    }

    /**
         * Check that setting a URL generator for a series does override the
         * default generator.
         */
    public void testSetSeriesURLGenerator() {
      CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
      CategoryItemRenderer renderer = plot.getRenderer();
      StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
      renderer.setSeriesItemURLGenerator(0, url1);
      CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
      assertTrue(url2 == url1);
    }

    /**
         * Create a stacked bar chart with sample data in the range -3 to +3.
         *
         * @return The chart.
         */
    /**
         * Create a line chart with sample data in the range -3 to +3.
         *
         * @return The chart.
         */
    /**
         * Create a bar chart with sample data in the range -3 to +3.
         *
         * @return The chart.
         */
    /**
         * Create a horizontal bar chart with sample data in the range -3 to +3.
         *
         * @return The chart.
         */
    private static JFreeChart  [[#variable1ab0c180]]() {
      // create a dataset...
      Number[][] data = new Integer[][] {
                                          {
                                            new Integer(-3),
                                            new Integer(-2)
                                          },
                                          {
                                            new Integer(-1),
                                            new Integer(1)
                                          },
                                          {
                                            new Integer(2),
                                            new Integer(3)
                                          }
                                        };
      CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
      // create the chart...
      return ChartFactory. [[#variable150af180]]( [[#variable1ab12720]], // chart title
                                                  "Domain", "Range", dataset, // data
                                                  PlotOrientation.HORIZONTAL, true, // include legend
                                                  true, true);
    }

    /**
         * A chart change listener.
         */
    /**
         * A chart change listener.
         *
         */
    static class LocalListener implements ChartChangeListener {
      /** A flag. */
      private boolean flag = false;

      /**
               * Event handler.
               *
               * @param event  the event.
               */
      public void chartChanged(ChartChangeEvent event) {
        this.flag = true;
      }
    }

CloneAbstraction

Parameter Bindings
Parameter Index | Clone Instance | Parameter Name | Value
--- | --- | --- | ---

1

1

`[[#1ab0c180]]`

    createBarChart3D

1

2

`[[#1ab0c180]]`

    createBarChart

1

3

`[[#1ab0c180]]`

    createLineChart3D

1

4

`[[#1ab0c180]]`

    createLineChart

1

5

`[[#1ab0c180]]`

    createChart

1

6

`[[#1ab0c180]]`

    createChart

1

7

`[[#1ab0c180]]`

    createChart

2

1

`[[#150af180]]`

    createBarChart3D

2

2

`[[#150af180]]`

    createBarChart

2

3

`[[#150af180]]`

    createLineChart3D

2

4

`[[#150af180]]`

    createLineChart

2

5

`[[#150af180]]`

    createStackedAreaChart

2

6

`[[#150af180]]`

    createStackedBarChart3D

2

7

`[[#150af180]]`

    createStackedBarChart

3

1

`[[#1ab12720]]`

    "Bar Chart 3D"

3

2

`[[#1ab12720]]`

    "Bar Chart"

3

3

`[[#1ab12720]]`

    "Line Chart"

3

4

`[[#1ab12720]]`

    "Line Chart"

3

5

`[[#1ab12720]]`

    "Stacked Area Chart"

3

6

`[[#1ab12720]]`

    "Stacked Bar Chart 3D"

3

7

`[[#1ab12720]]`

    "Stacked Bar Chart"