Example usage for org.jfree.data.xy XIntervalSeriesCollection XIntervalSeriesCollection

List of usage examples for org.jfree.data.xy XIntervalSeriesCollection XIntervalSeriesCollection

Introduction

In this page you can find the example usage for org.jfree.data.xy XIntervalSeriesCollection XIntervalSeriesCollection.

Prototype

public XIntervalSeriesCollection() 

Source Link

Document

Creates a new instance of XIntervalSeriesCollection.

Usage

From source file:org.jfree.data.xy.XIntervalSeriesCollectionTest.java

/**
 * A test for bug report 1170825 (originally affected XYSeriesCollection,
 * this test is just copied over).//from   w  ww.j  av a  2  s .  c  o  m
 */
@Test
public void test1170825() {
    XIntervalSeries s1 = new XIntervalSeries("Series1");
    XIntervalSeriesCollection dataset = new XIntervalSeriesCollection();
    dataset.addSeries(s1);
    try {
        /* XYSeries s = */ dataset.getSeries(1);
    } catch (IllegalArgumentException e) {
        // correct outcome
    } catch (IndexOutOfBoundsException e) {
        assertTrue(false); // wrong outcome
    }
}

From source file:org.jfree.data.xy.junit.XIntervalSeriesCollectionTest.java

/**
 * Some basic checks for the removeSeries() method.
 *///www .ja  va2  s. co  m
public void testRemoveSeries() {
    XIntervalSeriesCollection c = new XIntervalSeriesCollection();
    XIntervalSeries s1 = new XIntervalSeries("s1");
    c.addSeries(s1);
    c.removeSeries(0);
    assertEquals(0, c.getSeriesCount());
    c.addSeries(s1);

    boolean pass = false;
    try {
        c.removeSeries(-1);
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    pass = false;
    try {
        c.removeSeries(1);
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}

From source file:org.jfree.data.xy.junit.XIntervalSeriesCollectionTest.java

/**
 * A test for bug report 1170825 (originally affected XYSeriesCollection,
 * this test is just copied over)./*from ww  w.ja va 2 s  . c o m*/
 */
public void test1170825() {
    XIntervalSeries s1 = new XIntervalSeries("Series1");
    XIntervalSeriesCollection dataset = new XIntervalSeriesCollection();
    dataset.addSeries(s1);
    try {
        /* XYSeries s = */ dataset.getSeries(1);
    } catch (IllegalArgumentException e) {
        // correct outcome
    } catch (IndexOutOfBoundsException e) {
        assertTrue(false); // wrong outcome
    }
}

From source file:org.esa.beam.visat.toolviews.stat.HistogramPanel.java

private void createUI() {
    dataset = new XIntervalSeriesCollection();
    chart = ChartFactory.createHistogram(CHART_TITLE, "Values", "Frequency in #pixels", dataset,
            PlotOrientation.VERTICAL, false, // Legend?
            true, // tooltips
            false // url
    );//from   w w w  .j av a2  s  . c o  m
    final XYPlot xyPlot = chart.getXYPlot();
    xyPlot.setDomainZeroBaselineStroke(new BasicStroke(0.2f));

    final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);
    renderer.setShadowYOffset(-4.0);
    renderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setSeriesPaint(0, new Color(0, 0, 200));

    createUI(createChartPanel(chart), createOptionsPanel(), bindingContext);

    isInitialized = true;

    final Binding minBinding = xAxisRangeControl.getBindingContext().getBinding("min");
    final double min = (Double) minBinding.getPropertyValue();
    final Binding maxBinding = xAxisRangeControl.getBindingContext().getBinding("max");
    final double max = (Double) maxBinding.getPropertyValue();
    if (!histogramComputing && min > max) {
        minBinding.setPropertyValue(max);
        maxBinding.setPropertyValue(min);
    }
    updateXAxis();
}

From source file:org.jax.haplotype.analysis.visualization.GenomicGraphFactory.java

/**
 * Convert the intervals & values to a dataset that JFreeChart can use
 * @param snpIntervals//from   w  w  w  . j  a  v a  2  s. c o  m
 *          the intervals
 * @param visualInterval
 *          the visual interval that we should use
 * @return
 *          the data set
 */
private XYDataset createSnpIntervalHistogramData(final List<? extends RealValuedBasePairInterval> snpIntervals,
        final HighlightedSnpInterval visualInterval) {
    XIntervalSeriesCollection dataset = new XIntervalSeriesCollection();

    XIntervalSeries series = new XIntervalSeries("Interval Values", false, true);
    XIntervalSeries highlightSeries = new XIntervalSeries("Highlighted Interval Values", false, true);

    int endIndex = visualInterval.getEndIndex();
    int[] highlightIndices = visualInterval.getIndicesToHighlight();
    for (int i = visualInterval.getStartIndex(); i <= endIndex; i++) {
        RealValuedBasePairInterval currSnpInterval = snpIntervals.get(i);

        boolean highlight = false;
        for (int j = 0; j < highlightIndices.length; j++) {
            if (i == highlightIndices[j]) {
                highlight = true;
                break;
            }
        }

        if (highlight) {
            highlightSeries.add(currSnpInterval.getStartInBasePairs(), currSnpInterval.getStartInBasePairs(),
                    currSnpInterval.getEndInBasePairs(), currSnpInterval.getRealValue());
        } else {
            series.add(currSnpInterval.getStartInBasePairs(), currSnpInterval.getStartInBasePairs(),
                    currSnpInterval.getEndInBasePairs(), currSnpInterval.getRealValue());
        }
    }

    dataset.addSeries(series);
    dataset.addSeries(highlightSeries);
    return dataset;
}

From source file:desmoj.extensions.visualization2d.engine.modelGrafic.StatisticGrafic.java

/**
 * Build content for animationType StatisticGrafic.ANIMATION_Histogram
 * @return/*from  ww w . j  ava  2  s  .c  o  m*/
 * @throws ModelException
 */
private JPanel buildHistogramPanel() throws ModelException {
    XIntervalSeriesCollection dataset = new XIntervalSeriesCollection();
    dataset.addSeries(this.statistic.getHistogram());
    this.chart = ChartFactory.createXYBarChart(null, "Observation", false, "Count", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    this.chart.setBackgroundPaint(Grafic.COLOR_BACKGROUND);
    XYPlot plot = this.chart.getXYPlot();
    plot.setBackgroundPaint(StatisticGrafic.DIAGRAM_BACKGROUND);
    plot.setDomainGridlinePaint(StatisticGrafic.DIAGRAM_GRID);
    plot.setRangeGridlinePaint(StatisticGrafic.DIAGRAM_GRID);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    ValueAxis rangeAxis = (ValueAxis) plot.getRangeAxis();
    rangeAxis.setLabelFont(Grafic.FONT_DEFAULT);
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLabelFont(Grafic.FONT_DEFAULT);
    domainAxis.setAutoRange(true);

    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setShadowVisible(false);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setDrawBarOutline(true);
    renderer.setSeriesPaint(0, StatisticGrafic.DIAGRAM_FORGROUND);
    renderer.setSeriesOutlinePaint(0, StatisticGrafic.DIAGRAM_BORDER);
    renderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));

    this.buildHistogramAxisFormat(plot, "Observations");
    JPanel out = new ChartPanel(chart);
    out.setPreferredSize(new Dimension(350, 200));
    return out;
}

From source file:org.esa.beam.visat.toolviews.stat.HistogramPanel.java

private void setStx(Stx stx) {
    if (stx != null) {
        HistogramPanelModel.HistogramConfig config = createHistogramConfig();
        if (config == null) {
            return;
        }/*from w  w w.ja va  2s  .  co  m*/
        if (!model.hasStx(config)) {
            model.setStx(config, stx);
        }
        dataset = new XIntervalSeriesCollection();
        final int[] binCounts = stx.getHistogramBins();
        final RasterDataNode raster = getRaster();
        final XIntervalSeries series = new XIntervalSeries(raster.getName());
        final Histogram histogram = stx.getHistogram();
        for (int i = 0; i < binCounts.length; i++) {
            final double xMin = histogram.getBinLowValue(0, i);
            final double xMax = i < binCounts.length - 1 ? histogram.getBinLowValue(0, i + 1)
                    : histogram.getHighValue(0);
            series.add(xMin, xMin, xMax, binCounts[i]);
        }
        dataset.addSeries(series);
    }
    handleStxChange();
}

From source file:org.esa.snap.rcp.statistics.StatisticsPanel.java

private static ChartPanel createChartPanel(XIntervalSeries percentileSeries, String xAxisLabel,
        String yAxisLabel, Color color) {
    XIntervalSeriesCollection percentileDataset = new XIntervalSeriesCollection();
    percentileDataset.addSeries(percentileSeries);
    return getHistogramPlotPanel(percentileDataset, xAxisLabel, yAxisLabel, color);
}

From source file:org.esa.beam.visat.toolviews.stat.StatisticsPanel.java

private static ChartPanel createChartPanel(XIntervalSeries percentileSeries, String xAxisLabel,
        String yAxisLabel, Color color, double domainBounds[], double rangeBounds[]) {
    XIntervalSeriesCollection percentileDataset = new XIntervalSeriesCollection();
    percentileDataset.addSeries(percentileSeries);
    return getHistogramPlotPanel(percentileDataset, xAxisLabel, yAxisLabel, color, domainBounds, rangeBounds);
}

From source file:org.esa.beam.visat.toolviews.stat.StatisticsPanel.java

private static ChartPanel createScatterChartPanel(XIntervalSeries percentileSeries, String xAxisLabel,
        String yAxisLabel, Color color, double domainBounds[], double rangeBounds[]) {
    XIntervalSeriesCollection percentileDataset = new XIntervalSeriesCollection();
    percentileDataset.addSeries(percentileSeries);
    return getScatterPlotPanel(percentileDataset, xAxisLabel, yAxisLabel, color, domainBounds, rangeBounds);
}