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

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

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.openiot.gsn.vsensor.ChartVirtualSensor.java

/**
 * This method adds the specified stream elements to the timeSeries of the
 * appropriate plot./*from w w  w . j  av a2 s  .  co m*/
 * 
 * @param streamElement
 */
public synchronized void addData(StreamElement streamElement) {
    for (int i = 0; i < streamElement.getFieldNames().length; i++) {
        TimeSeries timeSeries = dataForTheChart.get(streamElement.getFieldNames()[i]);
        if (timeSeries == null) {
            dataForTheChart.put(streamElement.getFieldNames()[i],
                    timeSeries = new TimeSeries(streamElement.getFieldNames()[i],
                            org.jfree.data.time.FixedMillisecond.class));
            timeSeries.setMaximumItemCount(historySize);
            dataCollectionForTheChart.addSeries(timeSeries);
        }
        try {
            timeSeries.addOrUpdate(new FixedMillisecond(new Date(streamElement.getTimeStamp())),
                    Double.parseDouble(streamElement.getData()[i].toString()));
        } catch (SeriesException e) {
            logger.warn(e.getMessage(), e);
        }

    }
    changed = true;
}

From source file:gsn.vsensor.ChartVirtualSensor.java

/**
 * This method adds the specified stream elements to the timeSeries of the
 * appropriate plot.//www . j  a v  a  2s.  co m
 * 
 * @param streamElement
 */
public synchronized void addData(StreamElement streamElement) {
    for (int i = 0; i < streamElement.getFieldNames().length; i++) {
        TimeSeries timeSeries = dataForTheChart.get(streamElement.getFieldNames()[i]);
        if (timeSeries == null) {
            dataForTheChart.put(streamElement.getFieldNames()[i],
                    timeSeries = new TimeSeries(streamElement.getFieldNames()[i],
                            org.jfree.data.time.FixedMillisecond.class));
            if (isTimeBased) {
                timeSeries.setMaximumItemAge(historySize);
            } else {
                timeSeries.setMaximumItemCount(historySize);
            }
            dataCollectionForTheChart.addSeries(timeSeries);
        }
        try {
            timeSeries.addOrUpdate(new FixedMillisecond(new Date(streamElement.getTimeStamp())),
                    Double.parseDouble(streamElement.getData()[i].toString()));
        } catch (SeriesException e) {
            logger.warn(e.getMessage(), e);
        }

    }
    changed = true;
}

From source file:gov.llnl.lustre.lwatch.PlotFrame2.java

/**
 * Create the dataset for the set of TimeSeries curves to be plotted.
 *//*from   w w  w. j ava2s. c o  m*/

public XYDataset createDataset() {

    // Load data for settings from last "Refresh" time
    String[] selectedRows = lastRefreshPlotParams.getCategories();
    String[] selectedVars = lastRefreshPlotParams.getVariables();
    String[] selectedCurves = lastRefreshPlotParams.getCurves();

    int savedGranularity = granularity;
    granularity = lastRefreshPlotParams.getGranularity();

    if (localDebug)
        Debug.out("Granularity used for timeSeries generation is " + granularity);

    //int nLines = nRowsSelected * nColsSelected * nCurvesSelected;
    int nLines = selectedRows.length * selectedVars.length * selectedCurves.length;
    //TimeSeries [] ts = new TimeSeries[nRowsSelected * nColsSelected *
    //nCurvesSelected];
    TimeSeries[] ts = new TimeSeries[nLines];

    int row = 0;
    int col = 0;
    int crv = -1;
    long tmBeg = tsStartPlot.getTime();
    long tmEnd = tsEndPlot.getTime();

    for (int i = 0; i < nLines; i++) {
        //if (localDebug)
        //Debug.out("Plot curve # " + i);

        //if (dataPointCount[i] <=0) {
        //Debug.out("dataPointCount[" + i + "] <= 0. Skip it.");
        //}

        crv++;
        if (crv == selectedCurves.length) {
            crv = 0;
            col++;
            if (col == selectedVars.length) {
                col = 0;
                row++;
            }
        }
        int tindx = i / selectedCurves.length;

        //String catvar = cats2Plot[row] + " " + vars2Plot[col] + crvs2Plot[crv];
        String catvar = selectedRows[row] + " " + selectedVars[col] + selectedCurves[crv];
        //Debug.out("Plot line for " + catvar);
        if (granularity == Database.HOUR)
            ts[i] = new TimeSeries(catvar, Hour.class);
        else if (granularity == Database.DAY)
            ts[i] = new TimeSeries(catvar, Day.class);
        else if (granularity == Database.WEEK)
            ts[i] = new TimeSeries(catvar, Week.class);
        else if (granularity == Database.MONTH)
            ts[i] = new TimeSeries(catvar, Month.class);
        else if (granularity == Database.YEAR)
            ts[i] = new TimeSeries(catvar, Year.class);
        else if ((granularity == Database.RAW) || (granularity == HEARTBEAT)) {
            //if (limitedDebug) {
            //System.out.println("\n\n" + i + "  " + catvar);
            //}
            ts[i] = new TimeSeries(catvar, Second.class);
        }

        if (rawData == null) {
            if (localDebug)
                Debug.out("ERROR     RawData = null");
            return null;
        }

        if (rawData[i] == null) {
            if (localDebug)
                Debug.out("ERROR     RawData[" + i + "] = null");
            return null;
        }

        int dsSize = dataPointCount[i]; //rawData[i].length;

        if (localDebug) {
            Debug.out("Size of " + catvar + " data set # " + i + " = " + dsSize);
        }

        int includeCnt = 0;
        for (int j = 0; j <= dataPointCount[i] - 1; j++) {
            //if (localDebug)
            //Debug.out("tindx " + tindx + "  j " + j + " secs " +
            //rawTimes[tindx][j]);
            long rawT = rawTimes[tindx][j];
            if ((rawT >= tmBeg) && (rawT <= tmEnd)) {
                float rangeVal = rawData[i][j];
                if (useLogRangeAxis && (rangeVal <= 0.0))
                    rangeVal = 1;

                try {
                    if (granularity == Database.HOUR)
                        ts[i].add(new Hour(new Date(rawT)), rangeVal, false);
                    else if (granularity == Database.DAY)
                        ts[i].add(new Day(new Date(rawT)), rangeVal, false);
                    else if (granularity == Database.WEEK)
                        ts[i].add(new Week(new Date(rawT)), rangeVal, false);
                    else if (granularity == Database.MONTH)
                        ts[i].add(new Month(new Date(rawT)), rangeVal, false);
                    else if (granularity == Database.YEAR)
                        ts[i].add(new Year(new Date(rawT)), rangeVal, false);
                    else if ((granularity == Database.RAW) || (granularity == HEARTBEAT)) {
                        includeCnt++;
                        //if (localDebug) {
                        //System.out.println(i + " " + j + " " +
                        //(new Second(new Date(rawT))).toString() +
                        //"  " + rangeVal);
                        //}
                        ts[i].add(new Second(new Date(rawT)), rangeVal, false);

                    }
                } catch (org.jfree.data.general.SeriesException e) {
                    if (localDebug)
                        Debug.out("Exception detected while calculating Timestamp objects. Problem at rawT = "
                                + rawT + "\n" + e.getMessage());
                }
            }
        }
        if (localDebug)
            Debug.out("# of points included in time series = " + includeCnt + "\n# of curves to be plotted = "
                    + nLines);
    }
    if (localDebug)
        Debug.out("\nTimeSeries array generation complete\n");

    // *****************************************************************
    //  More than 150 demo applications are included with the JFreeChar
    //  Developer Guide...for more information, see
    //
    //  >   http://www.object-refinery.com/jfreechart/guide.html
    //
    // ******************************************************************

    TimeSeriesCollection dataset = new TimeSeriesCollection();

    for (int i = 0; i < nLines; i++) {
        if (dataPointCount[i] > 0) {
            if (localDebug)
                Debug.out("Add timeSeries # " + i + " to chart dataset.");
            dataset.addSeries(ts[i]);
        }
    }

    // Reset granularity;
    granularity = savedGranularity;

    return dataset;

}