Example usage for org.jfree.data.general SeriesException printStackTrace

List of usage examples for org.jfree.data.general SeriesException printStackTrace

Introduction

In this page you can find the example usage for org.jfree.data.general SeriesException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.jfree.data.time.junit.TimeSeriesTest.java

/**
 * Check that cloning works./*w w w. j  av a  2s .c o  m*/
 */
public void testClone() {

    TimeSeries series = new TimeSeries("Test Series");

    RegularTimePeriod jan1st2002 = new Day(1, MonthConstants.JANUARY, 2002);
    try {
        series.add(jan1st2002, new Integer(42));
    } catch (SeriesException e) {
        System.err.println("Problem adding to series.");
    }

    TimeSeries clone = null;
    try {
        clone = (TimeSeries) series.clone();
        clone.setKey("Clone Series");
        try {
            clone.update(jan1st2002, new Integer(10));
        } catch (SeriesException e) {
            e.printStackTrace();
        }
    } catch (CloneNotSupportedException e) {
        assertTrue(false);
    }

    int seriesValue = series.getValue(jan1st2002).intValue();
    int cloneValue = Integer.MAX_VALUE;
    if (clone != null) {
        cloneValue = clone.getValue(jan1st2002).intValue();
    }

    assertEquals(42, seriesValue);
    assertEquals(10, cloneValue);
    assertEquals("Test Series", series.getKey());
    if (clone != null) {
        assertEquals("Clone Series", clone.getKey());
    } else {
        assertTrue(false);
    }

}

From source file:com.sun.japex.ChartGenerator.java

private int generateTestCaseScatterCharts(String baseName, String extension) {
    int nOfFiles = 0;
    List<DriverImpl> driverInfoList = _testSuite.getDriverInfoList();

    try {//from   www.  ja  v a 2 s. co m
        // Get number of tests from first driver
        final int nOfTests = driverInfoList.get(0).getAggregateTestCases().size();

        DefaultTableXYDataset xyDataset = new DefaultTableXYDataset();

        // Generate charts
        for (DriverImpl di : driverInfoList) {
            XYSeries xySeries = new XYSeries(di.getName(), true, false);
            for (int j = 0; j < nOfTests; j++) {
                TestCaseImpl tc = (TestCaseImpl) di.getAggregateTestCases().get(j);
                try {
                    xySeries.add(tc.getDoubleParamNoNaN(Constants.RESULT_VALUE_X),
                            tc.getDoubleParamNoNaN(Constants.RESULT_VALUE));
                } catch (SeriesException e) {
                    // Ignore duplicate x-valued points
                }

            }
            xyDataset.addSeries(xySeries);
        }

        String resultUnit = _testSuite.getParam(Constants.RESULT_UNIT);
        String resultUnitX = _testSuite.getParam(Constants.RESULT_UNIT_X);

        JFreeChart chart = ChartFactory.createScatterPlot("Results Per Test", resultUnitX, resultUnit,
                xyDataset, PlotOrientation.VERTICAL, true, true, false);

        // Set log scale depending on japex.resultAxis[_X]
        XYPlot plot = chart.getXYPlot();
        if (_testSuite.getParam(Constants.RESULT_AXIS_X).equalsIgnoreCase("logarithmic")) {
            LogarithmicAxis logAxisX = new LogarithmicAxis(resultUnitX);
            logAxisX.setAllowNegativesFlag(true);
            plot.setDomainAxis(logAxisX);
        }
        if (_testSuite.getParam(Constants.RESULT_AXIS).equalsIgnoreCase("logarithmic")) {
            LogarithmicAxis logAxis = new LogarithmicAxis(resultUnit);
            logAxis.setAllowNegativesFlag(true);
            plot.setRangeAxis(logAxis);
        }

        chart.setAntiAlias(true);
        ChartUtilities.saveChartAsJPEG(new File(baseName + Integer.toString(nOfFiles) + extension), chart,
                _chartWidth, _chartHeight);
        nOfFiles++;
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return nOfFiles;
}