Java Code Examples for org.jfree.data.xy.XYSeriesCollection#setIntervalWidth()

The following examples show how to use org.jfree.data.xy.XYSeriesCollection#setIntervalWidth() . 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: ValueAxisTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tests the the lower and upper margin settings produce the expected
 * results.
 */
@Test
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);
    ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis();
    Range r = domainAxis.getRange();
    assertEquals(110.0, r.getLength(), EPSILON);
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertEquals(120.0, r.getLength(), EPSILON);
}
 
Example 2
Source File: DatasetUtilitiesTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: ValueAxisTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tests the the lower and upper margin settings produce the expected
 * results.
 */
@Test
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);
    ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis();
    Range r = domainAxis.getRange();
    assertEquals(110.0, r.getLength(), EPSILON);
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertEquals(120.0, r.getLength(), EPSILON);
}
 
Example 4
Source File: DatasetUtilitiesTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: ValueAxisTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Tests the the lower and upper margin settings produce the expected
 * results.
 */
@Test
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);
    ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis();
    Range r = domainAxis.getRange();
    assertEquals(110.0, r.getLength(), EPSILON);
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertEquals(120.0, r.getLength(), EPSILON);
}
 
Example 6
Source File: DatasetUtilitiesTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: ValueAxisTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests the the lower and upper margin settings produce the expected
 * results.
 */
@Test
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);
    ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis();
    Range r = domainAxis.getRange();
    assertEquals(110.0, r.getLength(), EPSILON);
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertEquals(120.0, r.getLength(), EPSILON);
}
 
Example 8
Source File: DatasetUtilitiesTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 9
Source File: ValueAxisTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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, false);
    ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis();
    Range r = domainAxis.getRange();
    assertEquals(110.0, r.getLength(), EPSILON);
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertEquals(120.0, r.getLength(), EPSILON);
}
 
Example 10
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 11
Source File: ValueAxisTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 = ((XYPlot) chart.getPlot()).getDomainAxis();
    Range r = domainAxis.getRange();
    assertEquals(110.0, r.getLength(), EPSILON);
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertEquals(120.0, r.getLength(), EPSILON);
}
 
Example 12
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 13
Source File: ValueAxisTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tests the the lower and upper margin settings produce the expected
 * results.
 */
@Test
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);
    ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis();
    Range r = domainAxis.getRange();
    assertEquals(110.0, r.getLength(), EPSILON);
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertEquals(120.0, r.getLength(), EPSILON);
}
 
Example 14
Source File: DatasetUtilitiesTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 15
Source File: XYSeriesCollectionTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    XYSeries s1 = new XYSeries("Series");
    s1.add(1.0, 1.1);
    XYSeriesCollection c1 = new XYSeriesCollection();
    c1.addSeries(s1);
    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));

    c1.setIntervalWidth(5.0);
    assertFalse(c1.equals(c2));
    c2.setIntervalWidth(5.0);
    assertTrue(c1.equals(c2));

    c1.setIntervalPositionFactor(0.75);
    assertFalse(c1.equals(c2));
    c2.setIntervalPositionFactor(0.75);
    assertTrue(c1.equals(c2));

    c1.setAutoWidth(true);
    assertFalse(c1.equals(c2));
    c2.setAutoWidth(true);
    assertTrue(c1.equals(c2));

}
 
Example 16
Source File: ChartDatasetFactory.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @param valueSource
 * @param plotInstance
 * @param autoWidthFraction
 *            If this value is greater than 0, an auto width for the intervals is calculated
 *            such that the intervals nearest to each other touch. This value is then multiplied
 *            with the value of autoWidthFtraction. If unset, the intervals have width 0.
 * @param allowDuplicates
 * @param sortByDomain
 *            if true, the data is sorted by domain values (useful for bar and area charts)
 * @return
 * @throws ChartPlottimeException
 */
public static XYSeriesCollection createXYSeriesCollection(ValueSource valueSource, PlotInstance plotInstance,
		double autoWidthFraction, boolean allowDuplicates, boolean sortByDomain) throws ChartPlottimeException {
	XYSeriesCollection xyDataset = new XYSeriesCollection();
	if (autoWidthFraction > 0) {
		xyDataset.setAutoWidth(true);
	} else {
		xyDataset.setAutoWidth(false);
		xyDataset.setIntervalWidth(0);
	}

	ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource);
	assertMaxValueCountNotExceededOrThrowException(valueSourceData);
	GroupCellSeriesData dataForAllGroupCells = valueSourceData.getSeriesDataForAllGroupCells();

	// Loop over group cells and add data to dataset
	for (GroupCellKeyAndData groupCellKeyAndData : dataForAllGroupCells) {
		GroupCellKey groupCellKey = groupCellKeyAndData.getKey();
		GroupCellData groupCellData = groupCellKeyAndData.getData();

		String seriesName = generateSeriesName(valueSource, groupCellKey,
				plotInstance.getCurrentPlotConfigurationClone());

		XYSeries series = new XYSeries(seriesName, sortByDomain, allowDuplicates);
		Map<PlotDimension, double[]> dataForUsageType = groupCellData.getDataForUsageType(SeriesUsageType.MAIN_SERIES);
		int rowCount = dataForUsageType.get(PlotDimension.DOMAIN).length;
		double[] xValues = dataForUsageType.get(PlotDimension.DOMAIN);
		double[] yValues = dataForUsageType.get(PlotDimension.VALUE);

		try {
			// Loop over rows and add data to series
			for (int row = 0; row < rowCount; ++row) {
				double x = xValues[row];
				double y = yValues[row];
				if (!Double.isNaN(x)) {
					series.add(x, y);
				}

			}
		} catch (SeriesException e) {
			throw new ChartPlottimeException("duplicate_value", valueSource.toString(), PlotDimension.DOMAIN.getName());
		}

		xyDataset.addSeries(series);
	}
	// intervals should not touch each other, so decrease auto width.
	if (xyDataset.getIntervalWidth() > 0) {
		xyDataset.setIntervalWidth(xyDataset.getIntervalWidth() * autoWidthFraction);
	}
	return xyDataset;
}