Example usage for org.jfree.data.xy XYSeries setNotify

List of usage examples for org.jfree.data.xy XYSeries setNotify

Introduction

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

Prototype

public void setNotify(boolean notify) 

Source Link

Document

Sets the flag that controls whether or not change events are sent to registered listeners.

Usage

From source file:umontreal.iro.lecuyer.charts.XYListSeriesCollection.java

/**
 * Adds  data series into the series collection. The input format of
 *  <TT>data</TT> is described in constructor
 * <TT>XYListSeriesCollection(double[][] data)</TT>.
 *   Only <SPAN  CLASS="textit">the first</SPAN> <TT>numPoints</TT> of <TT>data</TT>
 *  (the first <TT>numPoints</TT> columns of the matrix)
 *   will be added to each new series./*from w w  w. j  a  v a  2  s. co  m*/
 * 
 * @param data input data.
 * 
 *    @param numPoints Number of points to add for each new series
 * 
 *    @return Integer that represent the number of point sets added to the current dataset.
 * 
 */
public int add(double[][] data, int numPoints) {
    XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection;
    int n = tempSeriesCollection.getSeriesCount();

    if (data.length < 2)
        throw new IllegalArgumentException("Unable to render the plot. data contains less than two rows");

    for (int j = 0; j < data.length; j++)
        if (data[j].length < numPoints)
            throw new IllegalArgumentException("data[" + j + "] has not enough points");

    for (int j = 1; j < data.length; j++) {
        XYSeries serie = new XYSeries(" ");
        serie.setNotify(true);
        for (int k = 0; k < numPoints; k++)
            serie.add(data[0][k], data[j][k]);
        tempSeriesCollection.addSeries(serie);
    }

    // color
    for (int j = n; j < tempSeriesCollection.getSeriesCount(); j++)
        renderer.setSeriesPaint(j, getDefaultColor(j));

    String[] newPlotStyle = new String[tempSeriesCollection.getSeriesCount()];
    String[] newMarksType = new String[tempSeriesCollection.getSeriesCount()];
    String[] newDashPattern = new String[tempSeriesCollection.getSeriesCount()];
    for (int j = 0; j < n; j++) {
        newPlotStyle[j] = plotStyle[j];
        newMarksType[j] = marksType[j];
        newDashPattern[j] = dashPattern[j];
    }

    for (int j = n; j < tempSeriesCollection.getSeriesCount(); j++) {
        newPlotStyle[j] = "smooth";
        newMarksType[j] = " ";
        newDashPattern[j] = "solid";
    }
    plotStyle = newPlotStyle;
    marksType = newMarksType;
    dashPattern = newDashPattern;

    return (tempSeriesCollection.getSeriesCount() - n);
}

From source file:umontreal.iro.lecuyer.charts.XYListSeriesCollection.java

/**
 * Adds a data series into the series collection. Vector <TT>x</TT> represents
 *    the <SPAN CLASS="MATH"><I>x</I></SPAN>-coordinates and vector <TT>y</TT> represents the <SPAN CLASS="MATH"><I>y</I></SPAN>-coordinates of
 *    the series. Only <SPAN  CLASS="textit">the first</SPAN> <TT>numPoints</TT> of <TT>x</TT>
 *    and <TT>y</TT> will be added to the new series.
 * //from  www . ja  v  a2s. c om
 * @param x <SPAN CLASS="MATH"><I>x</I><SUB>i</SUB></SPAN> coordinates.
 * 
 *    @param y <SPAN CLASS="MATH"><I>y</I><SUB>i</SUB></SPAN> coordinates.
 * 
 *    @param numPoints Number of points to add
 * 
 *    @return Integer that represent the new point set's position in the JFreeChart <TT>XYSeriesCollection</TT> object.
 * 
 */
public int add(double[] x, double[] y, int numPoints) {
    XYSeries serie = new XYSeries(" ");
    XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection;
    serie.setNotify(true);
    if ((x.length < numPoints) || (y.length < numPoints))
        throw new IllegalArgumentException("numPoints > length of x or y");
    for (int i = 0; i < numPoints; i++)
        serie.add(x[i], y[i]);
    tempSeriesCollection.addSeries(serie);

    // color
    int j = tempSeriesCollection.getSeriesCount() - 1;
    renderer.setSeriesPaint(j, getDefaultColor(j));

    int co = tempSeriesCollection.getSeriesCount();
    String[] newPlotStyle = new String[co];
    String[] newMarksType = new String[co];
    String[] newDashPattern = new String[co];
    for (j = 0; j < co - 1; j++) {
        newPlotStyle[j] = plotStyle[j];
        newMarksType[j] = marksType[j];
        newDashPattern[j] = dashPattern[j];
    }

    newPlotStyle[j] = "smooth";
    newMarksType[j] = " ";
    newDashPattern[j] = "solid";
    plotStyle = newPlotStyle;
    marksType = newMarksType;
    dashPattern = newDashPattern;

    return tempSeriesCollection.getSeriesCount() - 1;
}

From source file:com.ivli.roim.controls.ChartView.java

@Override
public void OverlayChanged(OverlayChangeEvent anEvt) {
    LOG.debug(anEvt);/*from www .  ja v a2s . c  o m*/

    if (anEvt.getObject() instanceof ROI) {
        XYSeriesCollection col = ((XYSeriesCollection) iPlot.getDataset());
        final OverlayManager mgr = (OverlayManager) anEvt.getSource();

        switch (anEvt.getCode()) {
        case CREATED: {
            assert (0 > col.indexOf(anEvt.getObject().getName()));

            final XYSeries s = new XYSeries(anEvt.getObject().getName(), true, false);
            final ISeries c = ((ROI) anEvt.getObject()).getSeries(Measurement.DENSITY);

            IMultiframeImage img = mgr.getImage();

            assert (c.size() == img.getTimeSliceVector().getNumFrames());

            for (int n = 0; n < c.size(); ++n)
                s.add(img.getTimeSliceVector().getSlices().get(n) / 1000., c.get(n));

            ((XYSeriesCollection) iPlot.getDataset()).addSeries(s);
            iPlot.getRenderer().setSeriesPaint(col.indexOf(anEvt.getObject().getName()),
                    ((ROI) anEvt.getObject()).getColor());
        }
            break;

        case DELETED: {
            final int ndx = col.indexOf(anEvt.getObject().getName());
            col.removeSeries(ndx);
        }
            break;

        case MOVED: {//fall-through                                                                      
            final int ndx = col.indexOf(anEvt.getObject().getName());
            ISeries c = ((ROI) anEvt.getObject()).getSeries(Measurement.DENSITY);
            XYSeries s = col.getSeries(ndx);
            s.setNotify(false);
            s.clear();

            for (int n = 0; n < c.size(); ++n) {
                long dur = mgr.getImage().getTimeSliceVector().getSlices().get(n) / 1000;
                s.add(dur, c.get(n));
            }
            s.setNotify(true);
            //s.fireSeriesChanged();

        }
            break;

        case COLOR_CHANGED: {
            assert (anEvt.getExtra() instanceof java.awt.Color);
            final int ndx = col.indexOf(anEvt.getObject().getName());
            iPlot.getRenderer().setSeriesPaint(ndx, ((ROI) anEvt.getObject()).getColor());
        }
            break;

        case NAME_CHANGED: {
            assert (anEvt.getExtra() instanceof String);
            LOG.debug("ROI" + (String) anEvt.getExtra() + "name changed to " + anEvt.getObject().getName());

            final int ndx = col.indexOf(((String) anEvt.getExtra()));

            col.getSeries(ndx).setKey(anEvt.getObject().getName());
            /* this is a work-around the case when two or more ROI have the same names (user mistakenly renamed) 
             * when this mistake is corrected it might happen the colors of curves does not match colors of corresponding ROI 
             */
            iPlot.getRenderer().setSeriesPaint(ndx, ((ROI) anEvt.getObject()).getColor());

        }
            break;

        default:
            ///throw new java.lang.IllegalArgumentException();    
            break;
        }
    }
}