Java 类org.jfree.data.xy.DefaultTableXYDataset 实例源码

项目:parabuild-ci    文件:DefaultTableXYDatasetTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    final DefaultTableXYDataset d1 = new DefaultTableXYDataset();
    final XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.1);
    s1.add(2.0, 2.2);
    d1.addSeries(s1);

    final DefaultTableXYDataset d2 = new DefaultTableXYDataset();
    final XYSeries s2 = new XYSeries("Series 1", true, false);
    s2.add(1.0, 1.1);
    s2.add(2.0, 2.2);
    d2.addSeries(s2);

    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));

    s1.add(3.0, 3.3);
    assertFalse(d1.equals(d2));

    s2.add(3.0, 3.3);
    assertTrue(d1.equals(d2));

}
项目:parabuild-ci    文件:TableXYDatasetTests.java   
/**
 * Tests the auto-pruning feature.
 */
public void testAutoPrune() {

    // WITH AUTOPRUNING
    final DefaultTableXYDataset dataset = new DefaultTableXYDataset(true);
    dataset.addSeries(createSeriesA());
    assertEquals(2, dataset.getItemCount());  // should be 2 items
    dataset.addSeries(createSeriesB());
    assertEquals(2, dataset.getItemCount());  // still 2
    dataset.removeSeries(1);
    assertEquals(1, dataset.getItemCount());  // 1 value pruned.

    // WITHOUT AUTOPRUNING
    final DefaultTableXYDataset dataset2 = new DefaultTableXYDataset(true);
    dataset2.addSeries(createSeriesA());
    assertEquals(2, dataset2.getItemCount());  // should be 2 items
    dataset2.addSeries(createSeriesB());
    assertEquals(2, dataset2.getItemCount());  // still 2
    dataset2.removeSeries(1);
    assertEquals(1, dataset2.getItemCount());  // still 2.

}
项目:parabuild-ci    文件:StackedXYAreaRenderer2Tests.java   
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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) {
        success = false;
    }
    assertTrue(success);
}
项目:parabuild-ci    文件:StackedXYAreaRenderer2Tests.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
public void testFindRangeBounds() {
    TableXYDataset dataset 
            = RendererXYPackageTests.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, 
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:parabuild-ci    文件:DatasetUtilitiesTests.java   
/**
 * Creates a sample dataset for testing purposes.
 * 
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;  
}
项目:parabuild-ci    文件:DefaultTableXYDatasetTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    DefaultTableXYDataset d1 = new DefaultTableXYDataset();
    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.1);
    s1.add(2.0, 2.2);
    d1.addSeries(s1);

    DefaultTableXYDataset d2 = new DefaultTableXYDataset();
    XYSeries s2 = new XYSeries("Series 1", true, false);
    s2.add(1.0, 1.1);
    s2.add(2.0, 2.2);
    d2.addSeries(s2);

    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));

    s1.add(3.0, 3.3);
    assertFalse(d1.equals(d2));

    s2.add(3.0, 3.3);
    assertTrue(d1.equals(d2));

}
项目:parabuild-ci    文件:TableXYDatasetTests.java   
/**
 * Tests the auto-pruning feature.
 */
public void testAutoPrune() {

    // WITH AUTOPRUNING
    DefaultTableXYDataset dataset = new DefaultTableXYDataset(true);
    dataset.addSeries(createSeriesA());
    assertEquals(2, dataset.getItemCount());  // should be 2 items
    dataset.addSeries(createSeriesB());
    assertEquals(2, dataset.getItemCount());  // still 2
    dataset.removeSeries(1);
    assertEquals(1, dataset.getItemCount());  // 1 value pruned.

    // WITHOUT AUTOPRUNING
    DefaultTableXYDataset dataset2 = new DefaultTableXYDataset(true);
    dataset2.addSeries(createSeriesA());
    assertEquals(2, dataset2.getItemCount());  // should be 2 items
    dataset2.addSeries(createSeriesB());
    assertEquals(2, dataset2.getItemCount());  // still 2
    dataset2.removeSeries(1);
    assertEquals(1, dataset2.getItemCount());  // still 2.

}
项目:ccu-historian    文件:StackedXYAreaRenderer2Test.java   
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
@Test
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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) {
        success = false;
    }
    assertTrue(success);
}
项目:ccu-historian    文件:StackedXYAreaRenderer2Test.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:ccu-historian    文件:DatasetUtilitiesTest.java   
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}
项目:jfreechart    文件:StackedXYAreaRenderer2Test.java   
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
@Test
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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) {
        success = false;
    }
    assertTrue(success);
}
项目:jfreechart    文件:StackedXYAreaRenderer2Test.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:jfreechart    文件:DatasetUtilsTest.java   
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}
项目:aya-lang    文件:StackedXYAreaRenderer2Test.java   
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
@Test
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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) {
        success = false;
    }
    assertTrue(success);
}
项目:aya-lang    文件:StackedXYAreaRenderer2Test.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:aya-lang    文件:DatasetUtilitiesTest.java   
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}
项目:eamaster    文件:LinePlot.java   
/**
 * Generate the individual series for the specified key.
 * 
 * @param key the key identifying which result to plot
 * @param dataset the dataset to store the generated series
 */
protected void generateIndividualSeries(ResultKey key, 
        DefaultTableXYDataset dataset) {
    for (Accumulator accumulator : controller.get(key)) {
        if (!accumulator.keySet().contains(metric)) {
            continue;
        }

        XYSeries series = new XYSeries(key, false, false);

        for (int i=0; i<accumulator.size(metric); i++) {
            series.add((Number)accumulator.get("NFE", i), 
                    (Number)accumulator.get(metric, i));
        }

        dataset.addSeries(series);
    }
}
项目:pmgraph    文件:GraphFactory.java   
/**
 * Initialize a series for a port or IP graph with all the values set to zero and
 * add it to the database and to the hashmap containing all the series.
 * 
 * @param dataset
 * @param series
 * @param renderer
 * @param roundedStart
 * @param name
 * @param requestParams
 */
private void series2DataSet(DefaultTableXYDataset dataset,
        Map<DataPoint, float[]> series, XYItemRenderer renderer,
        long roundedStart, String name, RequestParams requestParams, int resolution)
{
    // Put the series into the graph
    for (DataPoint seriesId : series.keySet())
    {
        XYSeries xySeries = new XYSeries(seriesId.getSeriesId() + name,
                true, false);
        float[] values = series.get(seriesId);
        long j = 0;

        for (float val : values)
        {
            xySeries.add(Long.valueOf(roundedStart + j * resolution), Float
                    .valueOf(val));
            j++;
        }
        dataset.addSeries(xySeries);
        renderer.setSeriesPaint(dataset.getSeriesCount() - 1, 
                seriesId.getSeriesColor());
    }
}
项目:HTML5_WebSite    文件:StackedXYAreaChartDemo1.java   
/**
   * Creates a sample dataset.
   * 
   * @return a sample dataset.
   */
  protected  TableXYDataset createDataset(boolean isDemo) {
      if (isDemo){
      DefaultTableXYDataset dataset = new DefaultTableXYDataset();

      XYSeries s1 = new XYSeries("Series 1", true, false);
      s1.add(5.0, 5.0);
      s1.add(10.0, 15.5);
      s1.add(15.0, 9.5);
      s1.add(20.0, 7.5);
      dataset.addSeries(s1);

      XYSeries s2 = new XYSeries("Series 2", true, false);
      s2.add(5.0, 5.0);
      s2.add(10.0, 15.5);
      s2.add(15.0, 9.5);
      s2.add(20.0, 3.5);
      dataset.addSeries(s2);

      return dataset;}
else return super.createDataset(false);

  }
项目:psi-probe    文件:StandardSeriesProvider.java   
@Override
public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection,
    HttpServletRequest request) {

  String seriesParam = ServletRequestUtils.getStringParameter(request, "sp", null);
  for (int i = 0; i < statNames.size(); i++) {
    String statName = statNames.get(i);
    if (seriesParam != null) {
      statName = MessageFormat.format(statName, seriesParam);
    }
    List<XYDataItem> stats = statsCollection.getStats(statName);
    if (stats != null) {
      String series =
          ServletRequestUtils.getStringParameter(request, "s" + (i + 1) + "l", "series" + i);
      dataset.addSeries(toSeries(series, stats));
    }
  }
}
项目:psi-probe    文件:ConnectorSeriesProvider.java   
@Override
public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection,
    HttpServletRequest request) {

  // get Connector name from the request
  String connectorName = ServletRequestUtils.getStringParameter(request, "cn", null);

  // type of statistic to be displayed
  String statType = ServletRequestUtils.getStringParameter(request, "st", null);

  // Series legend
  String series1Legend = ServletRequestUtils.getStringParameter(request, "sl", "");

  if (connectorName != null && statType != null) {
    List<XYDataItem> stats =
        statsCollection.getStats("stat.connector." + connectorName + "." + statType);
    if (stats != null) {
      dataset.addSeries(toSeries(series1Legend, stats));
    }
  }
}
项目:jablus    文件:AreaGraphPanel.java   
public void addSeries(String name, double[] data, Paint linePaint){
    DefaultTableXYDataset dataset = (DefaultTableXYDataset)chart.getXYPlot().getDataset(0);
    XYSeries series = new XYSeries(name, false, false);
    if(data != null){
        for(int j = 0; j < data.length; j++){
            series.add(new Integer(j), new Double(data[j]));
        }
        seriesLengths.put(name, data.length);
    }
    else
        seriesLengths.put(name, 0);

    dataset.addSeries(series);
    seriesIds.put(name, new Integer(seriesCount));
    chart.getXYPlot().getRenderer().setSeriesPaint(seriesCount, linePaint);
    seriesCount++;
    // Set renerer
}
项目:hiketools    文件:Profile.java   
private static XYDataset createDataset(TrackPoint points[]) {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();
    XYSeries series = new XYSeries("Series 1", true, false);
    TrackPoint prev = null;
    double d = 0;
    for (TrackPoint pt: points) {
        if (prev != null) {
            d += EarthGeometry.distance(pt, prev);
        }
        double km = d/1000.0;
        if (series.indexOf(km) < 0) {
            series.add(km, pt.getH());
        }
        prev = pt;
    }
    dataset.addSeries(series);
    System.out.println("Distance: " + d);
    return dataset;
}
项目:nabs    文件:StackedXYAreaRenderer2Tests.java   
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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) {
        success = false;
    }
    assertTrue(success);
}
项目:nabs    文件:StackedXYAreaRenderer2Tests.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
public void testFindRangeBounds() {
    TableXYDataset dataset 
            = RendererXYPackageTests.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, 
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:nabs    文件:DatasetUtilitiesTests.java   
/**
 * Creates a sample dataset for testing purposes.
 * 
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;  
}
项目:nabs    文件:DefaultTableXYDatasetTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    DefaultTableXYDataset d1 = new DefaultTableXYDataset();
    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.1);
    s1.add(2.0, 2.2);
    d1.addSeries(s1);

    DefaultTableXYDataset d2 = new DefaultTableXYDataset();
    XYSeries s2 = new XYSeries("Series 1", true, false);
    s2.add(1.0, 1.1);
    s2.add(2.0, 2.2);
    d2.addSeries(s2);

    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));

    s1.add(3.0, 3.3);
    assertFalse(d1.equals(d2));

    s2.add(3.0, 3.3);
    assertTrue(d1.equals(d2));

}
项目:nabs    文件:TableXYDatasetTests.java   
/**
 * Tests the auto-pruning feature.
 */
public void testAutoPrune() {

    // WITH AUTOPRUNING
    DefaultTableXYDataset dataset = new DefaultTableXYDataset(true);
    dataset.addSeries(createSeriesA());
    assertEquals(2, dataset.getItemCount());  // should be 2 items
    dataset.addSeries(createSeriesB());
    assertEquals(2, dataset.getItemCount());  // still 2
    dataset.removeSeries(1);
    assertEquals(1, dataset.getItemCount());  // 1 value pruned.

    // WITHOUT AUTOPRUNING
    DefaultTableXYDataset dataset2 = new DefaultTableXYDataset(true);
    dataset2.addSeries(createSeriesA());
    assertEquals(2, dataset2.getItemCount());  // should be 2 items
    dataset2.addSeries(createSeriesB());
    assertEquals(2, dataset2.getItemCount());  // still 2
    dataset2.removeSeries(1);
    assertEquals(1, dataset2.getItemCount());  // still 2.

}
项目:ECG-Viewer    文件:StackedXYAreaRenderer2Test.java   
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
@Test
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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) {
        success = false;
    }
    assertTrue(success);
}
项目:ECG-Viewer    文件:StackedXYAreaRenderer2Test.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:ECG-Viewer    文件:DatasetUtilitiesTest.java   
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}
项目:astor    文件:StackedXYAreaRenderer2Tests.java   
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), true);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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) {
        success = false;
    }
    assertTrue(success);
}
项目:astor    文件:StackedXYAreaRenderer2Tests.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageTests.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:astor    文件:DatasetUtilitiesTests.java   
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}
项目:astor    文件:DefaultTableXYDatasetTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    DefaultTableXYDataset d1 = new DefaultTableXYDataset();
    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.1);
    s1.add(2.0, 2.2);
    d1.addSeries(s1);

    DefaultTableXYDataset d2 = new DefaultTableXYDataset();
    XYSeries s2 = new XYSeries("Series 1", true, false);
    s2.add(1.0, 1.1);
    s2.add(2.0, 2.2);
    d2.addSeries(s2);

    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));

    s1.add(3.0, 3.3);
    assertFalse(d1.equals(d2));

    s2.add(3.0, 3.3);
    assertTrue(d1.equals(d2));

}
项目:astor    文件:TableXYDatasetTests.java   
/**
 * Tests the auto-pruning feature.
 */
public void testAutoPrune() {

    // WITH AUTOPRUNING
    DefaultTableXYDataset dataset = new DefaultTableXYDataset(true);
    dataset.addSeries(createSeriesA());
    assertEquals(2, dataset.getItemCount());  // should be 2 items
    dataset.addSeries(createSeriesB());
    assertEquals(2, dataset.getItemCount());  // still 2
    dataset.removeSeries(1);
    assertEquals(1, dataset.getItemCount());  // 1 value pruned.

    // WITHOUT AUTOPRUNING
    DefaultTableXYDataset dataset2 = new DefaultTableXYDataset(true);
    dataset2.addSeries(createSeriesA());
    assertEquals(2, dataset2.getItemCount());  // should be 2 items
    dataset2.addSeries(createSeriesB());
    assertEquals(2, dataset2.getItemCount());  // still 2
    dataset2.removeSeries(1);
    assertEquals(1, dataset2.getItemCount());  // still 2.

}
项目:psi-probe-plus    文件:ConnectorSeriesProvider.java   
public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection, HttpServletRequest request) {
    //
    // get Connector name from the request
    //
    String connectorName = ServletRequestUtils.getStringParameter(request, "cn", null);
    //
    // type of statistic to be displayed
    //
    String statType = ServletRequestUtils.getStringParameter(request, "st", null);
    //
    // Series legend
    //
    String series1Legend = ServletRequestUtils.getStringParameter(request, "sl", "");


    if (connectorName != null && statType != null) {
        List l = statsCollection.getStats("stat.connector." + connectorName + "." + statType);
        if (l != null) {
            dataset.addSeries(toSeries(series1Legend, l));
        }
    }
}
项目:group-five    文件:StackedXYAreaRenderer2Test.java   
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
@Test
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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) {
        success = false;
    }
    assertTrue(success);
}
项目:group-five    文件:StackedXYAreaRenderer2Test.java   
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
项目:group-five    文件:DatasetUtilitiesTest.java   
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}