org.jfree.data.xy.IntervalXYDataset Java Examples

The following examples show how to use org.jfree.data.xy.IntervalXYDataset. 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: Histogram.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
protected JFreeChart createChart( final IntervalXYDataset dataset, final String title, final String units )
{
	final JFreeChart chart = ChartFactory.createXYBarChart(
		title,
		"Distance [" + units + "]",
		false,
		"Count",
		dataset,
		PlotOrientation.VERTICAL,
		false, // legend
		false,
		false );

	final NumberAxis range = (NumberAxis) chart.getXYPlot().getDomainAxis();
	range.setRange( getMin(), getMax() );

	final XYPlot plot = chart.getXYPlot();
	final XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();

	renderer.setSeriesPaint( 0, Color.red );
	renderer.setDrawBarOutline( true );
	renderer.setSeriesOutlinePaint( 0, Color.black );
	renderer.setBarPainter( new StandardXYBarPainter() );

	return chart;
}
 
Example #2
Source File: XYPlotTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a sample dataset.
 *
 * @return Series 1.
 */
private IntervalXYDataset createDataset1() {

    // create dataset 1...
    TimeSeries series1 = new TimeSeries("Series 1", Day.class);
    series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3);
    series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4);
    series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3);
    series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3);
    series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4);
    series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3);
    series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5);
    series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3);
    series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4);
    series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6);
    series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3);
    series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2);
    series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2);
    series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2);
    series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2);

    TimeSeriesCollection collection = new TimeSeriesCollection(series1);
    return collection;

}
 
Example #3
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a histogram chart.  This chart is constructed with an
 * {@link XYPlot} using an {@link XYBarRenderer}.  The domain and range
 * axes are {@link NumberAxis} instances.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  the x axis label (<code>null</code> permitted).
 * @param yAxisLabel  the y axis label (<code>null</code> permitted).
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param legend  create a legend?
 *
 * @return The chart.
 */
public static JFreeChart createHistogram(String title, String xAxisLabel,
        String yAxisLabel, IntervalXYDataset dataset, boolean legend) {

    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    ValueAxis yAxis = new NumberAxis(yAxisLabel);
    XYItemRenderer renderer = new XYBarRenderer();
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #4
Source File: Histogram.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
protected IntervalXYDataset createDataset( final List< Double > values, final int numBins, final String title )
{
	final XYSeries series = new XYSeries( title );

	final ValuePair< Double, Double > minmax = getMinMax( values );
	this.min = minmax.getA();
	this.max = minmax.getB();

	final List< ValuePair< Double, Integer > > hist = binData( values, min, max, numBins );

	for ( final ValuePair< Double, Integer > pair : hist )
		series.add( pair.getA(), pair.getB() );

	final XYSeriesCollection dataset = new XYSeriesCollection( series );
	dataset.setAutoWidth( true );

	return dataset;
}
 
Example #5
Source File: XYPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.  This test
 * uses a {@link DateAxis} and a {@link StandardXYToolTipGenerator}.
 */
@Test
public void testSerialization2() {
    IntervalXYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new XYBarRenderer(0.20);
    renderer1.setBaseToolTipGenerator(
            StandardXYToolTipGenerator.getTimeSeriesInstance());
    XYPlot p1 = new XYPlot(data1, new DateAxis("Date"), null, renderer1);
    XYPlot p2 = (XYPlot) TestUtilities.serialised(p1);
    assertEquals(p1, p2);
}
 
Example #6
Source File: ClusteredXYBarRenderer.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Iterates over the items in an {@link IntervalXYDataset} to find
 * the range of x-values including the interval OFFSET so that it centers
 * the interval around the start value.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The range (possibly <code>null</code>).
 */
protected Range findDomainBoundsWithOffset(IntervalXYDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();
    double lvalue;
    double uvalue;
    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            lvalue = dataset.getStartXValue(series, item);
            uvalue = dataset.getEndXValue(series, item);
            double offset = (uvalue - lvalue) / 2.0;
            lvalue = lvalue - offset;
            uvalue = uvalue - offset;
            minimum = Math.min(minimum, lvalue);
            maximum = Math.max(maximum, uvalue);
        }
    }

    if (minimum > maximum) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example #7
Source File: ChartServiceImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private byte[] generateTimeSeriesChart(
		String siteId, IntervalXYDataset dataset, int width, int height,
		boolean renderBar, float transparency,
		boolean itemLabelsVisible, 
		boolean smallFontInDomainAxis,
		String timePeriod) {
	return generateTimeSeriesChart(siteId, dataset, width, height, 
			renderBar, transparency, 
			itemLabelsVisible,
			smallFontInDomainAxis,
			timePeriod, null, null);
}
 
Example #8
Source File: Histogram.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public Histogram( final List< Double > values, final int numBins, final String title, final String units )
{
	super( title );

	final IntervalXYDataset dataset = createDataset( values, numBins, title );
	final JFreeChart chart = createChart( dataset, title, units );
	final ChartPanel chartPanel = new ChartPanel( chart );
	chartPanel.addChartMouseListener( new MouseListenerValue( chartPanel, getMin() + ( getMax() - getMin() ) / 2 ));

	chartPanel.setPreferredSize( new Dimension( 600, 270 ) );
	setContentPane( chartPanel );
}
 
Example #9
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a histogram chart.  This chart is constructed with an
 * {@link XYPlot} using an {@link XYBarRenderer}.  The domain and range
 * axes are {@link NumberAxis} instances.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  the x axis label (<code>null</code> permitted).
 * @param yAxisLabel  the y axis label (<code>null</code> permitted).
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical)
 *                     (<code>null</code> NOT permitted).
 * @param legend  create a legend?
 * @param tooltips  display tooltips?
 * @param urls  generate URLs?
 *
 * @return The chart.
 */
public static JFreeChart createHistogram(String title,
        String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset,
        PlotOrientation orientation, boolean legend, boolean tooltips,
        boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    ValueAxis yAxis = new NumberAxis(yAxisLabel);

    XYItemRenderer renderer = new XYBarRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #10
Source File: CombinedDataset.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the starting X value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The value.
 */
public Number getStartX(int series, int item) {
    DatasetInfo di = getDatasetInfo(series);
    if (di.data instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) di.data).getStartX(di.series, item);
    }
    else {
        return getX(series, item);
    }
}
 
Example #11
Source File: DatasetUtilities.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Iterates over the data item of the xy dataset to find
 * the range bounds.
 * 
 * @param dataset  the dataset (<code>null</code> not permitted).
 * 
 * @return The range (possibly <code>null</code>).
 */
public static Range iterateXYRangeBounds(XYDataset dataset) {
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();
    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double lvalue;
            double uvalue;
            if (dataset instanceof IntervalXYDataset) {
                IntervalXYDataset intervalXYData 
                    = (IntervalXYDataset) dataset;
                lvalue = intervalXYData.getStartYValue(series, item);
                uvalue = intervalXYData.getEndYValue(series, item);
            }
            else if (dataset instanceof OHLCDataset) {
                OHLCDataset highLowData = (OHLCDataset) dataset;
                lvalue = highLowData.getLowValue(series, item);
                uvalue = highLowData.getHighValue(series, item);
            }
            else {
                lvalue = dataset.getYValue(series, item);
                uvalue = lvalue;
            }
            if (!Double.isNaN(lvalue)) {
                minimum = Math.min(minimum, lvalue);
            }
            if (!Double.isNaN(uvalue)) {     
                maximum = Math.max(maximum, uvalue);
            }
        }
    }
    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example #12
Source File: ClusteredXYBarRenderer.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the x-value bounds for the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The bounds (possibly <code>null</code>).
 */
@Override
public Range findDomainBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    // need to handle cluster centering as a special case
    if (this.centerBarAtStartValue) {
        return findDomainBoundsWithOffset((IntervalXYDataset) dataset);
    }
    else {
        return super.findDomainBounds(dataset);
    }
}
 
Example #13
Source File: ClusteredXYBarRenderer.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Iterates over the items in an {@link IntervalXYDataset} to find
 * the range of x-values including the interval OFFSET so that it centers
 * the interval around the start value.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The range (possibly <code>null</code>).
 */
protected Range findDomainBoundsWithOffset(IntervalXYDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();
    double lvalue;
    double uvalue;
    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            lvalue = dataset.getStartXValue(series, item);
            uvalue = dataset.getEndXValue(series, item);
            double offset = (uvalue - lvalue) / 2.0;
            lvalue = lvalue - offset;
            uvalue = uvalue - offset;
            minimum = Math.min(minimum, lvalue);
            maximum = Math.max(maximum, uvalue);
        }
    }

    if (minimum > maximum) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example #14
Source File: SubSeriesDataset.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the ending X value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The ending X value for the specified series and item.
 */
@Override
public Number getEndX(int series, int item) {
    if (this.parent instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) this.parent).getEndX(
            this.map[series], item
        );
    }
    else {
        return getX(series, item);
    }
}
 
Example #15
Source File: SubSeriesDataset.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the starting X value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The starting X value for the specified series and item.
 */
@Override
public Number getStartX(int series, int item) {
    if (this.parent instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) this.parent).getStartX(
            this.map[series], item
        );
    }
    else {
        return getX(series, item);
    }
}
 
Example #16
Source File: CombinedDataset.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the ending Y value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The ending Y value for the specified series and item.
 */
@Override
public Number getEndY(int series, int item) {
    DatasetInfo di = getDatasetInfo(series);
    if (di.data instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) di.data).getEndY(di.series, item);
    }
    else {
        return getY(series, item);
    }
}
 
Example #17
Source File: JGenProg2017_0047_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Iterates over the data item of the xy dataset to find
 * the range bounds.
 * 
 * @param dataset  the dataset (<code>null</code> not permitted).
 * 
 * @return The range (possibly <code>null</code>).
 */
public static Range iterateXYRangeBounds(XYDataset dataset) {
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();
    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double lvalue;
            double uvalue;
            if (dataset instanceof IntervalXYDataset) {
                IntervalXYDataset intervalXYData 
                    = (IntervalXYDataset) dataset;
                lvalue = intervalXYData.getStartYValue(series, item);
                uvalue = intervalXYData.getEndYValue(series, item);
            }
            else if (dataset instanceof OHLCDataset) {
                OHLCDataset highLowData = (OHLCDataset) dataset;
                lvalue = highLowData.getLowValue(series, item);
                uvalue = highLowData.getHighValue(series, item);
            }
            else {
                lvalue = dataset.getYValue(series, item);
                uvalue = lvalue;
            }
            if (!Double.isNaN(lvalue)) {
                minimum = Math.min(minimum, lvalue);
            }
            if (!Double.isNaN(uvalue)) {     
                maximum = Math.max(maximum, uvalue);
            }
        }
    }
    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example #18
Source File: SubSeriesDataset.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the ending Y value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The ending Y value for the specified series and item.
 */
@Override
public Number getEndY(int series,  int item) {
    if (this.parent instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) this.parent).getEndY(
            this.map[series], item
        );
    }
    else {
        return getY(series, item);
    }
}
 
Example #19
Source File: CombinedDataset.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the starting Y value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The starting Y value for the specified series and item.
 */
@Override
public Number getStartY(int series, int item) {
    DatasetInfo di = getDatasetInfo(series);
    if (di.data instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) di.data).getStartY(di.series, item);
    }
    else {
        return getY(series, item);
    }
}
 
Example #20
Source File: CombinedDataset.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the ending X value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The value.
 */
@Override
public Number getEndX(int series, int item) {
    DatasetInfo di = getDatasetInfo(series);
    if (di.data instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) di.data).getEndX(di.series, item);
    }
    else {
        return getX(series, item);
    }
}
 
Example #21
Source File: CombinedDataset.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the ending Y value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The ending Y value for the specified series and item.
 */
@Override
public Number getEndY(int series, int item) {
    DatasetInfo di = getDatasetInfo(series);
    if (di.data instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) di.data).getEndY(di.series, item);
    }
    else {
        return getY(series, item);
    }
}
 
Example #22
Source File: SubSeriesDataset.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the starting X value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The starting X value for the specified series and item.
 */
public Number getStartX(int series, int item) {
    if (this.parent instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) this.parent).getStartX(
            this.map[series], item
        );
    }
    else {
        return getX(series, item);
    }
}
 
Example #23
Source File: SubSeriesDataset.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the starting X value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The starting X value for the specified series and item.
 */
public Number getStartX(int series, int item) {
    if (this.parent instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) this.parent).getStartX(
            this.map[series], item
        );
    }
    else {
        return getX(series, item);
    }
}
 
Example #24
Source File: CombinedDataset.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the starting X value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The value.
 */
@Override
public Number getStartX(int series, int item) {
    DatasetInfo di = getDatasetInfo(series);
    if (di.data instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) di.data).getStartX(di.series, item);
    }
    else {
        return getX(series, item);
    }
}
 
Example #25
Source File: CombinedDataset.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the starting Y value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The starting Y value for the specified series and item.
 */
public Number getStartY(int series, int item) {
    DatasetInfo di = getDatasetInfo(series);
    if (di.data instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) di.data).getStartY(di.series, item);
    }
    else {
        return getY(series, item);
    }
}
 
Example #26
Source File: CombinedDataset.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the ending X value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The value.
 */
@Override
public Number getEndX(int series, int item) {
    DatasetInfo di = getDatasetInfo(series);
    if (di.data instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) di.data).getEndX(di.series, item);
    }
    else {
        return getX(series, item);
    }
}
 
Example #27
Source File: SubSeriesDataset.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the starting X value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The starting X value for the specified series and item.
 */
@Override
public Number getStartX(int series, int item) {
    if (this.parent instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) this.parent).getStartX(
            this.map[series], item
        );
    }
    else {
        return getX(series, item);
    }
}
 
Example #28
Source File: CombinedDataset.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the starting Y value for the specified series and item.
 *
 * @param series  the index of the series of interest (zero-based).
 * @param item  the index of the item of interest (zero-based).
 *
 * @return The starting Y value for the specified series and item.
 */
public Number getStartY(int series, int item) {
    DatasetInfo di = getDatasetInfo(series);
    if (di.data instanceof IntervalXYDataset) {
        return ((IntervalXYDataset) di.data).getStartY(di.series, item);
    }
    else {
        return getY(series, item);
    }
}
 
Example #29
Source File: ClusteredXYBarRenderer.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Iterates over the items in an {@link IntervalXYDataset} to find
 * the range of x-values including the interval OFFSET so that it centers
 * the interval around the start value.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The range (possibly <code>null</code>).
 */
protected Range findDomainBoundsWithOffset(IntervalXYDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();
    double lvalue;
    double uvalue;
    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            lvalue = dataset.getStartXValue(series, item);
            uvalue = dataset.getEndXValue(series, item);
            double offset = (uvalue - lvalue) / 2.0;
            lvalue = lvalue - offset;
            uvalue = uvalue - offset;
            minimum = Math.min(minimum, lvalue);
            maximum = Math.max(maximum, uvalue);
        }
    }

    if (minimum > maximum) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example #30
Source File: ClusteredXYBarRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Iterates over the items in an {@link IntervalXYDataset} to find
 * the range of x-values including the interval OFFSET so that it centers
 * the interval around the start value.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The range (possibly <code>null</code>).
 */
protected Range findDomainBoundsWithOffset(IntervalXYDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();
    double lvalue;
    double uvalue;
    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            lvalue = dataset.getStartXValue(series, item);
            uvalue = dataset.getEndXValue(series, item);
            double offset = (uvalue - lvalue) / 2.0;
            lvalue = lvalue - offset;
            uvalue = uvalue - offset;
            minimum = Math.min(minimum, lvalue);
            maximum = Math.max(maximum, uvalue);
        }
    }

    if (minimum > maximum) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}