org.jfree.data.xy.YIntervalSeriesCollection Java Examples

The following examples show how to use org.jfree.data.xy.YIntervalSeriesCollection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PerformancePlotter.java    From burlap with Apache License 2.0 6 votes vote down vote up
/**
 * Adds the most recent trial (if enabled) chart and trial average (if enabled) chart into the provided container.
 * The GridBagConstraints will aumatically be incremented to the next position after this method returns.
 * @param plotContainer the contain in which to insert the plot(s).
 * @param c the current grid bag contraint locaiton in which the plots should be inserted.
 * @param columns the number of columns to fill in the plot container
 * @param chartWidth the width of any single plot
 * @param chartHeight the height of any single plot
 * @param title the title to label thep plot; if average trial plots are enabled the word "Average" will be prepended to the title for the average plot.
 * @param xlab the xlab axis of the plot
 * @param ylab the y lab axis of the plot
 * @param mostRecentCollection the XYSeriesCollection dataset with which the most recent trial plot is associated 
 * @param averageCollection the YIntervalSeriesCollection dataset with which the trial average plot is associated
 */
protected void insertChart(Container plotContainer, GridBagConstraints c, int columns, int chartWidth, int chartHeight,
		String title, String xlab, String ylab, XYSeriesCollection mostRecentCollection, YIntervalSeriesCollection averageCollection){
	
	if(this.trialMode.mostRecentTrialEnabled()){
		final JFreeChart chartCSR = ChartFactory.createXYLineChart(title, xlab, ylab, mostRecentCollection);
		ChartPanel chartPanelCSR = new ChartPanel(chartCSR);
		chartPanelCSR.setPreferredSize(new java.awt.Dimension(chartWidth, chartHeight));
		plotContainer.add(chartPanelCSR, c);
		this.updateGBConstraint(c, columns);
	}
	
	if(this.trialMode.averagesEnabled()){
		final JFreeChart chartCSRAvg = ChartFactory.createXYLineChart("Average " + title, xlab, ylab, averageCollection);
		((XYPlot)chartCSRAvg.getPlot()).setRenderer(this.createDeviationRenderer());
		ChartPanel chartPanelCSRAvg = new ChartPanel(chartCSRAvg);
		chartPanelCSRAvg.setPreferredSize(new java.awt.Dimension(chartWidth, chartHeight));
		plotContainer.add(chartPanelCSRAvg, c);
		this.updateGBConstraint(c, columns);
	}
}
 
Example #2
Source File: MultiAgentPerformancePlotter.java    From burlap with Apache License 2.0 6 votes vote down vote up
/**
 * Adds the most recent trial (if enabled) chart and trial average (if enabled) chart into the provided container.
 * The GridBagConstraints will aumatically be incremented to the next position after this method returns.
 * @param plotContainer the contain in which to insert the plot(s).
 * @param c the current grid bag contraint locaiton in which the plots should be inserted.
 * @param columns the number of columns to fill in the plot container
 * @param chartWidth the width of any single plot
 * @param chartHeight the height of any single plot
 * @param title the title to label thep plot; if average trial plots are enabled the word "Average" will be prepended to the title for the average plot.
 * @param xlab the xlab axis of the plot
 * @param ylab the y lab axis of the plot
 * @param mostRecentCollection the XYSeriesCollection dataset with which the most recent trial plot is associated 
 * @param averageCollection the YIntervalSeriesCollection dataset with which the trial average plot is associated
 */
protected void insertChart(Container plotContainer, GridBagConstraints c, int columns, int chartWidth, int chartHeight,
		String title, String xlab, String ylab, XYSeriesCollection mostRecentCollection, YIntervalSeriesCollection averageCollection){
	
	if(this.trialMode.mostRecentTrialEnabled()){
		final JFreeChart chartCSR = ChartFactory.createXYLineChart(title, xlab, ylab, mostRecentCollection);
		ChartPanel chartPanelCSR = new ChartPanel(chartCSR);
		chartPanelCSR.setPreferredSize(new java.awt.Dimension(chartWidth, chartHeight));
		plotContainer.add(chartPanelCSR, c);
		this.updateGBConstraint(c, columns);
	}
	
	if(this.trialMode.averagesEnabled()){
		final JFreeChart chartCSRAvg = ChartFactory.createXYLineChart("Average " + title, xlab, ylab, averageCollection);
		((XYPlot)chartCSRAvg.getPlot()).setRenderer(this.createDeviationRenderer());
		ChartPanel chartPanelCSRAvg = new ChartPanel(chartCSRAvg);
		chartPanelCSRAvg.setPreferredSize(new java.awt.Dimension(chartWidth, chartHeight));
		plotContainer.add(chartPanelCSRAvg, c);
		this.updateGBConstraint(c, columns);
	}
}
 
Example #3
Source File: YIntervalSeriesCollectionTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    YIntervalSeriesCollection c1 = new YIntervalSeriesCollection();
    YIntervalSeriesCollection c2 = new YIntervalSeriesCollection();
    assertEquals(c1, c2);
    
    // add a series
    YIntervalSeries s1 = new YIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    assertFalse(c1.equals(c2));
    YIntervalSeries s2 = new YIntervalSeries("Series");
    s2.add(1.0, 1.1, 1.2, 1.3);
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));
    
    // add an empty series
    c1.addSeries(new YIntervalSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new YIntervalSeries("Empty Series"));
    assertTrue(c1.equals(c2));
}
 
Example #4
Source File: YIntervalSeriesCollectionTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    YIntervalSeriesCollection c1 = new YIntervalSeriesCollection();
    YIntervalSeriesCollection c2 = new YIntervalSeriesCollection();
    assertEquals(c1, c2);

    // add a series
    YIntervalSeries s1 = new YIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    assertFalse(c1.equals(c2));
    YIntervalSeries s2 = new YIntervalSeries("Series");
    s2.add(1.0, 1.1, 1.2, 1.3);
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));

    // add an empty series
    c1.addSeries(new YIntervalSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new YIntervalSeries("Empty Series"));
    assertTrue(c1.equals(c2));
}
 
Example #5
Source File: YIntervalRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #6
Source File: DatasetUtilitiesTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
@Test
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #7
Source File: YIntervalRendererTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #8
Source File: YIntervalRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);
    
    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #9
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #10
Source File: YIntervalRendererTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #11
Source File: DatasetUtilitiesTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
@Test
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #12
Source File: YIntervalRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #13
Source File: DatasetUtilitiesTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
@Test
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #14
Source File: YIntervalRendererTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #15
Source File: DatasetUtilitiesTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
@Test
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #16
Source File: YIntervalRendererTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #17
Source File: DatasetUtilitiesTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
@Test
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #18
Source File: DatasetUtilitiesTest.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * A test for the findRangeBounds(XYDataset) method using
 * an IntervalXYDataset.
 */
@Test
public void testFindRangeBounds2() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);

    // what if we don't want the interval?
    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);
}
 
Example #19
Source File: ROCChartPlotter.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
private void prepareData() {

		this.dataset = new YIntervalSeriesCollection();

		Iterator<Map.Entry<String, List<ROCData>>> r = rocDataLists.entrySet().iterator();
		boolean showThresholds = true;
		if (rocDataLists.size() > 1) {
			showThresholds = false;
		}

		while (r.hasNext()) {
			Map.Entry<String, List<ROCData>> entry = r.next();
			YIntervalSeries rocSeries = new YIntervalSeries(entry.getKey());
			YIntervalSeries thresholdSeries = new YIntervalSeries(entry.getKey() + " (Thresholds)");
			List<ROCData> dataList = entry.getValue();
			for (int i = 0; i <= NUMBER_OF_POINTS; i++) {

				double rocSum = 0.0d;
				double rocSquaredSum = 0.0d;
				double thresholdSum = 0.0d;
				double thresholdSquaredSum = 0.0d;
				for (ROCData data : dataList) {
					double rocValue = data.getInterpolatedTruePositives(i / (double) NUMBER_OF_POINTS)
							/ data.getTotalPositives();
					rocSum += rocValue;
					rocSquaredSum += rocValue * rocValue;

					double thresholdValue = data.getInterpolatedThreshold(i / (double) NUMBER_OF_POINTS);
					thresholdSum += thresholdValue;
					thresholdSquaredSum += thresholdValue * thresholdValue;
				}

				double rocMean = rocSum / dataList.size();
				double rocDeviation = Math.sqrt(rocSquaredSum / dataList.size() - (rocMean * rocMean));
				rocSeries.add(i / (double) NUMBER_OF_POINTS, rocMean, rocMean - rocDeviation, rocMean + rocDeviation);

				double thresholdMean = thresholdSum / dataList.size();
				double thresholdDeviation = Math.sqrt(thresholdSquaredSum / dataList.size()
						- (thresholdMean * thresholdMean));
				thresholdSeries.add(i / (double) NUMBER_OF_POINTS, thresholdMean, thresholdMean - thresholdDeviation,
						thresholdMean + thresholdDeviation);

			}
			dataset.addSeries(rocSeries);

			if (showThresholds) {
				dataset.addSeries(thresholdSeries);
			}
		}
	}
 
Example #20
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * A test for the findRangeBounds(XYDataset) method using
 * an IntervalXYDataset.
 */
public void testFindRangeBounds2() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);

    // what if we don't want the interval?
    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);
}
 
Example #21
Source File: DatasetUtilitiesTest.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * A test for the findRangeBounds(XYDataset) method using
 * an IntervalXYDataset.
 */
@Test
public void testFindRangeBounds2() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);

    // what if we don't want the interval?
    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);
}
 
Example #22
Source File: YIntervalSeriesCollectionTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Verify that this class implements {@link PublicCloneable}.
 */
public void testPublicCloneable() {
    YIntervalSeriesCollection c1 = new YIntervalSeriesCollection();
    assertTrue(c1 instanceof PublicCloneable);
}
 
Example #23
Source File: MultiAgentPerformancePlotter.java    From burlap with Apache License 2.0 4 votes vote down vote up
/**
 * Initializes
 * @param tf the terminal function that will be used for detecting the end of episdoes
 * @param chartWidth the width of a cart
 * @param chartHeight the height of a chart
 * @param columns the number of columns of charts
 * @param maxWindowHeight the maximum window height until a scroll bar will be added
 * @param trialMode the kinds of trail data that will be displayed
 * @param metrics which metrics will be plotted.
 */
public MultiAgentPerformancePlotter(TerminalFunction tf, int chartWidth, int chartHeight, int columns, int maxWindowHeight,
							TrialMode trialMode, PerformanceMetric...metrics){


	this.tf = tf;
	
	colCSR = new XYSeriesCollection();
	colCER = new XYSeriesCollection();
	colAER = new XYSeriesCollection();
	colMER = new XYSeriesCollection();
	colCSE = new XYSeriesCollection();
	colSE = new XYSeriesCollection();
	
	colCSRAvg = new YIntervalSeriesCollection();
	colCERAvg = new YIntervalSeriesCollection();
	colAERAvg = new YIntervalSeriesCollection();
	colMERAvg = new YIntervalSeriesCollection();
	colCSEAvg = new YIntervalSeriesCollection();
	colSEAvg = new YIntervalSeriesCollection();
	
	
	if(metrics.length == 0){
		metricsSet.add(PerformanceMetric.CUMULATIVE_REWARD_PER_STEP);
		
		metrics = new PerformanceMetric[]{PerformanceMetric.CUMULATIVE_REWARD_PER_STEP};
	}
	
	this.trialMode = trialMode;
	
	Container plotContainer = new Container();
	plotContainer.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.insets = new Insets(0, 0, 10, 10);
       
       for(PerformanceMetric m : metrics){
       	
       	this.metricsSet.add(m);
       	
       	if(m == PerformanceMetric.CUMULATIVE_REWARD_PER_STEP){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Cumulative Reward", "Time Step", "Cumulative Reward", colCSR, colCSRAvg);
       	}
       	else if(m == PerformanceMetric.CUMULATIVE_REWARD_PER_EPISODE){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Cumulative Reward", "Episode", "Cumulative Reward", colCER, colCERAvg);
       	}
       	else if(m == PerformanceMetric.AVERAGE_EPISODE_REWARD){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Average Reward", "Episode", "Average Reward", colAER, colAERAvg);
       	}
       	else if(m == PerformanceMetric.MEDIAN_EPISODE_REWARD){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Median Reward", "Episode", "Median Reward", colMER, colMERAvg);
       	}
       	else if(m == PerformanceMetric.CUMULATIVE_STEPS_PER_EPISODE){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Cumulative Steps", "Episode", "Cumulative Steps", colCSE, colCSEAvg);
       	}
       	else if(m == PerformanceMetric.STEPS_PER_EPISODE){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Number of Steps", "Episode", "Number of Steps", colSE, colSEAvg);
       	}
       	
       	
       }
       
       int totalChartHeight = ((metrics.length / columns)+1)*(chartHeight+10);
       if(totalChartHeight > maxWindowHeight){
		JScrollPane scrollPane = new JScrollPane(plotContainer);
		scrollPane.setPreferredSize(new Dimension(chartWidth*columns+50, maxWindowHeight));
		this.add(scrollPane);
       }
       else{
       	this.add(plotContainer);
       }
	
}
 
Example #24
Source File: DatasetUtilitiesTest.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * A test for the findRangeBounds(XYDataset) method using
 * an IntervalXYDataset.
 */
@Test
public void testFindRangeBounds2() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);

    // what if we don't want the interval?
    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);
}
 
Example #25
Source File: PerformancePlotter.java    From burlap with Apache License 2.0 4 votes vote down vote up
/**
 * Initializes a performance plotter.
 * @param firstAgentName the name of the first agent whose performance will be measured.
 * @param chartWidth the width of each chart/plot
 * @param chartHeight the height of each chart//plot
 * @param columns the number of columns of the plots displayed. Plots are filled in columns first, then move down the next row.
 * @param maxWindowHeight the maximum window height allowed before a scroll view is used.
 * @param trialMode which plots to use; most recent trial, average over all trials, or both. If both, the most recent plot will be inserted into the window first, then the average.
 * @param metrics the metrics that should be plotted. The metrics will appear in the window in the order that they are specified (columns first)
 */
public PerformancePlotter(String firstAgentName, int chartWidth, int chartHeight, int columns, int maxWindowHeight,
							TrialMode trialMode, PerformanceMetric...metrics){

	this.curAgentName = firstAgentName;
	
	this.agentTrials = new HashMap<String, List<Trial>>();
	this.agentTrials.put(this.curAgentName, new ArrayList<PerformancePlotter.Trial>());
	
	colCSR = new XYSeriesCollection();
	colCER = new XYSeriesCollection();
	colAER = new XYSeriesCollection();
	colMER = new XYSeriesCollection();
	colCSE = new XYSeriesCollection();
	colSE = new XYSeriesCollection();
	
	colCSRAvg = new YIntervalSeriesCollection();
	colCERAvg = new YIntervalSeriesCollection();
	colAERAvg = new YIntervalSeriesCollection();
	colMERAvg = new YIntervalSeriesCollection();
	colCSEAvg = new YIntervalSeriesCollection();
	colSEAvg = new YIntervalSeriesCollection();
	
	this.curTrial = new Trial();
	this.curAgentDatasets = new AgentDatasets(curAgentName);
       
	if(metrics.length == 0){
		metricsSet.add(PerformanceMetric.CUMULATIVE_REWARD_PER_STEP);
		
		metrics = new PerformanceMetric[]{PerformanceMetric.CUMULATIVE_REWARD_PER_STEP};
	}
	
	this.trialMode = trialMode;
	
	
	Container plotContainer = new Container();
	plotContainer.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.insets = new Insets(0, 0, 10, 10);
       
       for(PerformanceMetric m : metrics){
       	
       	this.metricsSet.add(m);
       	
       	if(m == PerformanceMetric.CUMULATIVE_REWARD_PER_STEP){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Cumulative Reward", "Time Step", "Cumulative Reward", colCSR, colCSRAvg);
       	}
       	else if(m == PerformanceMetric.CUMULATIVE_REWARD_PER_EPISODE){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Cumulative Reward", "Episode", "Cumulative Reward", colCER, colCERAvg);
       	}
       	else if(m == PerformanceMetric.AVERAGE_EPISODE_REWARD){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Average Reward", "Episode", "Average Reward", colAER, colAERAvg);
       	}
       	else if(m == PerformanceMetric.MEDIAN_EPISODE_REWARD){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Median Reward", "Episode", "Median Reward", colMER, colMERAvg);
       	}
       	else if(m == PerformanceMetric.CUMULATIVE_STEPS_PER_EPISODE){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Cumulative Steps", "Episode", "Cumulative Steps", colCSE, colCSEAvg);
       	}
       	else if(m == PerformanceMetric.STEPS_PER_EPISODE){
       		this.insertChart(plotContainer, c, columns, chartWidth, chartHeight, "Number of Steps", "Episode", "Number of Steps", colSE, colSEAvg);
       	}
       	
       	
       }
       
       int totalChartHeight = ((metrics.length / columns)+1)*(chartHeight+10);
       if(totalChartHeight > maxWindowHeight){
		JScrollPane scrollPane = new JScrollPane(plotContainer);
		scrollPane.setPreferredSize(new Dimension(chartWidth*columns+50, maxWindowHeight));
		this.add(scrollPane);
       }
       else{
       	this.add(plotContainer);
       }
       
   


}
 
Example #26
Source File: DatasetUtilitiesTest.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * A test for the findRangeBounds(XYDataset) method using
 * an IntervalXYDataset.
 */
@Test
public void testFindRangeBounds2() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);

    // what if we don't want the interval?
    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);
}
 
Example #27
Source File: DatasetUtilitiesTest.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * A test for the findRangeBounds(XYDataset) method using
 * an IntervalXYDataset.
 */
@Test
public void testFindRangeBounds2() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.findRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);

    // what if we don't want the interval?
    r = DatasetUtilities.findRangeBounds(dataset, false);
    assertEquals(2.0, r.getLowerBound(), EPSILON);
    assertEquals(2.0, r.getUpperBound(), EPSILON);
}