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

项目:passatuto    文件:HitStatistic.java   
public static void writeROCCurves(File outputFile, TreeMap<String, HitStatistic> hits) throws Exception{

        XYSeriesCollection dataset = new XYSeriesCollection();

        for(Entry<String, HitStatistic> e:hits.entrySet()){
            File txtFile=new File(outputFile.getAbsolutePath().replaceAll(".jpg","_"+e.getKey().split("-")[2]+".txt"));
            BufferedWriter bw=new BufferedWriter(new FileWriter(txtFile));
            XYSeries series= new XYSeries(e.getKey());
            bw.write("false positive rate\tsensitivity");
            bw.newLine();
            List<double[]> roc=e.getValue().getROCAverage();
            for(double[] r:roc){
                bw.write(r[0]+"\t"+r[1]);
                bw.newLine();
                series.add(r[0],r[1]);
            }
            dataset.addSeries(series);
            bw.close();
        }


        final JFreeChart chart =ChartFactory.createXYLineChart("ROCCurve",  "false positive rate", "sensitivity", dataset);
        ChartUtilities.saveChartAsJPEG(outputFile, chart, 1000, 400);
    }
项目:Neural-Network-Programming-with-Java-SecondEdition    文件:Chart.java   
private void addSeries(double[][] data,String[] seriesLabel,int xcolumn,Paint[] color){
    int length = data.length;
    int numberOfSeries = data[0].length-1;
    //int currentSize = seriesColor.size();

    for (int j = 0; j < numberOfSeries+1; j++) {
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        XYSeries series = new XYSeries(seriesLabel[0],false);
        if(j==xcolumn)
            continue;
        else{
            seriesColor.add(color[(j>=xcolumn)?j-1:j]);

            for(int i=0;i<length;i++){
                series.add( data[i][xcolumn], data[i][j] ,false);
            }
            seriesCollection.addSeries(series);
        }
        dataset.add(seriesCollection);
    }
}
项目:AgentWorkbench    文件:ThreadInfoStorageScrollPane.java   
/**
 * Instantiates a new thread info scroll pane.
 *
 * @param deltaCollection the delta collection
 * @param totalCollection the total collection
 * @param popup the popup
 * @param frameTitle the frame title
 */
public ThreadInfoStorageScrollPane(XYSeriesCollection deltaCollection, XYSeriesCollection totalCollection, XYSeriesCollection loadCollection, boolean popup, String frameTitle, Object extraObject) {       
    super();
    this.showDelta = true;
    this.showTotal = true;
    this.showSystemTime = true;
    this.showUserTime = true;
    this.popup = popup;
    this.showLegend = popup;
    this.frameTitle = frameTitle;
    this.deltaCollection = deltaCollection;
    this.totalCollection = totalCollection;
    this.loadCollection = loadCollection;
    this.extraObject = extraObject;
    initialize();
}
项目:rapidminer    文件:DistributionPlotter.java   
private XYDataset createNumericalDataSet() {
    XYSeriesCollection dataSet = new XYSeriesCollection();
    int translatedPlotColumn = translateToModelColumn(plotColumn);
    double start = model.getLowerBound(translatedPlotColumn);
    double end = model.getUpperBound(translatedPlotColumn);
    double stepSize = (end - start) / (NUMBER_OF_STEPS - 1);
    for (int classIndex : model.getClassIndices()) {
        XYSeries series = new XYSeries(model.getClassName(classIndex));
        ContinuousDistribution distribution = (ContinuousDistribution) model.getDistribution(classIndex,
                translatedPlotColumn);
        for (double currentValue = start; currentValue < end; currentValue += stepSize) {
            double probability = distribution.getProbability(currentValue);
            if (!Double.isNaN(probability)) {
                series.add(currentValue, distribution.getProbability(currentValue));
            }
        }
        dataSet.addSeries(series);
    }
    return dataSet;
}
项目:ts-benchmark    文件:ChartBizUtil.java   
/**
 * 生成导入图表
 * @param dbName 目标数据库名称
 * @param loadBatchId 导入批次
 * @param path 附件路径
 */
public static void generateLoadDataChart(String dbName,long loadBatchId){
    String path=getChartRootPath(dbName+"_LoadDataPerform");
    System.out.println(path);
    XYSeries values = new XYSeries(dbName);
    List<Map<String, Object>> list = BizDBUtils.selectListBySqlAndParam("select pps from ts_load_record where load_batch_id=?",loadBatchId);
    System.out.println(list);
    if(list!=null&&list.size()>0){
        for(int i=0;i<list.size();i++){
            Map<String, Object> map = list.get(i);
            values.add(i+1,((Number)map.get("pps")).doubleValue());
        }
    }
    XYSeriesCollection mCollection = new XYSeriesCollection();
    mCollection.addSeries(values);
    JFreeChart mChart= createXYLineChart("数据导入吞吐量折线图", "次数","speed(points/sec)",mCollection);
    saveAsFile(mChart,path, 12000, 800);
}
项目:ts-benchmark    文件:ChartBizUtil.java   
public static void generateThroughputPerformChart(String dbName,long performBatchId){
    String path=getChartRootPath(dbName+"_ThroughputPerform");
    System.out.println(path);
    XYSeries values = new XYSeries(dbName);
    List<Map<String, Object>> list = BizDBUtils.selectListBySqlAndParam("select success_times,timeout_avg  from ts_timeout_perform where  perform_batch_id=? and load_type=99",performBatchId);
    if(list!=null&&list.size()>0){
        for(int i=0;i<list.size();i++){
            Map<String, Object> map = list.get(i);
            double timeout=((Number)map.get("timeout_avg")).doubleValue();
            double successTimes=((Number)map.get("success_times")).doubleValue();
            if(successTimes==0){
                values.add(i+1,0);
            }else{
                values.add(i+1,successTimes*(TimeUnit.SECONDS.toMicros(1)/timeout));
            }
        }
    }
    XYSeriesCollection mCollection = new XYSeriesCollection();
    mCollection.addSeries(values);
    JFreeChart mChart= createXYLineChart("数据吞吐量折线图", "请求次数","吞吐量(requests/sec)",mCollection);
    //saveAsFile(mChart,path, 1200, 800);
    saveAsFile(mChart,path, 2400, 800);

}
项目:jaer    文件:NetPlotter.java   
public XYPlot layerRaster(Collection<Spike> spikes,Layer lay)
    {
//        throw new UnsupportedOperationException("This is broken for now!");

        // Add the data
        Iterator<Spike> itr=spikes.iterator();
        XYSeries data=new XYSeries("Events");
        for (int i=0; i<spikes.size(); i++)
        {   Spike evt=itr.next();
            if (evt.layer==lay.ixLayer)
                data.add((float)evt.time/1000,evt.addr);
        }
        XYDataset raster = new XYSeriesCollection(data);

        //SamplingXYLineAndShapeRenderer renderer = new SamplingXYLineAndShapeRenderer(false, true);
        XYDotRenderer renderer = new XYDotRenderer();
        renderer.setDotWidth(2);
        renderer.setDotHeight(5);

        return new XYPlot(raster, null, new NumberAxis("Layer "+lay.ixLayer), renderer);

    }
项目:Proyecto-DASI    文件:xyLine.java   
public static void main(String arg[]){
    XYSeries series = new XYSeries("Average Weight");
    series.add(20, 20);
    series.add(40, 25);
    series.add(55, 50);
    series.add(70, 65);

//  series.add(20.0, 20.0);
//  series.add(40.0, 25.0);
//  series.add(55.0, 50.0);
//  series.add(70.0, 65.0);
    XYDataset xyDataset = new XYSeriesCollection(series);
    JFreeChart chart = ChartFactory.createXYLineChart
              ("XYLine Chart using JFreeChart", "Age", "Weight", xyDataset, PlotOrientation.VERTICAL, true, true, false);
    ChartFrame frame1=new ChartFrame("XYLine Chart",chart);
    frame1.setVisible(true);
    frame1.setSize(300,300);
    }
项目:parabuild-ci    文件:ScatterPlotTests.java   
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(10.0, 10.0);
    series1.add(20.0, 20.0);
    series1.add(30.0, 30.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    this.chart.getXYPlot().setDataset(dataset);
    assertEquals(true, l.flag);
    ValueAxis axis = this.chart.getXYPlot().getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around 10: "
               + range.getLowerBound(), range.getLowerBound() <= 10);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
项目:parabuild-ci    文件:ScatterPlotTests.java   
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return the chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    // create the chart...
    return ChartFactory.createScatterPlot(
        "Scatter Plot",  // chart title
        "Domain",
        "Range",
        dataset,         // data
        PlotOrientation.VERTICAL,
        true,            // include legend
        true,            // tooltips
        false            // urls
    );

}
项目:parabuild-ci    文件:CombinedDomainXYPlotTests.java   
/**
 * Creates a sample dataset.
 *
 * @return Series 2.
 */
private XYDataset createDataset2() {

    // create dataset 2...
    XYSeries series2 = new XYSeries("Series 3");

    series2.add(10.0, 16853.2);
    series2.add(20.0, 19642.3);
    series2.add(30.0, 18253.5);
    series2.add(40.0, 15352.3);
    series2.add(50.0, 13532.0);
    series2.add(100.0, 12635.3);
    series2.add(110.0, 13998.2);
    series2.add(120.0, 11943.2);
    series2.add(130.0, 16943.9);
    series2.add(140.0, 17843.2);
    series2.add(150.0, 16495.3);
    series2.add(160.0, 17943.6);
    series2.add(170.0, 18500.7);
    series2.add(180.0, 19595.9);

    return new XYSeriesCollection(series2);

}
项目:parabuild-ci    文件:CombinedRangeXYPlotTests.java   
/**
 * Creates a sample dataset.
 *
 * @return Series 2.
 */
private XYDataset createDataset2() {

    // create dataset 2...
    XYSeries series2 = new XYSeries("Series 3");

    series2.add(10.0, 16853.2);
    series2.add(20.0, 19642.3);
    series2.add(30.0, 18253.5);
    series2.add(40.0, 15352.3);
    series2.add(50.0, 13532.0);
    series2.add(100.0, 12635.3);
    series2.add(110.0, 13998.2);
    series2.add(120.0, 11943.2);
    series2.add(130.0, 16943.9);
    series2.add(140.0, 17843.2);
    series2.add(150.0, 16495.3);
    series2.add(160.0, 17943.6);
    series2.add(170.0, 18500.7);
    series2.add(180.0, 19595.9);

    return new XYSeriesCollection(series2);

}
项目:parabuild-ci    文件:ValueAxisTests.java   
/**
 * Tests the the lower and upper margin settings produce the expected results.
 */
public void testAxisMargins() {
    XYSeries series = new XYSeries("S1");
    series.add(100.0, 1.1);
    series.add(200.0, 2.2);
    XYSeriesCollection dataset = new XYSeriesCollection(series);
    dataset.setIntervalWidth(0.0);
    JFreeChart chart = ChartFactory.createScatterPlot(
        "Title", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false
    );
    ValueAxis domainAxis = chart.getXYPlot().getDomainAxis();
    Range r = domainAxis.getRange();
    assertTrue(NumberUtils.equal(110.0, r.getLength()));
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertTrue(NumberUtils.equal(120.0, r.getLength()));
}
项目:parabuild-ci    文件:DatasetUtilitiesTests.java   
/**
 * Creates a dataset for testing.
 * 
 * @return A dataset.
 */
private XYDataset createXYDataset1() {
    XYSeries series1 = new XYSeries("S1");
    series1.add(1.0, 100.0);
    series1.add(2.0, 101.0);
    series1.add(3.0, 102.0);
    XYSeries series2 = new XYSeries("S2");
    series2.add(1.0, 103.0);
    series2.add(2.0, null);
    series2.add(3.0, 105.0);
    XYSeriesCollection result = new XYSeriesCollection();
    result.addSeries(series1);
    result.addSeries(series2);
    result.setIntervalWidth(0.0);
    return result;
}
项目:parabuild-ci    文件:MovingAverage.java   
/**
 * Creates a new {@link XYDataset} containing the moving averages of each series in the
 * <code>source</code> dataset.
 *
 * @param source  the source dataset.
 * @param suffix  the string to append to source series names to create target series names.
 * @param period  the averaging period.
 * @param skip  the length of the initial skip period.
 *
 * @return The dataset.
 */
public static XYDataset createMovingAverage(XYDataset source, String suffix,
                                            double period, double skip) {

    // check arguments
    if (source == null) {
        throw new IllegalArgumentException(
            "MovingAverage.createMovingAverage(...) : null source (XYDataset)."
        );
    }

    final XYSeriesCollection result = new XYSeriesCollection();

    for (int i = 0; i < source.getSeriesCount(); i++) {
        final XYSeries s = createMovingAverage(source, i, source.getSeriesName(i) + suffix,
                                         period, skip);
        result.addSeries(s);
    }

    return result;

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

    final XYSeries s1 = new XYSeries("Series");
    s1.add(1.0, 1.1);
    XYSeriesCollection c1 = new XYSeriesCollection();
    c1.addSeries(s1);
    final XYSeries s2 = new XYSeries("Series");
    s2.add(1.0, 1.1);
    XYSeriesCollection c2 = new XYSeriesCollection();
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));
    assertTrue(c2.equals(c1));

    c1.addSeries(new XYSeries("Empty Series"));
    assertFalse(c1.equals(c2));

    c2.addSeries(new XYSeries("Empty Series"));
    assertTrue(c1.equals(c2));

}
项目:parabuild-ci    文件:RegressionTests.java   
/**
 * Checks the results of an OLS regression on sample dataset 1 AFTER converting it to
 * an XYSeries.
 */
public void testOLSRegression1b() {

    final double[][] data = createSampleData1();

    final XYSeries series = new XYSeries("Test");
    for (int i = 0; i < 11; i++) {
        series.add(data[i][0], data[i][1]);
    }
    final XYDataset ds = new XYSeriesCollection(series);
    final double[] result2 = Regression.getOLSRegression(ds, 0);

    assertEquals(.25680930, result2[0], 0.0000001);
    assertEquals(0.72792106, result2[1], 0.0000001);

}
项目:parabuild-ci    文件:RegressionTests.java   
/**
 * Checks the results of a power regression on sample dataset 1 AFTER converting it to
 * an XYSeries.
 */
public void testPowerRegression1b() {

    final double[][] data = createSampleData1();

    final XYSeries series = new XYSeries("Test");
    for (int i = 0; i < 11; i++) {
        series.add(data[i][0], data[i][1]);
    }
    final XYDataset ds = new XYSeriesCollection(series);
    final double[] result = Regression.getPowerRegression(ds, 0);

    assertEquals(0.91045813, result[0], 0.0000001);
    assertEquals(0.88918346, result[1], 0.0000001);

}
项目:parabuild-ci    文件:RegressionTests.java   
/**
 * Checks the results of an OLS regression on sample dataset 2 AFTER converting it to
 * an XYSeries.
 */
public void testOLSRegression2b() {

    final double[][] data = createSampleData2();

    final XYSeries series = new XYSeries("Test");
    for (int i = 0; i < 10; i++) {
        series.add(data[i][0], data[i][1]);
    }
    final XYDataset ds = new XYSeriesCollection(series);
    final double[] result = Regression.getOLSRegression(ds, 0);

    assertEquals(53.9729697, result[0], 0.0000001);
    assertEquals(-4.1823030, result[1], 0.0000001);

}
项目:parabuild-ci    文件:RegressionTests.java   
/**
 * Checks the results of a power regression on sample dataset 2 AFTER converting it to
 * an XYSeries.
 */
public void testPowerRegression2b() {

    final double[][] data = createSampleData2();

    final XYSeries series = new XYSeries("Test");
    for (int i = 0; i < 10; i++) {
        series.add(data[i][0], data[i][1]);
    }
    final XYDataset ds = new XYSeriesCollection(series);
    final double[] result = Regression.getPowerRegression(ds, 0);

    assertEquals(106.1241681, result[0], 0.0000001);
    assertEquals(-0.8466615, result[1], 0.0000001);

}
项目:parabuild-ci    文件:TimeSeriesChartTests.java   
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(10.0, 10.0);
    series1.add(20.0, 20.0);
    series1.add(30.0, 30.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setDataset(dataset);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around 10: "
               + range.getLowerBound(), range.getLowerBound() <= 10);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
项目:parabuild-ci    文件:TimeSeriesChartTests.java   
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    // create the chart...
    return ChartFactory.createTimeSeriesChart(
        "XY Line Chart",  // chart title
        "Domain",
        "Range",
        dataset,         // data
        true,            // include legend
        true,            // tooltips
        true             // urls
    );

}
项目:parabuild-ci    文件:XYStepChartTests.java   
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(10.0, 10.0);
    series1.add(20.0, 20.0);
    series1.add(30.0, 30.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setDataset(dataset);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around 10: "
               + range.getLowerBound(), range.getLowerBound() <= 10);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
项目:parabuild-ci    文件:XYStepChartTests.java   
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    // create the chart...
    return ChartFactory.createXYStepChart(
        "Step Chart",  // chart title
        "Domain",
        "Range",
        dataset,         // data
        PlotOrientation.VERTICAL,
        true,            // include legend
        true,            // tooltips
        true             // urls
    );

}
项目:parabuild-ci    文件:XYAreaChartTests.java   
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(10.0, 10.0);
    series1.add(20.0, 20.0);
    series1.add(30.0, 30.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setDataset(dataset);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around 10: "
               + range.getLowerBound(), range.getLowerBound() <= 10);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
项目:parabuild-ci    文件:XYAreaChartTests.java   
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    // create the chart...
    return ChartFactory.createXYAreaChart(
        "Area Chart",  // chart title
        "Domain",
        "Range",
        dataset,         // data
        PlotOrientation.VERTICAL,
        true,            // include legend
        true,            // tooltips
        true             // urls
    );

}
项目:parabuild-ci    文件:XYStepAreaChartTests.java   
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(10.0, 10.0);
    series1.add(20.0, 20.0);
    series1.add(30.0, 30.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setDataset(dataset);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around 10: "
               + range.getLowerBound(), range.getLowerBound() <= 10);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
项目:parabuild-ci    文件:XYStepAreaChartTests.java   
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    // create the chart...
    return ChartFactory.createXYStepAreaChart(
        "Step Chart",  // chart title
        "Domain",
        "Range",
        dataset,         // data
        PlotOrientation.VERTICAL,
        true,            // include legend
        true,            // tooltips
        true            // urls
    );

}
项目:parabuild-ci    文件:ScatterPlotTests.java   
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(10.0, 10.0);
    series1.add(20.0, 20.0);
    series1.add(30.0, 30.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setDataset(dataset);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around 10: "
               + range.getLowerBound(), range.getLowerBound() <= 10);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
项目:parabuild-ci    文件:ScatterPlotTests.java   
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    // create the chart...
    return ChartFactory.createScatterPlot(
        "Scatter Plot",  // chart title
        "Domain",
        "Range",
        dataset,         // data
        PlotOrientation.VERTICAL,
        true,            // include legend
        true,            // tooltips
        false            // urls
    );

}
项目:parabuild-ci    文件:XYLineChartTests.java   
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(10.0, 10.0);
    series1.add(20.0, 20.0);
    series1.add(30.0, 30.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setDataset(dataset);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around 10: "
               + range.getLowerBound(), range.getLowerBound() <= 10);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
项目:parabuild-ci    文件:XYLineChartTests.java   
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    // create the chart...
    return ChartFactory.createXYLineChart(
        "XY Line Chart",  // chart title
        "Domain",
        "Range",
        dataset,         // data
        PlotOrientation.VERTICAL,
        true,            // include legend
        true,            // tooltips
        true             // urls
    );

}
项目:parabuild-ci    文件:XYBarChartTests.java   
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(10.0, 10.0);
    series1.add(20.0, 20.0);
    series1.add(30.0, 30.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);

    XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setDataset(dataset);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around 10: "
               + range.getLowerBound(), range.getLowerBound() <= 10);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
项目:parabuild-ci    文件:XYBarChartTests.java   
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection(
            series1), 1.0);

    // create the chart...
    return ChartFactory.createXYBarChart(
        "XY Bar Chart",  // chart title
        "Domain", false,
        "Range",
        dataset,         // data
        PlotOrientation.VERTICAL,
        true,            // include legend
        true,            // tooltips
        true             // urls
    );

}
项目:parabuild-ci    文件:XYBarRendererTests.java   
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
public void testFindDomainBounds() {
    XYSeriesCollection dataset 
        = RendererXYPackageTests.createTestXYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYBarChart(
        "Test Chart", "X", false, "Y", dataset, 
        PlotOrientation.VERTICAL, false, false, false
    );
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
项目:parabuild-ci    文件:XYLineAndShapeRendererTests.java   
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
public void testFindDomainBounds() {
    XYSeriesCollection dataset 
            = RendererXYPackageTests.createTestXYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYLineChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, 
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.9));
    assertTrue(bounds.contains(1.0));
    assertTrue(bounds.contains(2.0));
    assertFalse(bounds.contains(2.10));
}
项目:parabuild-ci    文件:CombinedDomainXYPlotTests.java   
/**
 * Creates a sample dataset.
 *
 * @return Series 2.
 */
private XYDataset createDataset2() {

    // create dataset 2...
    XYSeries series2 = new XYSeries("Series 3");

    series2.add(10.0, 16853.2);
    series2.add(20.0, 19642.3);
    series2.add(30.0, 18253.5);
    series2.add(40.0, 15352.3);
    series2.add(50.0, 13532.0);
    series2.add(100.0, 12635.3);
    series2.add(110.0, 13998.2);
    series2.add(120.0, 11943.2);
    series2.add(130.0, 16943.9);
    series2.add(140.0, 17843.2);
    series2.add(150.0, 16495.3);
    series2.add(160.0, 17943.6);
    series2.add(170.0, 18500.7);
    series2.add(180.0, 19595.9);

    return new XYSeriesCollection(series2);

}
项目:parabuild-ci    文件:XYPlotTests.java   
/**
 * Some checks for the getRendererForDataset() method.
 */
public void testGetRendererForDataset() {
    XYDataset d0 = new XYSeriesCollection();
    XYDataset d1 = new XYSeriesCollection();
    XYDataset d2 = new XYSeriesCollection();
    XYDataset d3 = new XYSeriesCollection();  // not used by plot
    XYItemRenderer r0 = new XYLineAndShapeRenderer();
    XYItemRenderer r2 = new XYLineAndShapeRenderer();
    XYPlot plot = new XYPlot();
    plot.setDataset(0, d0);
    plot.setDataset(1, d1);
    plot.setDataset(2, d2);
    plot.setRenderer(0, r0);
    // no renderer 1
    plot.setRenderer(2, r2);
    assertEquals(r0, plot.getRendererForDataset(d0));
    assertEquals(r0, plot.getRendererForDataset(d1));
    assertEquals(r2, plot.getRendererForDataset(d2));
    assertEquals(null, plot.getRendererForDataset(d3));
    assertEquals(null, plot.getRendererForDataset(null));
}
项目:parabuild-ci    文件:NumberAxisTests.java   
/**
 * Checks that the auto-range for the domain axis on an XYPlot is
 * working as expected.
 */
public void testXYAutoRange1() {
    XYSeries series = new XYSeries("Series 1");
    series.add(1.0, 1.0);
    series.add(2.0, 2.0);
    series.add(3.0, 3.0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot(
        "Test", 
        "X",
        "Y",
        dataset,
        PlotOrientation.VERTICAL,
        false, 
        false,
        false
    );
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getDomainAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(0.9, axis.getLowerBound(), EPSILON);    
    assertEquals(3.1, axis.getUpperBound(), EPSILON);    
}
项目:parabuild-ci    文件:NumberAxisTests.java   
/**
 * Checks that the auto-range for the range axis on an XYPlot is
 * working as expected.
 */
public void testXYAutoRange2() {
    XYSeries series = new XYSeries("Series 1");
    series.add(1.0, 1.0);
    series.add(2.0, 2.0);
    series.add(3.0, 3.0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot(
        "Test", 
        "X",
        "Y",
        dataset,
        PlotOrientation.VERTICAL,
        false, 
        false,
        false
    );
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(0.9, axis.getLowerBound(), EPSILON);    
    assertEquals(3.1, axis.getUpperBound(), EPSILON);    
}